凭证页面中的授权重定向URI是http://testing.com:8008/success,但是它总是重定向到http://testing.com:8008/login,不知道这里出了什么问题,有人可以帮忙。
配置的application.yml文件如下所示。
security:
oauth2:
client:
clientId: 701691307057-184m2p0ce76k.apps.googleusercontent.com
clientSecret: 7186351
pre-established-redirect-uri: http://testing.com:8008/success
accessTokenUri: https://www.googleapis.com/oauth2/v3/token
userAuthorizationUri: https://accounts.google.com/o/oauth2/auth
tokenName: oauth_token
authenticationScheme: query
clientAuthenticationScheme: form
scope: profile email
resource:
userInfoUri: https://www.googleapis.com/userinfo/v2/me
preferTokenInfo: false
下面的Web安全配置类。
@EnableOAuth2Sso
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/home", "/success")
.permitAll()
.anyRequest()
.authenticated();
}
}
下面的控制器
@Controller
@RequestMapping("/")
public class WelcomeController {
@RequestMapping(value = {"home"}, method = RequestMethod.GET)
public String welcomePage(){
return "welcomePageAfterSignin";
}
@RequestMapping(method = RequestMethod.GET)
public String welcomePage2(){
return "welcomePage";
}
@RequestMapping(value = {"success"}, method = RequestMethod.GET)
public String AfterSignIn(){
return "success";
}
@RequestMapping(value = "user")
public Principal user(Principal principal) {
return principal;
}
}
发布于 2018-12-21 05:03:30
Actually nothing is wrong, you are being redirected to spring security login page.
您缺少的是spring-security的凭据。
仔细查看日志,您将看到类似于Using generated security password: 5608543f-48fd-46ae-94a4-3f7094aa0d53
的密码。
因此,您需要在登录页面中输入这些凭据。默认情况下,用户名是:每次在日志(如):user
中生成密码
只有这样,您才会被重定向到您的google页面或api,您已经公开了。
添加图片供您参考
发布于 2018-12-21 07:02:48
https://stackoverflow.com/questions/53879373
复制相似问题