Skip to content

Commit

Permalink
Fix log out error "Missing parameters: id_token_hint"
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Feb 28, 2024
1 parent 62264b1 commit 9448e9f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.0.0-beta.22 - 2024-02-28

### Bugs fixed:
- Fix log out error "Missing parameters: id_token_hint".

## v2.0.0-beta.21 - 2023-09-29

### Features:
Expand Down
2 changes: 1 addition & 1 deletion src/Nexus/API/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ internal class UsersController : ControllerBase

// [authenticated]
// GET /api/users/me
// GET /api/users/accept-license?catalogId=X
// POST /api/users/tokens/generate
// POST /api/users/accept-license?catalogId=X
// DELETE /api/users/tokens/{tokenId}

// [privileged]
Expand Down
17 changes: 17 additions & 0 deletions src/Nexus/Core/NexusAuthExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,24 @@ public static IServiceCollection AddNexusAuth(
options.ClientSecret = provider.ClientSecret;

options.CallbackPath = $"/signin-oidc/{provider.Scheme}";

/* OIDC spec RECOMMENDS id_token_hint (= id_token) to be added when
* post_logout_redirect_url is specified
* (https://openid.net/specs/openid-connect-rpinitiated-1_0.html)
*
* To be able to provide that parameter the (large) ID token must
* become part of the auth cookie. The /connect/logout endpoint in
* NexusIdentityProviderExtensions.cs is then getting that logout_hint
* query parameter automatically (this has been tested!).
* This parameter then is part of the httpContext.Request.Query dict.
*
* Why do we enable this when this is just recommended? Because newer
* version of Keycloak REQUIRE it, otherwise we get a
* "Missing parameters: id_token_hint" error.
*/
options.SaveTokens = true;
options.SignedOutCallbackPath = $"/signout-oidc/{provider.Scheme}";

options.ResponseType = OpenIdConnectResponseType.Code;

options.TokenValidationParameters.AuthenticationType = provider.Scheme;
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.0",
"suffix": "beta.21"
"suffix": "beta.22"
}

0 comments on commit 9448e9f

Please sign in to comment.