依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
配置
websecurity
@Configuration
@EnableWebSecurity
@EnableOAuth2Sso
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/favicon.ico");
}
}
application.yml
security:
oauth2:
client:
client-id: client1
client-secret: 1234
access-token-uri: http://authServer/oauth/token
user-authorization-uri: http://authServer/oauth/authorize
scope: all
resource:
token-info-uri: http://authServer/oauth/check_token
server:
servlet:
session:
cookie:
name: ${spring.application.name}_SESSIONID