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

jwt-bearer grant fails due to missing client ID #752

Closed
mwm-twx opened this issue Oct 9, 2024 · 1 comment
Closed

jwt-bearer grant fails due to missing client ID #752

mwm-twx opened this issue Oct 9, 2024 · 1 comment

Comments

@mwm-twx
Copy link

mwm-twx commented Oct 9, 2024

A POST request to the token endpoint with grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer and assertion=<Signed JWT> fails with no.nav.security.mock.oauth2.OAuth2Exception: client_id cannot be null:

no.nav.security.mock.oauth2.OAuth2Exception: client_id cannot be null
    at no.nav.security.mock.oauth2.extensions.NimbusExtensionsKt.clientIdAsString(NimbusExtensions.kt:80)
    at no.nav.security.mock.oauth2.token.RequestMappingTokenCallback.getClaims(OAuth2TokenCallback.kt:95)
    at no.nav.security.mock.oauth2.token.RequestMappingTokenCallback.audience(OAuth2TokenCallback.kt:121)
    at no.nav.security.mock.oauth2.token.OAuth2TokenProvider.exchangeAccessToken(OAuth2TokenProvider.kt:85)
    at no.nav.security.mock.oauth2.grant.JwtBearerGrantHandler.tokenResponse(JwtBearerGrantHandler.kt:27)
    at no.nav.security.mock.oauth2.http.OAuth2HttpRequestHandler.token$lambda$14$lambda$13(OAuth2HttpRequestHandler.kt:176)
    at no.nav.security.mock.oauth2.http.OAuth2HttpRouterKt$routeFromPathAndMethod$1.invoke(OAuth2HttpRouter.kt:209)
    at no.nav.security.mock.oauth2.http.OAuth2HttpRouterKt$routeFromPathAndMethod$1.invoke(OAuth2HttpRouter.kt:198)

The NimbusExtensionsKt code makes an assumption that TokenRequest will have a client ID or a ClientAuthentication instance, but a JWTBearerGrant is an AuthorizationGrant subclass and TokenRequest(URI, AuthorizationGrant) will have no ClientAuthentication.

According to the RFC, there is no client ID expected in a jwt-bearer request (https://datatracker.ietf.org/doc/html/rfc7523#section-4).

@tommytroen
Copy link
Collaborator

@mwm-twx fixed in 2.1.10

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

No branches or pull requests

2 participants