优化身份提供商

pull/82/head^2
awenes 2024-04-04 22:47:39 +08:00
parent 3b92254b54
commit 60d3a393f0
6 changed files with 41 additions and 84 deletions

View File

@ -18,15 +18,14 @@
import { ProFormSwitch } from '@ant-design/pro-components'; import { ProFormSwitch } from '@ant-design/pro-components';
import { IdentityProviderType } from '../../constant'; import { IdentityProviderType } from '../../constant';
import DingTalkOauthConfig from './DingTalkOauthConfig'; import DingTalkOauthConfig from './DingTalkOauthConfig';
import DingTalkScanCode from './DingTalkScanCodeConfig';
import FeiShuScanCodeConfig from './FeiShuScanCodeConfig'; import FeiShuScanCodeConfig from './FeiShuScanCodeConfig';
import QqOauthConfig from './QqOauthConfig'; import QqOauthConfig from './QqOauthConfig';
import WeChatScanCode from './WeChatScanCodeConfig'; import WeChatScanCode from './WeChatScanCodeConfig';
import WeWorkScanCode from './WeWorkScanCodeConfig'; import WeChatWorkConfig from './WeChatWorkConfig';
import GithubOauthConfig from './GithubOauthConfig'; import GithubOauthConfig from './GithubOauthConfig';
import GiteeOauthConfig from './GiteeOauthConfig'; import GiteeOauthConfig from './GiteeOauthConfig';
import AliPayOauthConfig from './AliPayOauthConfig';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import AliPayOauthConfig from '@/pages/authn/IdentityProvider/components/Config/AliPayOauthConfig';
/** /**
* Config * Config
@ -41,8 +40,7 @@ const Config = (props: { type: IdentityProviderType | string; isCreate?: boolean
return ( return (
<> <>
{type === IdentityProviderType.wechat_qr && <WeChatScanCode isCreate={isCreate} />} {type === IdentityProviderType.wechat_qr && <WeChatScanCode isCreate={isCreate} />}
{type === IdentityProviderType.wechatwork_qr && <WeWorkScanCode isCreate={isCreate} />} {type === IdentityProviderType.wechatwork_oauth && <WeChatWorkConfig isCreate={isCreate} />}
{type === IdentityProviderType.dingtalk_qr && <DingTalkScanCode isCreate={isCreate} />}
{type === IdentityProviderType.dingtalk_oauth && <DingTalkOauthConfig isCreate={isCreate} />} {type === IdentityProviderType.dingtalk_oauth && <DingTalkOauthConfig isCreate={isCreate} />}
{type === IdentityProviderType.qq_oauth && <QqOauthConfig isCreate={isCreate} />} {type === IdentityProviderType.qq_oauth && <QqOauthConfig isCreate={isCreate} />}
{type === IdentityProviderType.feishu_oauth && <FeiShuScanCodeConfig isCreate={isCreate} />} {type === IdentityProviderType.feishu_oauth && <FeiShuScanCodeConfig isCreate={isCreate} />}

View File

@ -1,61 +0,0 @@
/*
* eiam-console - Employee Identity and Access Management
* Copyright © 2022-Present Jinan Yuanchuang Network Technology Co., Ltd. (support@topiam.cn)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ProFormText } from '@ant-design/pro-components';
import CallbackUrl from './CallbackUrl';
import { useIntl } from '@umijs/max';
/**
*
*
* @constructor
*/
const DingTalkScanCode = (props: { isCreate: boolean }) => {
const { isCreate } = props;
const intl = useIntl();
return (
<>
<ProFormText
name={['config', 'appKey']}
label="AppKey"
rules={[{ required: true }]}
extra={intl.formatMessage({
id: 'pages.authn.identity_provider.config.ding_talk_oauth.app_id.extra',
})}
fieldProps={{ autoComplete: 'off' }}
placeholder={intl.formatMessage({
id: 'pages.authn.identity_provider.config.ding_talk_oauth.app_id.placeholder',
})}
/>
<ProFormText.Password
rules={[{ required: true }]}
name={['config', 'appSecret']}
label="AppSecret"
extra={intl.formatMessage({
id: 'pages.authn.identity_provider.config.ding_talk_oauth.app_id.extra',
})}
placeholder={intl.formatMessage({
id: 'pages.authn.identity_provider.config.ding_talk_oauth.app_secret.placeholder',
})}
fieldProps={{ autoComplete: 'off' }}
/>
{!isCreate && <CallbackUrl />}
</>
);
};
export default DingTalkScanCode;

