我想要一套可以与“客户端凭据”(用于计算机到计算机)以及OAuth2单点登录用于常规Web应用程序(由同一应用程序提供)一起使用的服务。
我尝试同时设置@ EnableOAuth2Sso和@EnableResourceServer;我希望应用程序可以“尝试”基于令牌,然后回退到SSO重定向,以防找不到任何令牌并且用户没有会话。
每个配置都可以正常运行(使用a:
@Bean
public RemoteTokenServices ...
供@EnableResourceServer配置“ CheckTokenEndpointUrl”。
但是一旦我尝试两者,我都会得到:
申请无法开始
说明:
org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration中的springSecurityFilterChain方法需要一个bean,但是找到了两个: -userInfoTokenServices:由类路径资源[org / springframework / boot / autoconfigure / security / oauth2 / resource / ResourceServerTokenServicesConfiguration $ RemoteTokenServicesConfiguration $ UserInfoTokenServicesConfiguration.class]中的方法'userInfoTokenServices'定义 -remoteTokenServices:由类路径资源[my / CustomWebSecurityConfigurerAdapter.class]
中的方法'remoteTokenServices'定义答案 0 :(得分:0)
在spring boot应用程序类中,使用@EnableOAuth2Sso
批注,在配置类中,使用@EnableResourceServer
批注,并在此类中定义要与访问令牌一起使用的端点。
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/user") //end point that needs access token in header
.antMatcher("/info") //end point that needs access token in header
.authorizeRequests().anyRequest().authenticated();
}
}
有关更多信息,请参见link