spring-authorization-server icon indicating copy to clipboard operation
spring-authorization-server copied to clipboard

Support JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens

Open andifalk opened this issue 3 years ago • 5 comments

Expected Behavior There is a new IETF specification for JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens which has already been approved by the IESG and will be published as final RFC very soon. This specification aims to provide a standardized and interoperable profile as an alternative to the proprietary JWT access token layouts going forward. This adds the following details for compliant JWT access tokens:

  • JWT access tokens MUST include "at+jwt" in the "typ" header parameter to explicitly declare that the JWT represents an access token
  • JWT access tokens require at least the following claims: iss, exp, aud, sub, client_id, iat, jti
  • Claims for Authorization are standardized using "roles", "groups", "entitlements" as defined in RFC7643

At least, it should be configurable to issue JWT access tokens supporting this new standardization effort.

Current Behavior Currently, JWT access tokens issued are not following/supporting this new specification

Context Note: I also added an issue to the spring security project (https://github.com/spring-projects/spring-security/issues/10272) for documenting the required configuration to validate such tokens as part of the reference docs.

andifalk avatar Sep 15 '21 14:09 andifalk

good , I'm really looking forward to it.

gsdukbh avatar Sep 16 '21 15:09 gsdukbh

good , I'm really looking forward to it.

Recently, I have been thinking about how to use what I have to achieve the effect of JWT, but I am not very satisfied.

gsdukbh avatar Sep 16 '21 15:09 gsdukbh

Thanks @andifalk ! We'll look at implementing this in one of the upcoming releases.

jgrandja avatar Sep 22 '21 19:09 jgrandja

Most of the required claims are there, except for client_id and jti.

public class Customizer implements OAuth2TokenCustomizer<JwtEncodingContext> {
    @Override
    public void customize(JwtEncodingContext context) {
        context.getClaims()
                .id(UuidUtils.randomUuid())
                .claim("client_id",
                        context.getRegisteredClient()
                                .getClientId());
    }
}

nickcaballero avatar Sep 28 '21 12:09 nickcaballero

good , I'm really looking forward to it too.

lcxw avatar Dec 03 '21 06:12 lcxw