File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,23 @@ describe("oidc authorization", () => {
164164
165165 expect ( authUrl . searchParams . get ( "prompt" ) ) . toEqual ( "create" ) ;
166166 } ) ;
167+
168+ it ( "should generate url with login_hint" , async ( ) => {
169+ const nonce = "abc123" ;
170+
171+ const authUrl = new URL (
172+ await generateOidcAuthorizationUrl ( {
173+ metadata : delegatedAuthConfig ,
174+ homeserverUrl : baseUrl ,
175+ clientId,
176+ redirectUri : baseUrl ,
177+ nonce,
178+ loginHint : "login1234" ,
179+ } ) ,
180+ ) ;
181+
182+ expect ( authUrl . searchParams . get ( "login_hint" ) ) . toEqual ( "login1234" ) ;
183+ } ) ;
167184 } ) ;
168185
169186 describe ( "completeAuthorizationCodeGrant" , ( ) => {
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ export const generateAuthorizationUrl = async (
125125 * @param prompt - indicates to the OP which flow the user should see - eg login or registration
126126 * See https://openid.net/specs/openid-connect-prompt-create-1_0.html#name-prompt-parameter
127127 * @param urlState - value to append to the opaque state identifier to uniquely identify the callback
128+ * @param loginHint - value to send as the `login_hint` to the OP, giving a hint about the login identifier the user might use to log in.
129+ * See {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest OIDC core 3.1.2.1}.
128130 * @returns a Promise with the url as a string
129131 */
130132export const generateOidcAuthorizationUrl = async ( {
@@ -136,6 +138,7 @@ export const generateOidcAuthorizationUrl = async ({
136138 nonce,
137139 prompt,
138140 urlState,
141+ loginHint,
139142} : {
140143 clientId : string ;
141144 metadata : ValidatedAuthMetadata ;
@@ -145,6 +148,7 @@ export const generateOidcAuthorizationUrl = async ({
145148 nonce : string ;
146149 prompt ?: string ;
147150 urlState ?: string ;
151+ loginHint ?: string ;
148152} ) : Promise < string > => {
149153 const scope = generateScope ( ) ;
150154 const oidcClient = new OidcClient ( {
@@ -163,6 +167,7 @@ export const generateOidcAuthorizationUrl = async ({
163167 nonce,
164168 prompt,
165169 url_state : urlState ,
170+ login_hint : loginHint ,
166171 } ) ;
167172
168173 return request . url ;
You can’t perform that action at this time.
0 commit comments