Skip to content

Spring-security-oauth2-authorization-server0.4.0 and springboot2.6.14 compatibility issues #1040

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

Closed
Lvbuqing opened this issue Jan 11, 2023 · 1 comment
Assignees
Labels
status: invalid An issue that we don't feel is valid

Comments

@Lvbuqing
Copy link

Lvbuqing commented Jan 11, 2023

I use springboot2.6.14 to dock spring-security-oauth2-authorization-server0.4.0.

I use this interface to apply for a token: http://oauth2-server.com:9000/oauth2/token?grant_type=client_credentials

Use the pre-set interface of the request: http://oauth2-resource.com:8001/res2

The result is that the request fails and will be executed to AccessDeniedHandler,access denied.

But I use spring-security-oauth2-authorization-server0.2.3, then the request is OK.

I checked because 0.2.3 uses spring-security-oauth2-resource-server5.8.0, and springboot2.6.14 uses spring-security-oauth2-resource-server5.6.9

My authorization-server configuration is:

private RegisteredClient createRegisteredClient(final String clientId) {
TokenSettings tokenSettings = TokenSettings.builder()
.accessTokenTimeToLive(Duration.ofDays(365))
//.reuseRefreshTokens(false)
.build();
ClientSettings clientSettings = ClientSettings.builder()
.requireAuthorizationConsent(false)
.build();
return RegisteredClient
.withId(UUID.randomUUID().toString())
.clientId("micro_service")
.clientSecret(PasswordEncoderFactories.createDelegatingPasswordEncoder().encode("123456"))
.clientName("micro_service")
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
.redirectUri("http://127.0.0.1:8001")
.redirectUri("http://127.0.0.1:8002")
.scope("all")
.tokenSettings(tokenSettings)
.clientSettings(clientSettings)
.build();
}

My resource-server configuration is:

@bean
SecurityFilterChain jwtSecurityFilterChain(HttpSecurity http) throws Exception {
SimpleAccessDeniedHandler accessDeniedHandler = new SimpleAccessDeniedHandler();
SimpleAuthenticationEntryPoint authenticationEntryPoint = new SimpleAuthenticationEntryPoint();

    return http
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and()
            .authorizeRequests()
            .antMatchers("/res1").hasAnyAuthority("SCOPE_read","SCOPE_all")
            .antMatchers("/res2").hasAnyAuthority("SCOPE_write","SCOPE_all")
            .anyRequest().authenticated()
         .and()
            .exceptionHandling(exceptionConfigurer -> exceptionConfigurer
                    .accessDeniedHandler(accessDeniedHandler)
                    .authenticationEntryPoint(authenticationEntryPoint)
            )
            .oauth2ResourceServer(resourceServer -> resourceServer
                    .accessDeniedHandler(accessDeniedHandler)
                    .authenticationEntryPoint(authenticationEntryPoint)
                    .jwt()
            )
            .build();
}

image

Why does the GA version of springboot2.6.14 not provide the corresponding authorization-server GA version.

I hope that each GA version of springboot has a corresponding GA version of authorization-server,
Now authorization-server is an independent application, separated from springcloud,
I believe that now everyone basically uses springboot for web development, and the development version of authorization-server should correspond to springboot

I can't adapt the 0.4.0-GA version of authorization-server through the GA version of springboot2.6.14

I also want to ask, which springboot version does the 0.4.0 version of authorization-server correspond to?
Which springboot version does the 1.0.0 version of authorization-server correspond to?

@Lvbuqing Lvbuqing added the type: bug A general bug label Jan 11, 2023
@jgrandja
Copy link
Collaborator

@Lvbuqing The 0.4.0 release is compatible with Spring Boot 2.7.5, as indicated by the default-authorizationserver sample. Please use Spring Boot 2.7.5+.

NOTE: The 1.0.0 release is compatible with Spring Boot 3.0.0+.

Why does the GA version of springboot2.6.14 not provide the corresponding authorization-server GA version.

There currently is no Spring Authorization Server integration with Spring Boot. However, this is in the works via gh-673. We're targeting Spring Boot 3.1 to include auto-config and custom properties for Spring Authorization Server.

@jgrandja jgrandja self-assigned this Jan 16, 2023
@jgrandja jgrandja added status: invalid An issue that we don't feel is valid and removed type: bug A general bug labels Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants