Skip to content

Commit 51137e9

Browse files
committed
feat: replace enableOIDCSessionManagement with syncSession for session management configuration
1 parent 3452b9d commit 51137e9

File tree

7 files changed

+24
-8
lines changed

7 files changed

+24
-8
lines changed

packages/browser/src/__legacy__/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {SPAUtils} from './utils';
5353
const DefaultConfig: Partial<AuthClientConfig<Config>> = {
5454
autoLogoutOnTokenRefreshError: false,
5555
checkSessionInterval: 3,
56-
enableOIDCSessionManagement: false,
56+
syncSession: false,
5757
periodicTokenRefresh: false,
5858
sessionRefreshInterval: 300,
5959
storage: BrowserStorage.SessionStorage,

packages/browser/src/__legacy__/clients/main-thread-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export const MainThreadClient = async (
406406
await _authenticationClient.reInitialize(config);
407407

408408
// Re-initiates check session if the check session endpoint is updated.
409-
if (config.enableOIDCSessionManagement && isCheckSessionIframeDifferent) {
409+
if (config.syncSession && isCheckSessionIframeDifferent) {
410410
_sessionManagementHelper.reset();
411411

412412
checkSession();

packages/browser/src/__legacy__/clients/web-worker-client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export const WebWorkerClient = async (
506506
SPAUtils.setSignOutURL(url, config.clientId, instanceID);
507507

508508
// Enable OIDC Sessions Management only if it is set to true in the config.
509-
if (config.enableOIDCSessionManagement) {
509+
if (config.syncSession) {
510510
checkSession();
511511
}
512512

@@ -534,7 +534,7 @@ export const WebWorkerClient = async (
534534
await startAutoRefreshToken();
535535

536536
// Enable OIDC Sessions Management only if it is set to true in the config.
537-
if (config.enableOIDCSessionManagement) {
537+
if (config.syncSession) {
538538
checkSession();
539539
}
540540

@@ -829,7 +829,7 @@ export const WebWorkerClient = async (
829829
await communicate<Partial<AuthClientConfig<WebWorkerClientConfig>>, void>(message);
830830

831831
// Re-initiates check session if the check session endpoint is updated.
832-
if (config.enableOIDCSessionManagement && isCheckSessionIframeDifferent) {
832+
if (config.syncSession && isCheckSessionIframeDifferent) {
833833
_sessionManagementHelper.reset();
834834

835835
checkSession();

packages/browser/src/__legacy__/helpers/authentication-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
480480
}
481481

482482
// 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) {
484484
checkSession();
485485
}
486486
} else {
@@ -606,7 +606,7 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
606606
this._spaHelper.refreshAccessTokenAutomatically(this);
607607

608608
// Enable OIDC Sessions Management only if it is set to true in the config.
609-
if (config.enableOIDCSessionManagement) {
609+
if (config.syncSession) {
610610
checkSession();
611611
}
612612

packages/browser/src/__legacy__/models/client-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface SPAConfig {
2525
* @remarks If the consumer app the OP is hosted in different domains,
2626
* third party cookies has to be enabled for this to work properly.
2727
*/
28-
enableOIDCSessionManagement?: boolean;
28+
syncSession?: boolean;
2929
checkSessionInterval?: number;
3030
sessionRefreshInterval?: number;
3131
resourceServerURLs?: string[];

packages/javascript/src/models/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@ export interface BaseConfig<T = unknown> extends WithPreferences {
185185
* @see {@link SignUpOptions} for more details.
186186
*/
187187
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;
188200
}
189201

190202
export interface WithPreferences {

packages/react/src/contexts/Asgardeo/AsgardeoProvider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
5757
organizationHandle,
5858
applicationId,
5959
signInOptions,
60+
syncSession,
6061
...rest
6162
}: PropsWithChildren<AsgardeoProviderProps>): ReactElement => {
6263
const reRenderCheckRef: RefObject<boolean> = useRef(false);
@@ -83,6 +84,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
8384
signUpUrl,
8485
signInUrl,
8586
signInOptions,
87+
syncSession,
8688
...rest,
8789
});
8890

@@ -397,6 +399,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
397399
},
398400
signInOptions,
399401
getDecodedIdToken: asgardeo.getDecodedIdToken.bind(asgardeo),
402+
syncSession,
400403
}),
401404
[
402405
applicationId,
@@ -414,6 +417,7 @@ const AsgardeoProvider: FC<PropsWithChildren<AsgardeoProviderProps>> = ({
414417
user,
415418
asgardeo,
416419
signInOptions,
420+
syncSession,
417421
],
418422
);
419423

0 commit comments

Comments
 (0)