我一直在研究 Spring Boot Oauth2 教程,但我似乎无法让一个非常关键的元素正常工作:
https://spring.io/guides/tutorials/spring-boot-oauth2/
我想作为授权服务器运行。我已经尽可能地按照说明进行操作,但是当我转到 /oauth/authorize 端点时,我得到的只是 403 Forbidden 响应。鉴于教程设置的 HttpSecurity 配置,这对我来说实际上是有意义的:
protected void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/**")
.authorizeRequests()
.antMatchers("/", "/login**", "/webjars/**")
.permitAll()
.anyRequest()
.authenticated()
.and().logout().logoutSuccessUrl("/").permitAll()
.and().csrf().csrfTokenRepository(csrfTokenRepository())
.and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class)
.addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class);
}
本教程的登录页面实际上是主索引,我在教程中绝对看不到任何指示 Oauth 系统将登录流程重定向到那里的内容。
我可以通过添加这个来让它工作:
.and().formLogin().loginPage("/")
...但在继续前进之前,我真的很想了解这是否是教程或我的实现或其他问题的问题。Oauth 安全系统决定什么是“登录”页面的机制是什么?