Replace Spring Security Login with OTP Verification

社会主义新天地 提交于 2020-05-16 01:36:10

问题


I have a following tables

User table

    -username
    -password
    -mobile

OTP
    -mobile
    -otpCode
    -expiry

WebSecurityConfig

http.authorizeRequests().anyRequest().hasAnyRole("ADMIN", "USER")
    .and()
    .authorizeRequests().antMatchers("/login**").permitAll()
    .and()
    .formLogin().loginPage("/login").loginProcessingUrl("/loginAction").permitAll()
    .and()
    .logout().logoutSuccessUrl("/login").permitAll()
    .and()
    .csrf().disable();

When I attempt login. Spring Security checks User table for username and password. My Use-case is login screen is customised to send otp and Authentication should happen in this flow

  1. Check Username from User table
  2. Check otpCode for corresponding user's mobile in OTP table
  3. If matches flow should complete successful authentication.

来源:https://stackoverflow.com/questions/61804081/replace-spring-security-login-with-otp-verification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!