Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting notified when the OKTA global session is not valid anymore #112

Open
boubou158 opened this issue Nov 29, 2022 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@boubou158
Copy link

boubou158 commented Nov 29, 2022

Describe the feature request?

Hello,

So far, except if I am missing something, the only way to be notified that the OKTA global session is not valid anymore is to use

`this.oktaAuth.start();
const signin = await this.oktaAuth.signInWithCredentials({username: 'myUser', password: 'myPwdUser'});

const tokens = (await this.oktaAuth.token.getWithoutPrompt({sessionToken: signin.sessionToken})).tokens;

// Triggers tokens autorenewal mechanism
this.oktaAuth.tokenManager.setTokens(tokens);

this.oktaAuthStateService.authState$.subscribe((authState) => {
console.log(authState);
if (authState.isAuthenticated) {
// handle connection logic in the app
} else {
// isAuthenticated will be false if the global session is not valid anymore the moment the autorenewal mechanism triggers
// handle disconnection logic in the app
}
})`

With this approach, the issue is that it could happen that the okta global session is not valid anymore, BUT we still have to wait for the autorenewal mechanism to be automatically triggered, to be notified that the user is not connected anymore and should be disconnected. It means it could occur that user is not supposed to be connected anymore, but he is still connected on the app until the autorenewal triggers.

Is there any other way to handle the okta global session expiry?

Thanks and best regards

New or Affected Resource(s)

NA

Provide a documentation link

No response

Additional Information?

No response

@boubou158 boubou158 added the enhancement New feature or request label Nov 29, 2022
@oleksandrpravosudko-okta
Copy link
Contributor

Please note that by default authState.isAuthenticated value doesn't include a state of Okta session. You can modify it using transformAuthState callback to check if session is still valid. You could set your token(s) lifetime equal to session duration in Okta Admin panel to get notification when session expires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants