java Spring安全OAuth2在成功登录后重定向到登录
我已经能够使用Github clientId和ClientSecret成功登录OAuth2,但由于某些原因,它一直将我重定向到http://localhost:8080/login而不是http://localhost:8080/welcome,我确信clientId和ClientSecret是正确的(以前在GitHub页面中注册了应用程序),因为如果我将值更改为不正确的对,它会将我重定向到GitHub 404 Not Found页面
应用程序。yml
spring:
security:
oauth2:
client:
registration:
github:
clientId: theClientId
clientSecret: theClientSecret
redirect-uri: http://localhost:8080/welcome
OAuth2LoginSecurityConfig。爪哇
@EnableWebSecurity
@Configuration
public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.oauth2Login();
}
}
依赖关系
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
我错过了什么?谢谢
共 (0) 个答案