File tree Expand file tree Collapse file tree 4 files changed +56
-12
lines changed
Expand file tree Collapse file tree 4 files changed +56
-12
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,16 @@ import processOpenIDScopes from '../utils/processOpenIDScopes';
4545 * Default configurations.
4646 */
4747const DefaultConfig : Partial < AuthClientConfig < unknown > > = {
48- clockTolerance : 300 ,
48+ tokenValidation : {
49+ idToken : {
50+ validate : true ,
51+ validateIssuer : true ,
52+ clockTolerance : 300 ,
53+ } ,
54+ } ,
4955 enablePKCE : true ,
5056 responseMode : 'query' ,
5157 sendCookiesInRequests : true ,
52- validateIDToken : true ,
53- validateIDTokenIssuer : true ,
5458} ;
5559
5660/**
Original file line number Diff line number Diff line change @@ -197,8 +197,8 @@ export class AuthenticationHelper<T> {
197197 ( await this . _config ( ) ) . clientId ,
198198 issuer ?? '' ,
199199 this . _cryptoHelper . decodeIdToken ( idToken ) . sub ,
200- ( await this . _config ( ) ) . clockTolerance ,
201- ( await this . _config ( ) ) . validateIDTokenIssuer ?? true ,
200+ ( await this . _config ( ) ) . tokenValidation ?. idToken ?. clockTolerance ,
201+ ( await this . _config ( ) ) . tokenValidation ?. idToken ?. validateIssuer ?? true ,
202202 ) ;
203203 }
204204
@@ -257,7 +257,7 @@ export class AuthenticationHelper<T> {
257257
258258 parsedResponse . created_at = new Date ( ) . getTime ( ) ;
259259
260- const shouldValidateIdToken : boolean | undefined = ( await this . _config ( ) ) . validateIDToken ;
260+ const shouldValidateIdToken : boolean | undefined = ( await this . _config ( ) ) . tokenValidation ?. idToken ?. validate ;
261261
262262 if ( shouldValidateIdToken ) {
263263 return this . validateIdToken ( parsedResponse . id_token ) . then ( async ( ) => {
Original file line number Diff line number Diff line change @@ -29,12 +29,25 @@ export interface DefaultAuthClientConfig {
2929 prompt ?: string ;
3030 responseMode ?: OAuthResponseMode ;
3131 scopes ?: string | string [ ] | undefined ;
32- validateIDToken ?: boolean ;
33- validateIDTokenIssuer ?: boolean ;
34- /**
35- * Allowed leeway for id_tokens (in seconds).
36- */
37- clockTolerance ?: number ;
32+ tokenValidation ?: {
33+ /**
34+ * ID token validation config.
35+ */
36+ idToken ?: {
37+ /**
38+ * Whether to validate ID tokens.
39+ */
40+ validate ?: boolean ;
41+ /**
42+ * Whether to validate the issuer of ID tokens.
43+ */
44+ validateIssuer ?: boolean ;
45+ /**
46+ * Allowed leeway for ID tokens (in seconds).
47+ */
48+ clockTolerance ?: number ;
49+ } ;
50+ } ;
3851 /**
3952 * Specifies if cookies should be sent with access-token requests, refresh-token requests,
4053 * custom-grant requests, etc.
Original file line number Diff line number Diff line change @@ -107,6 +107,33 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
107107 * and use the `SignUp` component to render it.
108108 */
109109 signUpUrl ?: string | undefined ;
110+
111+ /**
112+ * Token validation configuration.
113+ * This allows you to configure how the SDK validates tokens received from the authorization server.
114+ * It includes options for ID token validation, such as whether to validate the token,
115+ * whether to validate the issuer, and the allowed clock tolerance for token validation.
116+ * If not provided, the SDK will use default validation settings.
117+ */
118+ tokenValidation ?: {
119+ /**
120+ * ID token validation config.
121+ */
122+ idToken ?: {
123+ /**
124+ * Whether to validate ID tokens.
125+ */
126+ validate ?: boolean ;
127+ /**
128+ * Whether to validate the issuer of ID tokens.
129+ */
130+ validateIssuer ?: boolean ;
131+ /**
132+ * Allowed leeway for ID tokens (in seconds).
133+ */
134+ clockTolerance ?: number ;
135+ } ;
136+ } ;
110137}
111138
112139export interface WithPreferences {
You can’t perform that action at this time.
0 commit comments