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

Do you have oauth2 migration demo? #253

Open
damon008 opened this issue Nov 18, 2021 · 0 comments
Open

Do you have oauth2 migration demo? #253

damon008 opened this issue Nov 18, 2021 · 0 comments

Comments

@damon008
Copy link

damon008 commented Nov 18, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants