nuxt-oidc-auth: Unable to retrieve ID token for Keycloak id_token_hint logout
Hi, I’m encountering difficulties obtaining a valid ID token that I would like to use for Keycloak logout. The ID token is not included in the user object, and attempting to set exposeIdToken: true in the provider configuration results in an infinite loop after login.
Current configuration:
oidc: {
defaultProvider: 'keycloak',
providers: {
keycloak: {
audience: 'account',
baseUrl: 'http://localhost:8080/realms/dzg',
redirectUri: 'http://localhost:3000/auth/keycloak/callback',
clientId: 'xx',
clientSecret: 'xx',
authorizationUrl: 'http://localhost:8080/realms/dzg/protocol/openid-connect/auth',
tokenUrl: 'http://localhost:8080/realms/dzg/protocol/openid-connect/token',
logoutUrl: 'http://localhost:8080/realms/dzg/protocol/openid-connect/logout',
logoutRedirectParameterName: 'post_logout_redirect_uri',
scope: ['openid', 'profile', 'email'],
responseType: 'code',
exposeAccessToken: true,
grantType: 'authorization_code'
}
},
middleware: {
globalMiddlewareEnabled: true,
customLoginPage: false
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (7 by maintainers)
@VictorioBerra I doubt you are using the latest version. Also, the sessionHooks should be in
server/api/auth/session.ts@VictorioBerra It does work, here is what I have on my side:
This is a general problem of cookies/h3 and would impact nuxt-auth-utils in the same way if they would expose id or access token via the session. A general problem with Keycloak is that is promotes a lot of bad practices towards JWT usage such as storing non-essential user data in tokens instead of using the tokens for auth only and then requesting additonal user information from a db/service/userendpoint etc…
Try to not use
exposeAccessTokenorexposeIdTokenat all and try to reduce the load of these on Keycloak side. If you absolutely need one of them try to only expose that one.@Mattymoo007 I switched to nuxt-auth-utils and there it worked fine for me. I think you’re getting this issue, because the library can’t store id_token plus the other tokens you’re using in the cookies. You need to somehow only save the id_token without refresh and access token, I reckon.