forked from github/dataease
Merge branch 'dev' of github.com:dataease/dataease into dev
This commit is contained in:
commit
a30c66a752
@ -72,8 +72,8 @@ public interface AuthApi {
|
||||
boolean isOpenDingtalk();
|
||||
|
||||
@ApiOperation("是否开启飞书")
|
||||
@PostMapping("/isOpenFark")
|
||||
boolean isOpenFark();
|
||||
@PostMapping("/isOpenLark")
|
||||
boolean isOpenLark();
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/isPluginLoaded")
|
||||
|
@ -305,12 +305,12 @@ public class AuthServer implements AuthApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenFark() {
|
||||
public boolean isOpenLark() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if (!licValid)
|
||||
return false;
|
||||
|
||||
return authUserService.supportFark();
|
||||
return authUserService.supportLark();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ public interface AuthUserService {
|
||||
|
||||
Boolean supportDingtalk();
|
||||
|
||||
Boolean supportFark();
|
||||
Boolean supportLark();
|
||||
|
||||
Boolean pluginLoaded();
|
||||
|
||||
|
@ -16,6 +16,7 @@ import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
import io.dataease.plugins.xpack.cas.service.CasXpackService;
|
||||
import io.dataease.plugins.xpack.dingtalk.service.DingtalkXpackService;
|
||||
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
|
||||
@ -187,8 +188,12 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean supportFark() {
|
||||
return false;
|
||||
public Boolean supportLark() {
|
||||
Map<String, LarkXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((LarkXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) return false;
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
if (ObjectUtils.isEmpty(larkXpackService)) return false;
|
||||
return larkXpackService.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,7 +83,7 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenOidc", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenWecom", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenDingtalk", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenFark", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenLark", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/getPublicKey", ANON);
|
||||
filterChainDefinitionMap.put("/api/pluginCommon/component/*", ANON);
|
||||
filterChainDefinitionMap.put("/api/pluginCommon/staticInfo/**", ANON);
|
||||
@ -94,8 +94,8 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
filterChainDefinitionMap.put("/plugin/wecom/getQrParam", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/dingtalk/callBack*", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/dingtalk/getQrParam", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/fark/callBack*", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/fark/getQrParam", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/lark/callBack*", ANON);
|
||||
filterChainDefinitionMap.put("/plugin/lark/getQrParam", ANON);
|
||||
filterChainDefinitionMap.put("/cas/reset/**", ANON);
|
||||
|
||||
filterChainDefinitionMap.put("/unauth", ANON);
|
||||
|
@ -0,0 +1,134 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkQrResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
|
||||
import io.dataease.plugins.xpack.lark.dto.response.LarkInfo;
|
||||
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping("/plugin/lark")
|
||||
@Controller
|
||||
public class XLarkServer {
|
||||
|
||||
|
||||
@Resource
|
||||
private AuthUserService authUserService;
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping("/info")
|
||||
public LarkInfo getLarkInfo() {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
return larkXpackService.info();
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequiresPermissions("sysparam:read")
|
||||
@PostMapping("/save")
|
||||
public void save(@RequestBody List<SysSettingDto> settings) {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
larkXpackService.save(settings);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/testConn")
|
||||
public void testConn(@RequestBody LarkInfo larkInfo) {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
try {
|
||||
larkXpackService.testConn(larkInfo);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/getQrParam")
|
||||
public LarkQrResult getQrParam() {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
return larkXpackService.getQrParam();
|
||||
}
|
||||
|
||||
@GetMapping("/callBack")
|
||||
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
|
||||
ModelAndView modelAndView = new ModelAndView("redirect:/");
|
||||
HttpServletResponse response = ServletUtils.response();
|
||||
LarkXpackService larkXpackService = null;
|
||||
try {
|
||||
Map<String, LarkXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((LarkXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少飞书插件");
|
||||
}
|
||||
larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
Boolean isOpen = larkXpackService.isOpen();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启飞书");
|
||||
}
|
||||
LarkUserInfo larkUserInfo = larkXpackService.userInfo(code, state);
|
||||
String username = larkUserInfo.getUser_id();
|
||||
String sub = larkUserInfo.getSub();
|
||||
SysUserEntity sysUserEntity = authUserService.getUserBySub(sub, 6);
|
||||
if (null == sysUserEntity) {
|
||||
String email = StringUtils.isNotBlank(larkUserInfo.getEmail()) ? larkUserInfo.getEmail() : "demo@lark.work";
|
||||
sysUserService.validateExistUser(username, larkUserInfo.getName(), email);
|
||||
sysUserService.saveLarkCUser(larkUserInfo, email);
|
||||
sysUserEntity = authUserService.getUserBySub(sub, 6);
|
||||
}
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(sysUserEntity.getUserId()).username(sysUserEntity.getUsername()).build();
|
||||
String realPwd = sysUserEntity.getPassword();
|
||||
String token = JWTUtils.sign(tokenInfo, realPwd);
|
||||
ServletUtils.setToken(token);
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.LOGIN, SysLogConstants.SOURCE_TYPE.USER, sysUserEntity.getUserId(), null, null, null);
|
||||
|
||||
Cookie cookie_token = new Cookie("Authorization", token);
|
||||
cookie_token.setPath("/");
|
||||
|
||||
response.addCookie(cookie_token);
|
||||
} catch (Exception e) {
|
||||
|
||||
String msg = e.getMessage();
|
||||
if (null != e.getCause()) {
|
||||
msg = e.getCause().getMessage();
|
||||
}
|
||||
try {
|
||||
msg = URLEncoder.encode(msg, "UTF-8");
|
||||
LogUtil.error(e);
|
||||
Cookie cookie_error = new Cookie("LarkError", msg);
|
||||
cookie_error.setPath("/");
|
||||
|
||||
return modelAndView;
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return modelAndView;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUsersRolesMapper;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.xpack.dingtalk.dto.response.DingUserEntity;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
|
||||
import io.dataease.plugins.xpack.oidc.dto.SSOUserInfo;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -172,6 +173,28 @@ public class SysUserService {
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveLarkCUser(LarkUserInfo larkUserInfo, String email) {
|
||||
long now = System.currentTimeMillis();
|
||||
SysUser sysUser = new SysUser();
|
||||
|
||||
sysUser.setUsername(larkUserInfo.getUser_id());
|
||||
sysUser.setNickName(larkUserInfo.getName());
|
||||
sysUser.setEmail(email);
|
||||
sysUser.setPassword(CodingUtil.md5(DEFAULT_PWD));
|
||||
sysUser.setCreateTime(now);
|
||||
sysUser.setUpdateTime(now);
|
||||
|
||||
sysUser.setEnabled(1L);
|
||||
sysUser.setLanguage("zh_CN");
|
||||
sysUser.setFrom(6);
|
||||
sysUser.setIsAdmin(false);
|
||||
sysUser.setSub(larkUserInfo.getSub());
|
||||
sysUser.setPhone(larkUserInfo.getMobile());
|
||||
sysUserMapper.insert(sysUser);
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveCASUser(String name, String email) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
@ -114,9 +114,9 @@ export function dingtalkStatus() {
|
||||
})
|
||||
}
|
||||
|
||||
export function farkStatus() {
|
||||
export function larkStatus() {
|
||||
return request({
|
||||
url: '/api/auth/isOpenFark',
|
||||
url: '/api/auth/isOpenLark',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
@ -61,13 +61,13 @@
|
||||
<el-row class="code-contaniner">
|
||||
<plugin-com v-if="loginTypes.includes(4) && codeIndex === 4" ref="WecomQr" component-name="WecomQr" />
|
||||
<plugin-com v-if="loginTypes.includes(5) && codeIndex === 5" ref="DingtalkQr" component-name="DingtalkQr" />
|
||||
<plugin-com v-if="loginTypes.includes(6) && codeIndex === 6" ref="FarkQr" component-name="FarkQr" />
|
||||
<plugin-com v-if="loginTypes.includes(6) && codeIndex === 6" ref="LarkQr" component-name="LarkQr" />
|
||||
</el-row>
|
||||
|
||||
<div v-if="qrTypes.length > 1" class="login-third-items">
|
||||
<span v-if="qrTypes.includes(4)" class="login-third-item login-third-wecom" @click="switchCodeIndex(4)" />
|
||||
<span v-if="qrTypes.includes(5)" class="login-third-item login-third-dingtalk" @click="switchCodeIndex(5)" />
|
||||
<span v-if="qrTypes.includes(6)" class="login-third-item login-third-fark" @click="switchCodeIndex(6)" />
|
||||
<span v-if="qrTypes.includes(6)" class="login-third-item login-third-lark" @click="switchCodeIndex(6)" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -89,7 +89,7 @@
|
||||
<script>
|
||||
|
||||
import { encrypt } from '@/utils/rsaEncrypt'
|
||||
import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded, defaultLoginType, wecomStatus, dingtalkStatus, farkStatus } from '@/api/user'
|
||||
import { ldapStatus, oidcStatus, getPublicKey, pluginLoaded, defaultLoginType, wecomStatus, dingtalkStatus, larkStatus } from '@/api/user'
|
||||
import { getSysUI } from '@/utils/auth'
|
||||
import { changeFavicon } from '@/utils/index'
|
||||
import { initTheme } from '@/utils/ThemeUtil'
|
||||
@ -193,7 +193,7 @@ export default {
|
||||
this.setDefaultType()
|
||||
})
|
||||
|
||||
farkStatus().then(res => {
|
||||
larkStatus().then(res => {
|
||||
if (res.success && res.data) {
|
||||
this.loginTypes.push(6)
|
||||
const arr = this.loginTypes.filter(item => item > 3)
|
||||
@ -520,8 +520,8 @@ export default {
|
||||
.login-third-dingtalk {
|
||||
background: url(../../assets/dingding01.png) no-repeat 50%/cover;
|
||||
}
|
||||
.login-third-fark {
|
||||
background: url(../../assets/fark.png) no-repeat 50%/cover;
|
||||
.login-third-lark {
|
||||
background: url(../../assets/lark.png) no-repeat 50%/cover;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
@ -71,6 +71,12 @@
|
||||
:label="$t('dingtalk.title')"
|
||||
name="twelve"
|
||||
/>
|
||||
<el-tab-pane
|
||||
v-if="isPluginLoaded"
|
||||
:lazy="true"
|
||||
:label="$t('lark.title')"
|
||||
name="thirteen"
|
||||
/>
|
||||
</el-tabs>
|
||||
<div
|
||||
class="tabs-container"
|
||||
@ -80,34 +86,15 @@
|
||||
<basic-setting v-if="activeName === 'zero'" />
|
||||
<email-setting v-if="activeName === 'first'" />
|
||||
<map-setting v-if="activeName === 'ten'" ref="mapSetting" />
|
||||
<plugin-com
|
||||
v-if="activeName === 'fourth'"
|
||||
ref="DisplaySetting"
|
||||
component-name="LdapSetting"
|
||||
/>
|
||||
<plugin-com
|
||||
v-if="activeName === 'five'"
|
||||
ref="DisplaySetting"
|
||||
component-name="SsoSetting"
|
||||
/>
|
||||
<plugin-com v-if="activeName === 'fourth'" ref="DisplaySetting" component-name="LdapSetting" />
|
||||
<plugin-com v-if="activeName === 'five'" ref="DisplaySetting" component-name="SsoSetting" />
|
||||
<simple-mode v-if="activeName === 'six'" />
|
||||
<cluster-mode v-if="activeName === 'seven'" />
|
||||
<kettle-setting v-if="activeName === 'eight'" />
|
||||
<plugin-com
|
||||
v-if="activeName === 'nine'"
|
||||
ref="CasSetting"
|
||||
component-name="CasSetting"
|
||||
/>
|
||||
<plugin-com
|
||||
v-if="activeName === 'eleven'"
|
||||
ref="WecomSetting"
|
||||
component-name="WecomSetting"
|
||||
/>
|
||||
<plugin-com
|
||||
v-if="activeName === 'twelve'"
|
||||
ref="DingtalkSetting"
|
||||
component-name="DingtalkSetting"
|
||||
/>
|
||||
<plugin-com v-if="activeName === 'nine'" ref="CasSetting" component-name="CasSetting" />
|
||||
<plugin-com v-if="activeName === 'eleven'" ref="WecomSetting" component-name="WecomSetting" />
|
||||
<plugin-com v-if="activeName === 'twelve'" ref="DingtalkSetting" component-name="DingtalkSetting" />
|
||||
<plugin-com v-if="activeName === 'thirteen'" ref="LarkSetting" component-name="LarkSetting" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user