We need your advice for implementing OKTA /logut functionality for our use case. I have gone through posted messages on Okta dev Forum and found below thread the most useful but we need more than what is suggested as solution there.
‘[OIDC] Logout without having the original Id Token?’
A little bit of a background for our application:
We have used OKTA to implement authentication via OIDC for our AWS Serverless application (written in goLang) which is behind AWS Application Load Balancer. UI is a separate application (Angular) and hosted in the publicly available AWS CloudFront.
to manage user state, we maintain two cookies, frontend & backend!
When user hits the UI application URL, it checks for frontEnd session cookie and if not found, it redirects the request to the backend (hosted behind AWS ALB) for OIDC authentication.
On successful Authentication from OKTA, ALB does token exchange and sets frontend session cookie on the UI domain and keeps AWSELBSessionCookie for active session management at the backend. Everything seems work fine except logout functionality!
We do not have any separate application login page and consider organisation’s okta login page as a common login page. There are many other applications in our organization those also use OKTA Authentication flow. On logout event from our application, we want the user to be logged out only from our application and all other applications’ okta sessions should remain active.
The problem:
AWS ALB does not pass ID token to the backend applicaiton (it only passes x-amzn-oidc-accesstoken & x-amzn-oidc-data). As we do not have ID Token, we are not able to redirect user to https://<okta org url>/oauth2/default/v1/logout? id_token_hint =<id token> which should have resolved our problem, I think!
It seems '@okta/okta-auth-js’ library provides logout functionality, but currently our UI is not aware of OKTA and we do not want to use it on publically available AWS CloudFront.
We have also tried https://<okta org url>/login/signout, but unfortunately it signs out of all okta applications which is not desirable in our case.
It seems closest way to get the ID Token is to use the /token post request, but I am not sure if that will work as ALB may filter ID Token again!
Unfortunately https://< org >.okta.com/login/signout?fromURI=http://< trusted hostname of your app > does not completely work for our use case!
It signs out from all okta active application sessions. i.e. suppose user is using our application and he has also logged-in into company ESS application (which also uses okta) in other browser tab. Now if the user logs out of our application using /login/signout?fromURI=… flow of our application and refreshes the company ESS site in the other tab, then ESS site also redirectes the user to okta login page which should not be the case.
The other drawback of /login/signout?fromURI=… approach is, it does not have any impact of fromURI=< our authenticated app ur >. As after login, it goes to < org okta home page > and not < our application home page >.!
As a workaround we are thinking to develop our custom login page which would be managed by frontend-session-cookie value. In short, we’ll show/redirect user to the login page (once the logout event is triggered) based on the frontend-session-cookie value. We’ll not kill Okta application session.!
User still will feel a new login attempt. If user clears the browser cache, our actual flow will bring user okta login page!
Hi - Can you please help how to get the user claims from x-amzn-oidc-accesstoken, our app is .net core and behind AWS ALB OKAT OIDC we were able to authenticate but somehow we are not able to get the token from x-amzn-oidc-accesstoken, any help would be helpful.
Thanks
Ibrahim
Hi I would also have the same problem. I am following the approach of redirecting to “{{your_okta_org}}/login/signout?fromURI={{one of the trusted origins}}” after expiring the EKS Ingress ALB session cookie. Currently I have created an application in my Okta developer account and it is having only one application in it. But when we move this to our organization okta account, the user would logout from all the logged in applications once he logs out from my application. Is the there any way to get the id token, may be by calling Okta API so that we can call https:///oauth2/default/v1/logout?id_token_hint=${id_token} to logoff specifically from my application.