提交 c76a5e57 作者: duanxincheng

cmeeting单点登录

父级 333fc161
......@@ -35,4 +35,9 @@ public class UserController {
public R auth(@Validated @RequestBody UserVo.Auth vo) {
return R.ok(userService.auth(vo));
}
@PostMapping(value = "/tokenAuth")
public R tokenAuth(@Validated @RequestBody ApplicationUserVO.LoginDecrypt vo) {
return R.ok(userService.tokenAuth(vo));
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ package com.cmeeting.ad.service;
import com.cmeeting.ad.entity.RoleTree;
import com.cmeeting.ad.entity.SysMenu;
import com.cmeeting.ad.vo.ApplicationUserVO;
import com.cmeeting.ad.vo.UserVo;
import com.cmeeting.util.R;
......@@ -24,4 +25,6 @@ public interface UserService {
RoleTree getLoginMenus(List<SysMenu> sysMenuList);
Object list(String search, Integer type, Integer userType, String categoryId, Integer authType);
Object tokenAuth(ApplicationUserVO.LoginDecrypt vo);
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.cmeeting.ad.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -225,6 +226,21 @@ public class UserServiceImpl implements UserService {
return object;
}
@Override
public Object tokenAuth(ApplicationUserVO.LoginDecrypt vo) {
String aigcToken = vo.getData();
String url = userAdminConfig.getSystemDomain() + "/cloud/info";
JSONObject object = HttpClientUtils.httpGet(url, aigcToken);
if("0".equals(object.get("code"))){
return null;
}
JSONObject data = object.getJSONObject("data");
RobotSecurityUser robotSecurityUser = JSON.parseObject(data.toJSONString(), RobotSecurityUser.class);
UserVo.Auth authParams = UserVo.Auth.builder().id(robotSecurityUser.getUsername()).nick(robotSecurityUser.getNickName()).build();
String token = auth(authParams);
return token;
}
private R loginByAD(ApplicationUserVO.Login login) {
// AD验证
// boolean auth = iLdapService.authenticate(login.getUsername().trim(), login.getPassword().trim());
......
package com.cmeeting.ad.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 登录
......@@ -32,6 +35,9 @@ public class UserVo {
}
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class Auth {
/**
* 用户id (系统和应用用户的主键id,同步用户的userId)
......
......@@ -10,4 +10,6 @@ public class UserAdminConfig {
@Value("${userAdmin.domain}")
private String userAdminDomain;
@Value("${userAdmin.systemDomain}")
private String systemDomain;
}
......@@ -127,7 +127,8 @@ ldap:
domain: '@cimc.com'
userAdmin:
domain: http://192.168.10.154:8303
domain: http://192.168.10.154:9103
systemDomain: http://192.168.10.154:9101
appId: af94e0ec9cc0bef2bfa63f470f6f4351
secret: 4luHTMYMyXzOmDHN0ZOSMwOst702plcr9EKqAHtT8Nag6EPlP0VSFvqv9Zq0NRDE
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论