View File

@ -21,7 +21,7 @@ import CallbackUrl from './CallbackUrl';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
/** /**
* *
* *
* @constructor * @constructor
*/ */

View File

@ -23,9 +23,9 @@ import {
ProFormTextArea, ProFormTextArea,
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { useAsyncEffect } from 'ahooks'; import { useAsyncEffect } from 'ahooks';
import { Spin } from 'antd'; import { Avatar, Space, Spin } from 'antd';
import { useForm } from 'antd/es/form/Form'; import { useForm } from 'antd/es/form/Form';
import { useState } from 'react'; import React, { useState } from 'react';
import { import {
DRAWER_FORM_ITEM_LAYOUT, DRAWER_FORM_ITEM_LAYOUT,
IdentityProviderCategory, IdentityProviderCategory,
@ -33,6 +33,7 @@ import {
} from '../../constant'; } from '../../constant';
import Config from '../Config'; import Config from '../Config';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { ICON_LIST } from '@/components/IconFont/constant';
export type CreateDrawerProps = { export type CreateDrawerProps = {
visible?: boolean; visible?: boolean;
@ -50,7 +51,7 @@ export default (props: CreateDrawerProps) => {
if (category === IdentityProviderCategory.enterprise) { if (category === IdentityProviderCategory.enterprise) {
form?.setFieldsValue({ form?.setFieldsValue({
displayed: true, displayed: true,
type: IdentityProviderType.dingtalk_qr, type: IdentityProviderType.dingtalk_oauth,
}); });
} }
if (category === IdentityProviderCategory.social) { if (category === IdentityProviderCategory.social) {
@ -108,36 +109,51 @@ export default (props: CreateDrawerProps) => {
required: true, required: true,
}, },
]} ]}
fieldProps={{
optionRender: ({ data }) => {
return (
<Space>
<Avatar shape={'square'} src={ICON_LIST[data?.icon]} />
{data.label}
</Space>
);
},
}}
options={[ options={[
{ {
value: IdentityProviderType.wechat_qr, value: IdentityProviderType.wechat_qr,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.wechat_qr', id: 'pages.authn.identity_provider.create_modal.form.type.wechat_qr',
}), }),
icon: IdentityProviderType.wechat_qr,
}, },
{ {
value: IdentityProviderType.qq_oauth, value: IdentityProviderType.qq_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.qq', id: 'pages.authn.identity_provider.create_modal.form.type.qq',
}), }),
icon: IdentityProviderType.qq_oauth,
}, },
{ {
value: IdentityProviderType.alipay_oauth, value: IdentityProviderType.alipay_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.alipay_oauth', id: 'pages.authn.identity_provider.create_modal.form.type.alipay_oauth',
}), }),
icon: IdentityProviderType.alipay_oauth,
}, },
{ {
value: IdentityProviderType.github_oauth, value: IdentityProviderType.github_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.github', id: 'pages.authn.identity_provider.create_modal.form.type.github',
}), }),
icon: IdentityProviderType.github_oauth,
}, },
{ {
value: IdentityProviderType.gitee_oauth, value: IdentityProviderType.gitee_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.gitee', id: 'pages.authn.identity_provider.create_modal.form.type.gitee',
}), }),
icon: IdentityProviderType.gitee_oauth,
}, },
]} ]}
/> />
@ -166,30 +182,37 @@ export default (props: CreateDrawerProps) => {
required: true, required: true,
}, },
]} ]}
fieldProps={{
optionRender: ({ data }) => {
return (
<Space>
<Avatar shape={'square'} src={ICON_LIST[data?.icon]} />
{data.label}
</Space>
);
},
}}
options={[ options={[
{ {
value: IdentityProviderType.dingtalk_oauth, value: IdentityProviderType.dingtalk_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.dingtalk_oauth', id: 'pages.authn.identity_provider.create_modal.form.type.dingtalk_oauth',
}), }),
}, icon: IdentityProviderType.dingtalk_oauth,
{
value: IdentityProviderType.dingtalk_qr,
label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.dingtalk_qr',
}),
}, },
{ {
value: IdentityProviderType.feishu_oauth, value: IdentityProviderType.feishu_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.feishu_oauth', id: 'pages.authn.identity_provider.create_modal.form.type.feishu_oauth',
}), }),
icon: IdentityProviderType.feishu_oauth,
}, },
{ {
value: IdentityProviderType.wechatwork_qr, value: IdentityProviderType.wechatwork_oauth,
label: intl.formatMessage({ label: intl.formatMessage({
id: 'pages.authn.identity_provider.create_modal.form.type.wechatwork_qr', id: 'pages.authn.identity_provider.create_modal.form.type.wechatwork_oauth',
}), }),
icon: IdentityProviderType.wechatwork_oauth,
}, },
]} ]}
/> />

