feat(系统设置): 认证登陆调试
This commit is contained in:
parent
e17389c271
commit
7e3111385b
|
@ -11,6 +11,7 @@ public class FilterChainUtils {
|
||||||
filterChainDefinitionMap.put("/login", "anon");
|
filterChainDefinitionMap.put("/login", "anon");
|
||||||
filterChainDefinitionMap.put("/ldap/login", "anon");
|
filterChainDefinitionMap.put("/ldap/login", "anon");
|
||||||
filterChainDefinitionMap.put("/authentication/get-list", "anon");
|
filterChainDefinitionMap.put("/authentication/get-list", "anon");
|
||||||
|
filterChainDefinitionMap.put("/authentication//get/by/type/**", "anon");
|
||||||
filterChainDefinitionMap.put("/we_com/info", "anon");
|
filterChainDefinitionMap.put("/we_com/info", "anon");
|
||||||
filterChainDefinitionMap.put("/ding_talk/info", "anon");
|
filterChainDefinitionMap.put("/ding_talk/info", "anon");
|
||||||
filterChainDefinitionMap.put("/lark/info", "anon");
|
filterChainDefinitionMap.put("/lark/info", "anon");
|
||||||
|
|
|
@ -837,7 +837,7 @@
|
||||||
<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
|
<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
|
||||||
SELECT
|
SELECT
|
||||||
crfc.id as id,
|
crfc.id as id,
|
||||||
history.`status` as reviewStatus,
|
IFNULL(history.`status`, fc.review_status) as reviewStatus,
|
||||||
fc.module_id as moduleId,
|
fc.module_id as moduleId,
|
||||||
fc.name as name,
|
fc.name as name,
|
||||||
fc.id as caseId,
|
fc.id as caseId,
|
||||||
|
|
|
@ -2,6 +2,7 @@ import MSR from '@/api/http/index';
|
||||||
import {
|
import {
|
||||||
AddAuthUrl,
|
AddAuthUrl,
|
||||||
DeleteAuthUrl,
|
DeleteAuthUrl,
|
||||||
|
GetAuthDetailByTypeUrl,
|
||||||
GetAuthDetailUrl,
|
GetAuthDetailUrl,
|
||||||
GetAuthListUrl,
|
GetAuthListUrl,
|
||||||
GetBaseInfoUrl,
|
GetBaseInfoUrl,
|
||||||
|
@ -86,6 +87,11 @@ export function getAuthDetail(id: string) {
|
||||||
return MSR.get<AuthItem>({ url: GetAuthDetailUrl, params: id });
|
return MSR.get<AuthItem>({ url: GetAuthDetailUrl, params: id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取认证源详情
|
||||||
|
export function getAuthDetailByType(type: string) {
|
||||||
|
return MSR.get<AuthItem>({ url: GetAuthDetailByTypeUrl, params: type });
|
||||||
|
}
|
||||||
|
|
||||||
// 添加认证源
|
// 添加认证源
|
||||||
export function addAuth(data: AuthParams) {
|
export function addAuth(data: AuthParams) {
|
||||||
return MSR.post({ url: AddAuthUrl, data });
|
return MSR.post({ url: AddAuthUrl, data });
|
||||||
|
|
|
@ -24,6 +24,8 @@ export const GetAuthListUrl = '/system/authsource/list';
|
||||||
export const AddAuthUrl = '/system/authsource/add';
|
export const AddAuthUrl = '/system/authsource/add';
|
||||||
// 获取认证源详情
|
// 获取认证源详情
|
||||||
export const GetAuthDetailUrl = '/system/authsource/get';
|
export const GetAuthDetailUrl = '/system/authsource/get';
|
||||||
|
// 根据类型获取认证源详情
|
||||||
|
export const GetAuthDetailByTypeUrl = '/authentication/get/by/type';
|
||||||
// 删除认证源
|
// 删除认证源
|
||||||
export const DeleteAuthUrl = '/system/authsource/delete';
|
export const DeleteAuthUrl = '/system/authsource/delete';
|
||||||
// 测试ldap连接
|
// 测试ldap连接
|
||||||
|
|
|
@ -196,4 +196,5 @@ export default {
|
||||||
'common.collapseAllSubModule': 'Collapse all submodules',
|
'common.collapseAllSubModule': 'Collapse all submodules',
|
||||||
'common.selectedCount': '{count} data selected',
|
'common.selectedCount': '{count} data selected',
|
||||||
'common.advancedSettings': 'Advanced settings',
|
'common.advancedSettings': 'Advanced settings',
|
||||||
|
'common.auth_redirect_tip': 'You will be redirected to the certification source page for certification',
|
||||||
};
|
};
|
||||||
|
|
|
@ -195,4 +195,5 @@ export default {
|
||||||
'common.collapseAllSubModule': '收起全部子模块',
|
'common.collapseAllSubModule': '收起全部子模块',
|
||||||
'common.selectedCount': '(已选 {count} 项数据)',
|
'common.selectedCount': '(已选 {count} 项数据)',
|
||||||
'common.advancedSettings': '高级设置',
|
'common.advancedSettings': '高级设置',
|
||||||
|
'common.auth_redirect_tip': '即将跳转至认证源页面进行认证',
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,7 @@ export interface PageConfig extends ThemeConfig, LoginConfig, PlatformConfig {}
|
||||||
export type PageConfigKeys = keyof PageConfig;
|
export type PageConfigKeys = keyof PageConfig;
|
||||||
|
|
||||||
// 认证源类型
|
// 认证源类型
|
||||||
export type AuthType = 'CAS' | 'LDAP' | 'OAuth2' | 'OIDC';
|
export type AuthType = 'CAS' | 'LDAP' | 'OAUTH2' | 'OIDC';
|
||||||
|
|
||||||
// 认证源配置列表项对象
|
// 认证源配置列表项对象
|
||||||
export interface AuthItem {
|
export interface AuthItem {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div></div>
|
<a-spin class="w-full" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
<span class="type-text text-[7px]">OAUTH</span>
|
<span class="type-text text-[7px]">OAUTH</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isShowCAS && userInfo.authenticate !== 'CAS'" class="loginType" @click="redirectAuth('CAS')">
|
<div v-if="isShowCAS && userInfo.authenticate !== 'CAS'" class="loginType" @click="redirectAuth('CAS')">
|
||||||
<span class="type-text text-[7px]">CAS</span>
|
<span class="type-text text-[10px]">CAS</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="props.isPreview" class="mask"></div>
|
<div v-if="props.isPreview" class="mask"></div>
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
import TabQrCode from '@/views/login/components/tabQrCode.vue';
|
import TabQrCode from '@/views/login/components/tabQrCode.vue';
|
||||||
|
|
||||||
import { getProjectInfo } from '@/api/modules/project-management/basicInfo';
|
import { getProjectInfo } from '@/api/modules/project-management/basicInfo';
|
||||||
import { getAuthDetail } from '@/api/modules/setting/config';
|
import { getAuthDetail, getAuthDetailByType } from '@/api/modules/setting/config';
|
||||||
import { getPlatformParamUrl } from '@/api/modules/user';
|
import { getPlatformParamUrl } from '@/api/modules/user';
|
||||||
import { GetLoginLogoUrl } from '@/api/requrls/setting/config';
|
import { GetLoginLogoUrl } from '@/api/requrls/setting/config';
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
|
@ -132,11 +132,11 @@
|
||||||
import { useAppStore, useUserStore } from '@/store';
|
import { useAppStore, useUserStore } from '@/store';
|
||||||
import useLicenseStore from '@/store/modules/setting/license';
|
import useLicenseStore from '@/store/modules/setting/license';
|
||||||
import { encrypted } from '@/utils';
|
import { encrypted } from '@/utils';
|
||||||
import { setLoginExpires } from '@/utils/auth';
|
import { setLoginExpires, setToken } from '@/utils/auth';
|
||||||
import { getFirstRouteNameByPermission, routerNameHasPermission } from '@/utils/permission';
|
import { getFirstRouteNameByPermission, routerNameHasPermission } from '@/utils/permission';
|
||||||
|
|
||||||
import type { LoginData } from '@/models/user';
|
import type { LoginData } from '@/models/user';
|
||||||
import { SettingRouteEnum } from '@/enums/routeEnum';
|
import { ProjectManagementRouteEnum, SettingRouteEnum } from '@/enums/routeEnum';
|
||||||
|
|
||||||
import { ValidatedError } from '@arco-design/web-vue/es/form/interface';
|
import { ValidatedError } from '@arco-design/web-vue/es/form/interface';
|
||||||
|
|
||||||
|
@ -303,11 +303,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirectAuth(authId: string) {
|
function redirectAuth(authType: string) {
|
||||||
if (authId === 'LDAP' || authId === 'LOCAL') {
|
if (authType === 'LDAP' || authType === 'LOCAL') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getAuthDetail(authId).then((res) => {
|
getAuthDetailByType(authType).then((res) => {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -315,38 +315,32 @@
|
||||||
Message.error(t('login.auth_not_enable'));
|
Message.error(t('login.auth_not_enable'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 以前的cas登录
|
const authId = res.id;
|
||||||
if (userInfo.value.authenticate === 'CAS') {
|
|
||||||
const config = JSON.parse(res.configuration);
|
|
||||||
if (config.casServerUrl && !config.loginUrl) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
openModal({
|
openModal({
|
||||||
type: 'warning',
|
type: 'info',
|
||||||
title: t('commons.auth_redirect_tip'),
|
content: t('common.auth_redirect_tip'),
|
||||||
content: t('ms.minders.leaveUnsavedTip'),
|
|
||||||
okText: t('common.confirm'),
|
okText: t('common.confirm'),
|
||||||
cancelText: t('common.cancel'),
|
cancelText: t('common.cancel'),
|
||||||
okButtonProps: {
|
okButtonProps: {
|
||||||
status: 'normal',
|
status: 'normal',
|
||||||
},
|
},
|
||||||
|
closable: false,
|
||||||
onBeforeOk: async () => {
|
onBeforeOk: async () => {
|
||||||
const config = JSON.parse(res.configuration);
|
const config = JSON.parse(res.configuration);
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
const redirectUrl = eval(`\`${config.redirectUrl}\``);
|
const redirectUrl = eval(`\`${config.redirectUrl}\``);
|
||||||
let url;
|
let url;
|
||||||
if (userInfo.value.authenticate === 'CAS') {
|
if (authType === 'CAS') {
|
||||||
url = `${config.loginUrl}?service=${encodeURIComponent(redirectUrl)}`;
|
url = `${config.loginUrl}?service=${encodeURIComponent(redirectUrl)}`;
|
||||||
}
|
}
|
||||||
if (userInfo.value.authenticate === 'OIDC') {
|
if (authType === 'OIDC') {
|
||||||
url = `${config.authUrl}?client_id=${config.clientId}&redirect_uri=${redirectUrl}&response_type=code&scope=openid+profile+email&state=${authId}`;
|
url = `${config.authUrl}?client_id=${config.clientId}&redirect_uri=${redirectUrl}&response_type=code&scope=openid+profile+email&state=${authId}`;
|
||||||
// 保存一个登录地址,禁用本地登录
|
// 保存一个登录地址,禁用本地登录
|
||||||
if (config.loginUrl) {
|
if (config.loginUrl) {
|
||||||
localStorage.setItem('oidcLoginUrl', config.loginUrl);
|
localStorage.setItem('oidcLoginUrl', config.loginUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userInfo.value.authenticate === 'OAUTH2') {
|
if (authType === 'OAUTH2') {
|
||||||
url =
|
url =
|
||||||
`${config.authUrl}?client_id=${config.clientId}&response_type=code` +
|
`${config.authUrl}?client_id=${config.clientId}&response_type=code` +
|
||||||
`&redirect_uri=${redirectUrl}&state=${authId}`;
|
`&redirect_uri=${redirectUrl}&state=${authId}`;
|
||||||
|
@ -363,9 +357,47 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getQueryVariable(variable: string) {
|
||||||
|
const urlString = window.location.href;
|
||||||
|
|
||||||
|
const queryIndex = urlString.indexOf('?');
|
||||||
|
if (queryIndex !== -1) {
|
||||||
|
const query = urlString.substring(queryIndex + 1);
|
||||||
|
|
||||||
|
// 分割查询参数
|
||||||
|
const params = query.split('&');
|
||||||
|
|
||||||
|
// 遍历参数,找到 _token 参数的值
|
||||||
|
let variableValue;
|
||||||
|
params.forEach((param) => {
|
||||||
|
const pair = param.split('=');
|
||||||
|
if (pair[0] === variable) {
|
||||||
|
console.log(pair[1]);
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
variableValue = pair[1];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return variableValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkAuthUrlParam() {
|
||||||
|
const TOKEN = getQueryVariable('_token');
|
||||||
|
const CSRF = getQueryVariable('_csrf');
|
||||||
|
const pId = getQueryVariable('_pId');
|
||||||
|
const orgId = getQueryVariable('orgId');
|
||||||
|
if (TOKEN !== null && TOKEN !== undefined && CSRF !== null && CSRF !== undefined) {
|
||||||
|
setToken(TOKEN, CSRF);
|
||||||
|
appStore.setCurrentOrgId(pId || '');
|
||||||
|
appStore.setCurrentProjectId(orgId || '');
|
||||||
|
await userStore.checkIsLogin(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
userStore.getAuthentication();
|
userStore.getAuthentication();
|
||||||
initPlatformInfo();
|
initPlatformInfo();
|
||||||
|
checkAuthUrlParam();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@
|
||||||
<MsFormItemSub :text="t('system.config.auth.loginUrlTip')" :show-fill-icon="false" />
|
<MsFormItemSub :text="t('system.config.auth.loginUrlTip')" :show-fill-icon="false" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="activeAuthForm.type === 'OAuth2'">
|
<template v-else-if="activeAuthForm.type === 'OAUTH2'">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
:label="t('system.config.auth.authUrl')"
|
:label="t('system.config.auth.authUrl')"
|
||||||
field="configuration.authUrl"
|
field="configuration.authUrl"
|
||||||
|
@ -899,7 +899,7 @@
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
case 'OAuth2':
|
case 'OAUTH2':
|
||||||
description = description.concat([
|
description = description.concat([
|
||||||
{
|
{
|
||||||
label: t('system.config.auth.authUrl'),
|
label: t('system.config.auth.authUrl'),
|
||||||
|
@ -1150,7 +1150,7 @@
|
||||||
loginUrl: configuration.loginUrl,
|
loginUrl: configuration.loginUrl,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 'OAuth2':
|
case 'OAUTH2':
|
||||||
_configuration = {
|
_configuration = {
|
||||||
authUrl: configuration.authUrl,
|
authUrl: configuration.authUrl,
|
||||||
tokenUrl: configuration.tokenUrl,
|
tokenUrl: configuration.tokenUrl,
|
||||||
|
|
Loading…
Reference in New Issue