摘要:
2.2 用户验证通过之后,生成SessionID,并返回给业务系统。
通过redis缓存和cookie实现单点登录
整体实现思路如下图所示。
1.业务系统发起登录请求,调用SSO用户登录接口;
2.SSO登录接口的处理逻辑:
2.1 根据用户名和密码去数据库验证用户是否合法。2.2 用户验证通过之后,生成SessionID,并返回给业务系统。
同时以SessionID为key,存储用户信息到redis缓存中
public JSONObject userLogin(@RequestBody JSONObject jsonObject){
UserLoginResponse userLoginResponss = new UserLoginResponse();
try {
logger.info("处理用户登录业务逻辑,接收报文"+jsonObject);
String msgWithDigesta=SecurityUtil.scfMatch(jsonObject.toString(), newXService.getPrivateKey());
//生成实体
User user = JSONObject.parseObject(msgWithDigesta,User.class);
//是否验证用户的密码
boolean isChechPassword = true;
User userInfo = anaService.loginCheckUserInfo(user,isChechPassword);
// 存储用户信息到redis缓存中
String ticket = anaService.storeUserLoginSessionInRedis(userInfo,user.getModuleCode());