【发布时间】:2022-01-05 03:19:05
【问题描述】:
我正在尝试使用 Web 服务为我的 Spring Boot 运行 azure Active Directory。问题是当我成功登录时,它找不到应该可以访问的页面。
我添加了以下属性(tetant-id、client-id、client-secret、user-group.allowed-group-names)
azure.activedirectory.redirect-uri-template=login/oauth2/code
我的配置是:
@Order(1)
@Configuration
@EnableWebSecurity
public class AADSecurityConfiguration extends AADWebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/health");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/oauth2/**", "/login/**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.oauth2Login()
.defaultSuccessUrl("/list", true);
}
}
简单的控制器请求是:
@GetMapping("/list")
@PreAuthorize("hasRole('Admin') or hasRole('Users')")
public String getListPage() {
return "list";
}
依赖的版本是:
<spring.security.version>5.6.0</spring.security.version>
<spring.boot.version>2.5.4</spring.boot.version>
<azure.version>3.10.0</azure.version>
正如我在正确登录时提到的,/list 页面无法访问,它在下面显示 404 错误。 白标错误页面
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Nov 27 12:29:06 UTC 2021
There was an unexpected error (type=Not Found, status=404).
导致该问题的原因可能是什么?
【问题讨论】:
标签: spring-boot azure-active-directory spring-security-oauth2