Questions tagged «multi-factor-authentication»

1
使用Spring Boot 2和Spring Security 5进行多重身份验证
我想在Angular&Spring应用程序中添加具有TOTP软令牌的多因素身份验证,同时使所有内容尽可能接近Spring Boot Security Starter的默认值。 令牌验证在本地进行(使用aerogear-otp-java库),没有第三方API提供程序。 为用户设置令牌是可行的,但无法通过利用Spring Security Authentication Manager / Providers来验证令牌。 TL; DR 将额外的AuthenticationProvider集成到Spring Boot Security Starter配置的系统中的正式方法是什么? 建议采用什么方法来防止重放攻击? 长版 该API具有一个端点/auth/token,前端可以通过提供用户名和密码从该端点获取JWT令牌。该响应还包括一个身份验证状态,可以为AUTHENTICATED或PRE_AUTHENTICATED_MFA_REQUIRED。 如果用户需要MFA,则使用授予的单个授权PRE_AUTHENTICATED_MFA_REQUIRED和5分钟的到期时间来颁发令牌。这使用户可以访问端点/auth/mfa-token,在端点上可以从其Authenticator应用程序提供TOTP代码,并获取经过完全身份验证的令牌来访问站点。 提供者和令牌 我创建了MfaAuthenticationProvider实现AuthenticationProvider以下内容的自定义: @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { // validate the OTP code } @Override public boolean supports(Class<?> authentication) { return OneTimePasswordAuthenticationToken.class.isAssignableFrom(authentication); } 还有一个OneTimePasswordAuthenticationToken扩展AbstractAuthenticationToken名,用于保存用户名(取自签名的JWT)和OTP代码。 设定档 我有我的自定义WebSecurityConfigurerAdapter,我AuthenticationProvider通过添加我的自定义http.authenticationProvider()。根据JavaDoc,这似乎是正确的位置: 允许添加一个额外的AuthenticationProvider来使用 …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.