File tree Expand file tree Collapse file tree 7 files changed +24
-8
lines changed
react/src/contexts/Asgardeo Expand file tree Collapse file tree 7 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ import {SPAUtils} from './utils';
53
53
const DefaultConfig : Partial < AuthClientConfig < Config > > = {
54
54
autoLogoutOnTokenRefreshError : false ,
55
55
checkSessionInterval : 3 ,
56
- enableOIDCSessionManagement : false ,
56
+ syncSession : false ,
57
57
periodicTokenRefresh : false ,
58
58
sessionRefreshInterval : 300 ,
59
59
storage : BrowserStorage . SessionStorage ,
Original file line number Diff line number Diff line change @@ -406,7 +406,7 @@ export const MainThreadClient = async (
406
406
await _authenticationClient . reInitialize ( config ) ;
407
407
408
408
// Re-initiates check session if the check session endpoint is updated.
409
- if ( config . enableOIDCSessionManagement && isCheckSessionIframeDifferent ) {
409
+ if ( config . syncSession && isCheckSessionIframeDifferent ) {
410
410
_sessionManagementHelper . reset ( ) ;
411
411
412
412
checkSession ( ) ;
Original file line number Diff line number Diff line change @@ -506,7 +506,7 @@ export const WebWorkerClient = async (
506
506
SPAUtils . setSignOutURL ( url , config . clientId , instanceID ) ;
507
507
508
508
// Enable OIDC Sessions Management only if it is set to true in the config.
509
- if ( config . enableOIDCSessionManagement ) {
509
+ if ( config . syncSession ) {
510
510
checkSession ( ) ;
511
511
}
512
512
@@ -534,7 +534,7 @@ export const WebWorkerClient = async (
534
534
await startAutoRefreshToken ( ) ;
535
535
536
536
// Enable OIDC Sessions Management only if it is set to true in the config.
537
- if ( config . enableOIDCSessionManagement ) {
537
+ if ( config . syncSession ) {
538
538
checkSession ( ) ;
539
539
}
540
540
@@ -829,7 +829,7 @@ export const WebWorkerClient = async (
829
829
await communicate < Partial < AuthClientConfig < WebWorkerClientConfig > > , void > ( message ) ;
830
830
831
831
// Re-initiates check session if the check session endpoint is updated.
832
- if ( config . enableOIDCSessionManagement && isCheckSessionIframeDifferent ) {
832
+ if ( config . syncSession && isCheckSessionIframeDifferent ) {
833
833
_sessionManagementHelper . reset ( ) ;
834
834
835
835
checkSession ( ) ;
Original file line number Diff line number Diff line change @@ -480,7 +480,7 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
480
480
}
481
481
482
482
// Enable OIDC Sessions Management only if it is set to true in the config.
483
- if ( checkSession && typeof checkSession === 'function' && config . enableOIDCSessionManagement ) {
483
+ if ( checkSession && typeof checkSession === 'function' && config . syncSession ) {
484
484
checkSession ( ) ;
485
485
}
486
486
} else {
@@ -606,7 +606,7 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
606
606
this . _spaHelper . refreshAccessTokenAutomatically ( this ) ;
607
607
608
608
// Enable OIDC Sessions Management only if it is set to true in the config.
609
- if ( config . enableOIDCSessionManagement ) {
609
+ if ( config . syncSession ) {
610
610
checkSession ( ) ;
611
611
}
612
612
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export interface SPAConfig {
25
25
* @remarks If the consumer app the OP is hosted in different domains,
26
26
* third party cookies has to be enabled for this to work properly.
27
27
*/
28
- enableOIDCSessionManagement ?: boolean ;
28
+ syncSession ?: boolean ;
29
29
checkSessionInterval ?: number ;
30
30
sessionRefreshInterval ?: number ;
31
31
resourceServerURLs ?: string [ ] ;
Original file line number Diff line number Diff line change @@ -185,6 +185,18 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
185
185
* @see {@link SignUpOptions } for more details.
186
186
*/
187
187
signUpOptions ?: SignUpOptions ;
188
+
189
+ /**
190
+ * Flag to indicate whether the Application session should be synchronized with the IdP session.
191
+ * @remarks This uses the OIDC iframe base session management feature to keep the application session in sync with the IdP session.
192
+ * WARNING: This may not work in all browsers due to 3rd party cookie restrictions.
193
+ * It is recommended to use this feature only if you are aware of the implications and have tested it in your target browsers.
194
+ * If you are not sure, it is safer to leave this option as `false`.
195
+ * @example
196
+ * syncSession: true
197
+ * @see {@link https://openid.net/specs/openid-connect-session-management-1_0.html#IframeBasedSessionManagement }
198
+ */
199
+ syncSession ?: boolean ;
188
200
}
189
201
190
202
export interface WithPreferences {
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
57
57
organizationHandle,
58
58
applicationId,
59
59
signInOptions,
60
+ syncSession,
60
61
...rest
61
62
} : PropsWithChildren < AsgardeoProviderProps > ) : ReactElement => {
62
63
const reRenderCheckRef : RefObject < boolean > = useRef ( false ) ;
@@ -83,6 +84,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
83
84
signUpUrl,
84
85
signInUrl,
85
86
signInOptions,
87
+ syncSession,
86
88
...rest ,
87
89
} ) ;
88
90
@@ -397,6 +399,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
397
399
} ,
398
400
signInOptions,
399
401
getDecodedIdToken : asgardeo . getDecodedIdToken . bind ( asgardeo ) ,
402
+ syncSession,
400
403
} ) ,
401
404
[
402
405
applicationId ,
@@ -414,6 +417,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
414
417
user ,
415
418
asgardeo ,
416
419
signInOptions ,
420
+ syncSession ,
417
421
] ,
418
422
) ;
419
423
You can’t perform that action at this time.
0 commit comments