Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

Generating ID token when sid null during refresh_token grant throws IllegalArgumentException #1283

Closed

Description

@cbilodeauupgrade

Describe the bug
Generating a refresh_token with null sid from the OidcIdToken claims throw IllegalArgumentException

To Reproduce
Don't set the SessionRegistry on the OAuth2AuthorizationCodeAuthenticationProvider or use a SessionRegistry that don't return SessionInformation

Expected behavior
Generating a refresh_token with null sid from the OidcIdToken claims should not throw an exception.

Context
According to the specification (https://openid.net/specs/openid-connect-backchannel-1_0.html#LogoutToken):

sid
OPTIONAL. Session ID - String identifier for a Session. This represents a Session of a User Agent or device for a logged-in End-User at an RP. Different sid values are used to identify distinct sessions at an OP. The sid value need only be unique in the context of a particular issuer. Its contents are opaque to the RP. Its syntax is the same as an OAuth 2.0 Client Identifier.

At the moment, the sid can be null in the OidcIdToken if the SessionInformation was not found but it's throw a IllegalArgumentException when generating a refresh_token.

https://github.com/spring-projects/spring-authorization-server/blob/a74f90d2dfa708bbae5c3890a9a7323902493d64/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/token/JwtGenerator.java#L137
should be

if (currentIdToken.getClaim("sid") != null) {
  claimsBuilder.claim("sid", currentIdToken.getClaim("sid"));
}

Activity

  1. jgrandja commented on Jun 23, 2023

    @jgrandja
    Contributor

    @cbilodeauupgrade Thanks for reporting this. Would you be interested in submitting a PR with the fix?

  2. self-assigned this
    on Jun 23, 2023
  3. added this to the 1.1.2 milestone on Jun 23, 2023
  4. changed the title [-]Generating a refresh_token with null 'sid' from the OidcIdToken claims throw IllegalArgumentException[/-] [+]Generating ID token when sid null during refresh_token grant throws IllegalArgumentException[/+] on Jun 30, 2023
  5. added a commit that references this issue on Jun 30, 2023
    b6f3b5c
  6. added a commit that references this issue on Oct 2, 2023
    219ef93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions