I have an SPA OIDC app configured in our custom tenant for auth code pkce flow. I get a session token from Okta’s authn url /api/v1/authn. I then use this session token to kick off the OIDC flow.
I have the below code base to logout the user. The access and refresh tokens are revoked but not the Okta sid cookie. When the session token of a different identity gets passed in getWithoutPrompt, I am getting OIDC tokens associated to the prior user logged in. It seems like getWithoutPrompt is taking Okta sid cookie as a precedence then the session token.
So I have the below code base for signout(). It does delete the Okta sid cookie but not the Okta access token. When I call the introspect url oauth2/{{customAuthzServer}}/v1/introspect my access token is still active.
Also, if revoke and then logout is called, it deletes the sid and revokes the access and refresh token. In the logout url, it has the id_token as per below. Is the id_token picked from local token manager, or Okta knows about the id_token based on Okta sid cookie ?
So can I call /logout directly from my javascript app and use it to revoke OIDC tokens or call /revoke endpoint directly from javascript with access token of the identity? Or is there any other way to revoke the tokens from my javascript ? Also, I tried oktaAuth.revokeRefreshToken and oktaAuth.revokeAccessToken it didnt work for me. In our SPA, when a user clicks logout, it goes to downstream service to delete additional company wide token and it redirects back to our UI logout page. I think when it redirects, the token manager is lost and hence oktaAuth.revokeRefreshToken and oktaAuth.revokeAccessToken dont work.
So in my case once the OIDC flow is successful in our login SPA it redirects to another UI (lets say SPA Z)within our company. If the user wants to logout, it (SPA Z) calls our backend service to revoke the company wide SSO token and then the backend service redirects to login SPA /logout page. I think because it redirects back to login SPA app, we dont have TokenManager where the OIDC tokens are accessible.
So one solution I tried is, once the OIDC flow is successful, my login SPA app stores the access and refresh token object in local storage and when the login SPA is accessed for logout operation from another UI, it accesses the access and refresh token object from local storage and passes it in oktaAuth.signOut() method. Also, calling the signOut() deletes the Okta session (ie sid cookie).
oktaAuth.signOut({
accessToken: JSON.parse(localStorage.getItem('accessToken')),
refreshToken: JSON.parse(localStorage.getItem('refreshToken')),
postLogoutRedirectUri: myDomain + '/loginUi/logout/',
});
OR another way to revoke access and refresh tokens
oktaAuth.revokeRefreshToken(refreshToken)
oktaAuth.revokeRefreshToken(accessToken)