View File

@ -28,8 +28,7 @@ export enum IdentityProviderCategory {
*/ */
export enum IdentityProviderType { export enum IdentityProviderType {
//企业 //企业
wechatwork_qr = 'wechatwork_qr', wechatwork_oauth = 'wechatwork_oauth',
dingtalk_qr = 'dingtalk_qr',
feishu_oauth = 'feishu_oauth', feishu_oauth = 'feishu_oauth',
dingtalk_oauth = 'dingtalk_oauth', dingtalk_oauth = 'dingtalk_oauth',
//社交 //社交
@ -44,8 +43,7 @@ export enum IdentityProviderType {
* *
*/ */
export const EXIST_CALLBACK = [ export const EXIST_CALLBACK = [
IdentityProviderType.wechatwork_qr, IdentityProviderType.wechatwork_oauth,
IdentityProviderType.dingtalk_qr,
IdentityProviderType.dingtalk_oauth, IdentityProviderType.dingtalk_oauth,
IdentityProviderType.wechat_qr, IdentityProviderType.wechat_qr,
IdentityProviderType.qq_oauth, IdentityProviderType.qq_oauth,

View File

@ -42,9 +42,8 @@ export default {
'pages.authn.identity_provider.create_modal.form.type.github': 'GitHub认证', 'pages.authn.identity_provider.create_modal.form.type.github': 'GitHub认证',
'pages.authn.identity_provider.create_modal.form.type.alipay_oauth': '支付宝认证', 'pages.authn.identity_provider.create_modal.form.type.alipay_oauth': '支付宝认证',
'pages.authn.identity_provider.create_modal.form.type.dingtalk_oauth': '钉钉认证', 'pages.authn.identity_provider.create_modal.form.type.dingtalk_oauth': '钉钉认证',
'pages.authn.identity_provider.create_modal.form.type.dingtalk_qr': '钉钉扫码认证',
'pages.authn.identity_provider.create_modal.form.type.feishu_oauth': '飞书认证', 'pages.authn.identity_provider.create_modal.form.type.feishu_oauth': '飞书认证',
'pages.authn.identity_provider.create_modal.form.type.wechatwork_qr': '企业微信扫码认证', 'pages.authn.identity_provider.create_modal.form.type.wechatwork_oauth': '企业微信认证',
'pages.authn.identity_provider.create_modal.form.name': '认证源名称', 'pages.authn.identity_provider.create_modal.form.name': '认证源名称',
'pages.authn.identity_provider.create_modal.form.name.placeholder': '请输入认证源名称', 'pages.authn.identity_provider.create_modal.form.name.placeholder': '请输入认证源名称',
'pages.authn.identity_provider.create_modal.form.name.rule.0.message': '认证源名称为必填项', 'pages.authn.identity_provider.create_modal.form.name.rule.0.message': '认证源名称为必填项',