java - 如何使用 Spring 和 SAP Cloud Platform 执行 SAML 身份验证
问题描述
我正在尝试按照此处所述实施程序化身份验证https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/e637f62abb571014857cb0232adc43a7.html#loio778d8987e7714376977c190f6df379ad
但是,我不想手动实现 servlet,我想改用 Spring。
这是我的身份验证提供程序:
import com.sap.security.auth.login.LoginContextFactory;
@Component
public class FormAuthenticationProvider extends AbstractJaasAuthenticationProvider {
private final static String FORM = "FORM";
{
setAuthorityGranters(new AuthorityGranter[] {
new AuthorityGranter() {
@Override
public Set<String> grant(Principal principal) {
// TODO Auto-generated method stub
return null;
}
}
});
}
@Override
protected LoginContext createLoginContext(CallbackHandler handler) throws LoginException {
// TODO Auto-generated method stub
return LoginContextFactory.createLoginContext(FORM);
}
}
和 web 安全配置器适配器:
public static class FormWebSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
private FormAuthenticationProvider formAuthenticationProvider;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(formAuthenticationProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable() //HTTP with Disable CSRF
.antMatcher("/form")
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin();
}
}
通过这个实现,当我想要重定向到 SAP ID 服务时,我会被重定向到 Java 登录表单。
成功重定向到 SAP ID 服务的经典web.xml
方法<auth-method>FORM</auth-method>
,我认为 SpringformLogin()
是等价的。
我究竟做错了什么?
解决方案
推荐阅读
- python - 检测一个单词是否只有一个缺失或不正确的字母?
- php - 变量使用 PHP 中的先前值
- c# - 计算 DataTable 中的同比变化
- javascript - 堆栈中 .pop() 的实现和队列中的出队
- flutter - 在 TextEditingController 的初始化程序中只能访问静态成员
- json - 在 JQ 中按对象键组合列表
- javascript - 如何在 React 中渲染和编辑 SVG 数据?
- javascript - React + Redux :使用redux reducer 时,如果我们想依赖prevstate,是否需要使用prevstate?
- amazon-web-services - Route 53 子域和 API 网关
- python-3.x - Python 请求 - 获取网站 Cookie