Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Had a Error when update springboot and Springcloud from Hoxton to 2020.0.4 #254

@damon008

Description

@damon008

Describe the bug

In my client of Resource Server

Base on

Springboot version:2.5.6
Springcloud version: 2020.0.4
Spring cloud Security version(spring-cloud-starter-oauth2): 2.2.5.RELEASE
<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/>
    </parent>
<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>2020.0.4</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

<dependencies>
          <dependency>
	          <groupId>org.springframework.cloud</groupId>
	          <artifactId>spring-cloud-starter-oauth2</artifactId>
	          <version>2.2.5.RELEASE</version>
          </dependency>
</dependencies>

How can use Oauth2 for Resource Server? for some examples?

The following code is mine

SecurityConfig.java

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
	
	@Override
    public void configure(WebSecurity web) throws Exception {
		web.ignoring().antMatchers(
        		"/v2/api-docs", "/swagger-resources/configuration/ui",
                "/swagger-resources","/swagger-resources/configuration/security",
                "/swagger-ui.html","/css/**", "/js/**","/images/**", "/webjars/**", "**/favicon.ico", "/index",
        		"/public/", "/static/", "/css/**", "/js/**", "/plugins/**", "/favicon.ico", "/images/**");
    }
}

but it throw a exception:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfig': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.commons.security.ResourceServerTokenRelayAutoConfiguration$ResourceServerTokenRelayRegistrationAutoConfiguration': Unsatisfied dependency expressed through field 'accessTokenContextRelay'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.commons.security.AccessTokenContextRelay' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


Description:

Field accessTokenContextRelay in org.springframework.cloud.commons.security.ResourceServerTokenRelayAutoConfiguration$ResourceServerTokenRelayRegistrationAutoConfiguration required a bean of type 'org.springframework.cloud.commons.security.AccessTokenContextRelay' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.cloud.commons.security.AccessTokenContextRelay' in your configuration.

But, I can use SSO by Oauth2 for Resource Server (Client Demo) from the version:

Springboot version: 2.3.12
Springcloud version:  Hoxton.SR12
spring-cloud-starter-oauth2:  2.2.5.RELEASE

I Just update the version of springboot and Springcloud.

Springboot version:2.5.6
Springcloud version: 2020.0.4
Spring cloud Security version(spring-cloud-starter-oauth2): 2.2.5.RELEASE

===============================================

So Excuse me, is there an example of integrating SSO with spring cloud security? Didn't understand the migration guide. Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions