添加登入添加Google Authenticator TOTP六位动态码 授权登。2. 保留Google登录并支持动态码登录

This commit is contained in:
lu7213 committed 2026-10-21 04:03:06 -04:00
1 parent 42a06f7e4d
commit cc5fe279e9
13 files changed
+714 -2

No files matched your search

@@ -0,0 +1,25 @@
package com.ruoyi.system.mapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/** TOTP 凭据专用映射,密钥不进入用户实体、JWT 或常规用户响应。 */
public interface SysUserTotpMapper {
@Select("SELECT secret_cipher FROM sys_user_totp WHERE user_id = #{userId}")
String selectSecret(@Param("userId") Long userId);
@Insert("INSERT INTO sys_user_totp(user_id, secret_cipher, last_used_step) "
+ "VALUES(#{userId}, #{cipher}, #{step})")
int insert(@Param("userId") Long userId, @Param("cipher") String cipher, @Param("step") long step);
/** CAS 同时校验密钥版本与时间步,多个实例并发验证也只允许一次成功。 */
@Update("UPDATE sys_user_totp SET last_used_step = #{step}, updated_at = CURRENT_TIMESTAMP "
+ "WHERE user_id = #{userId} AND secret_cipher = #{cipher} AND last_used_step < #{step}")
int consume(@Param("userId") Long userId, @Param("cipher") String cipher, @Param("step") long step);
@Delete("DELETE FROM sys_user_totp WHERE user_id = #{userId} AND secret_cipher = #{cipher}")
int delete(@Param("userId") Long userId, @Param("cipher") String cipher);
}