czh-20260612-新增单点登录功能
This commit is contained in:
@@ -89,6 +89,8 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/smsCheckCaptcha", "anon"); //短信次数发送太多验证码排除
|
||||
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/autoLogin", "anon"); //网关自动登录
|
||||
filterChainDefinitionMap.put("/sys/ipAutoLogin", "anon"); //IP自动登录
|
||||
filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
|
||||
filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
|
||||
|
||||
+40
@@ -136,6 +136,46 @@ public class LoginController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 网关自动登录 — 按 username 匹配用户,跳过密码验证
|
||||
*/
|
||||
@Operation(summary = "网关自动登录")
|
||||
@RequestMapping(value = "/autoLogin", method = RequestMethod.POST)
|
||||
public Result<JSONObject> autoLogin(String username, String password,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
Result<JSONObject> result = new Result<>();
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysUser::getUsername, username);
|
||||
SysUser sysUser = sysUserService.getOne(queryWrapper);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if (!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
// 密码验证跳过 — 网关已认证
|
||||
userInfo(sysUser, result, request);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP自动登录 — 仅按 username 匹配用户,跳过密码验证
|
||||
*/
|
||||
@Operation(summary = "IP自动登录")
|
||||
@RequestMapping(value = "/ipAutoLogin", method = RequestMethod.POST)
|
||||
public Result<JSONObject> ipAutoLogin(String username, String password,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
Result<JSONObject> result = new Result<>();
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysUser::getUsername, username);
|
||||
SysUser sysUser = sysUserService.getOne(queryWrapper);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if (!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
// 密码验证跳过 — 网关已认证
|
||||
userInfo(sysUser, result, request);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 【vue3专用】获取用户信息
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user