Skip to content

AOT Spring authorization server authentication #2291

@trcoelho

Description

@trcoelho

Describe the bug
By compiling natively spring-boot-starter-security-oauth2-authorization-server and then authenticate in oauth2/token, application throws:

Caused by: tools.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'java.util.Collections$UnmodifiableMap' as a subtype of `java.util.Map<java.lang.String,java.lang.Object>`: Configured `PolymorphicTypeValidator` (of type `tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator`) denied resolution at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); byte offset: #UNKNOWN]
I could see that it is related to "client_settings" and "token_settings" oauth2_registered_client's columns where JsonMapper.readValue are not able to read ´java.util.Collections$UnmodifiableMap´.

Tried to register type ´java.utils.Collections.class´ hint but no success.

It only occurs when compile natively.

To Reproduce
Spring Boot Version: 4.0.3
Spring Cloud Version: 2025.1.0

Dependency:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security-oauth2-authorization-server</artifactId> </dependency>

Create a oauth2_registered_client with client_settings and token_settings.
Compile natively with GraalVM.
Try to authenticate.

Expected behavior
Token must be successfully retrieved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions