我正在尝试创建一个使用Spring Security和reactjs作为部署在s3存储桶中的前端的授权代码流,但是我的问题是,当用户出现问题时,我需要从后端到前端执行http sendredirect。
按照我的后端安全配置
application.yml
security:
oauth2:
client:
clientId: MyClientId
clientSecret: secret
accessTokenUri: http://localhost:8088/auth/oauth/token
userAuthorizationUri: http://localhost:8088/auth/oauth/authorize
resource:
userInfoUri: http://localhost:8088/auth/user/me
SecurityAdapter
@EnableOAuth2Sso
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/login**")
.permitAll()
.anyRequest()
.authenticated();
}
@Bean
public RequestContextListener requestContextListener() {
return new RequestContextListener();
}
@Bean
public SimpleUrlAuthenticationSuccessHandler successHandler() {
return new SimpleUrlAuthenticationSuccessHandler("http://localhost:3000/app/");
}
}
POM
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
我尝试使用.authenticated().and().oauth2Login().successHandler(successHandler);
配置适配器
但不起作用。有人可以帮我这个配置吗?