Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 775 Bytes

File metadata and controls

30 lines (24 loc) · 775 Bytes

optionfactory-spring/authentication-resource-server

BearerTokenResolvers with JWT Header introspection.

Maven

<dependency>
    <groupId>net.optionfactory.spring</groupId>
    <artifactId>authentication-resource-server</artifactId>
</dependency>

Usage

Use JwtTokenResolverAdapter to resolve bearer tokens based on JWT header values (e.g., checking the Key ID kid):

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    http.oauth2ResourceServer(oauth2 -> oauth2
        .bearerTokenResolver(new JwtTokenResolverAdapter(header -> 
            "expected-kid".equals(header.toJSONObject().get("kid"))
        ))
        .jwt(Customizer.withDefaults())
    );
    // ...
    return http.build();
}