Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring OAuth2 Client + native does not work out of the box. Should be easy to fix #15764

Open
rcomblen opened this issue Sep 9, 2024 · 2 comments
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement

Comments

@rcomblen
Copy link

rcomblen commented Sep 9, 2024

Expected Behavior

One should be able to use the native build features of Spring Boot out of the box with .spring-boot-starter-oauth2-client.
I'm just doing the most naive login thru Google use case.

Current Behavior

Doesn't work out of the box. One need to resort to using the native-image-agent to collect the necessary introspection data.

Workaround

A RuntimeHintsRegistrar should be easy add.

Adding the following to META-INF/native-image/serialization-config.json fixes the issue:

{
  "types":[
    {
      "name":"java.lang.Boolean"
    },
    {
      "name":"java.lang.String"
    },
    {
      "name":"java.net.URL"
    },
    {
      "name":"java.time.Instant"
    },
    {
      "name":"java.time.Ser"
    },
    {
      "name":"java.util.ArrayList"
    },
    {
      "name":"java.util.Collections$UnmodifiableCollection"
    },
    {
      "name":"java.util.Collections$UnmodifiableList"
    },
    {
      "name":"java.util.Collections$UnmodifiableMap"
    },
    {
      "name":"java.util.Collections$UnmodifiableRandomAccessList"
    },
    {
      "name":"java.util.Collections$UnmodifiableSet"
    },
    {
      "name":"java.util.HashMap"
    },
    {
      "name":"java.util.HashSet"
    },
    {
      "name":"java.util.LinkedHashMap"
    },
    {
      "name":"java.util.LinkedHashSet"
    },
    {
      "name":"org.springframework.security.authentication.AbstractAuthenticationToken"
    },
    {
      "name":"org.springframework.security.core.authority.SimpleGrantedAuthority"
    },
    {
      "name":"org.springframework.security.core.context.SecurityContextImpl"
    },
    {
      "name":"org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken"
    },
    {
      "name":"org.springframework.security.oauth2.core.AbstractOAuth2Token"
    },
    {
      "name":"org.springframework.security.oauth2.core.AuthorizationGrantType"
    },
    {
      "name":"org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest"
    },
    {
      "name":"org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationResponseType"
    },
    {
      "name":"org.springframework.security.oauth2.core.oidc.OidcIdToken"
    },
    {
      "name":"org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser"
    },
    {
      "name":"org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority"
    },
    {
      "name":"org.springframework.security.oauth2.core.user.DefaultOAuth2User"
    },
    {
      "name":"org.springframework.security.oauth2.core.user.OAuth2UserAuthority"
    },
    {
      "name":"org.springframework.security.web.authentication.WebAuthenticationDetails"
    }
  ],
  "lambdaCapturingTypes":[
  ],
  "proxies":[
  ]
}
@rcomblen rcomblen added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Sep 9, 2024
@marcusdacoregio marcusdacoregio self-assigned this Sep 10, 2024
@marcusdacoregio marcusdacoregio removed the status: waiting-for-triage An issue we've not yet triaged label Sep 10, 2024
@marcusdacoregio
Copy link
Contributor

Hi @rcomblen. Thanks for the report.

Can you provide more details about your application? Ideally, a minimal, reproducible sample would be great.
I tried myself using the oauth2-login sample and it worked out of the box. I just had to tweak the Thymeleaf template (not related to Spring Security tho).

@marcusdacoregio marcusdacoregio added the status: waiting-for-feedback We need additional information before we can continue label Sep 10, 2024
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Sep 17, 2024
@marcusdacoregio marcusdacoregio removed their assignment Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants