【发布时间】:2019-07-20 06:29:33
【问题描述】:
我有一个 Spring Boot 应用程序,我需要在其中限制对特定端点的访问。到目前为止,我可以使用 SAML 2.0 对 Azure 进行身份验证。
这是Spring中认证的主要配置
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling()
.authenticationEntryPoint(samlEntryPoint());
http
.csrf()
.disable();
http
.addFilterBefore(metadataGeneratorFilter(), ChannelProcessingFilter.class)
.addFilterAfter(samlFilter(), BasicAuthenticationFilter.class);
http
.authorizeRequests()
.antMatchers("/error").permitAll()
.antMatchers("/saml/**").permitAll()
.anyRequest().authenticated();
http
.logout()
.logoutSuccessUrl("/");
}
在 Azure 中,我已将角色添加到声明值中,如下图所示
我的目标是能够立即执行以下操作:
@GetMapping("/")
@PreAuthorize("hasRole('User')")
public String getSample(Principal principal) {
log.info("Get Request");
return "Hello";
}
【问题讨论】:
标签: spring-boot azure-active-directory saml saml-2.0 spring-saml