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", () => {
164
164
165
165
expect ( authUrl . searchParams . get ( "prompt" ) ) . toEqual ( "create" ) ;
166
166
} ) ;
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
+ } ) ;
167
184
} ) ;
168
185
169
186
describe ( "completeAuthorizationCodeGrant" , ( ) => {
Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ export const generateAuthorizationUrl = async (
125
125
* @param prompt - indicates to the OP which flow the user should see - eg login or registration
126
126
* See https://openid.net/specs/openid-connect-prompt-create-1_0.html#name-prompt-parameter
127
127
* @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}.
128
130
* @returns a Promise with the url as a string
129
131
*/
130
132
export const generateOidcAuthorizationUrl = async ( {
@@ -136,6 +138,7 @@ export const generateOidcAuthorizationUrl = async ({
136
138
nonce,
137
139
prompt,
138
140
urlState,
141
+ loginHint,
139
142
} : {
140
143
clientId : string ;
141
144
metadata : ValidatedAuthMetadata ;
@@ -145,6 +148,7 @@ export const generateOidcAuthorizationUrl = async ({
145
148
nonce : string ;
146
149
prompt ?: string ;
147
150
urlState ?: string ;
151
+ loginHint ?: string ;
148
152
} ) : Promise < string > => {
149
153
const scope = generateScope ( ) ;
150
154
const oidcClient = new OidcClient ( {
@@ -163,6 +167,7 @@ export const generateOidcAuthorizationUrl = async ({
163
167
nonce,
164
168
prompt,
165
169
url_state : urlState ,
170
+ login_hint : loginHint ,
166
171
} ) ;
167
172
168
173
return request . url ;
You can’t perform that action at this time.
0 commit comments