Skip to content

Commit 5a2abcd

Browse files
committed
feat: 支持 github、gitee、coding 登录
1 parent e17300a commit 5a2abcd

File tree

28 files changed

+1121
-17
lines changed

28 files changed

+1121
-17
lines changed

config/proxy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ export default {
2020
// 依赖 origin 的功能可能需要这个,比如 cookie
2121
changeOrigin: true,
2222
},
23+
'/login/': {
24+
// 要代理的地址
25+
target: 'http://localhost:8001',
26+
// 配置了这个可以从 http 代理到 https
27+
// 依赖 origin 的功能可能需要这个,比如 cookie
28+
changeOrigin: true,
29+
},
2330
'/swagger/': {
2431
// 要代理的地址
2532
target: 'http://localhost:8001',

config/routes.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,31 @@ export default [
5656
},
5757
],
5858
},
59-
// {
60-
// name: 'authn',
61-
// path: '/authn',
62-
// icon: 'VerifiedOutlined',
63-
// routes: [
64-
// { path: '/authn/identity-provider', redirect: '/authn/identity-provider/list' },
65-
// {
66-
// path: '/authn/identity-provider/list',
67-
// name: 'identity-provider-list',
68-
// component: './User',
69-
// },
70-
// ],
71-
// },
59+
{
60+
name: 'authn',
61+
path: '/authn',
62+
icon: 'NodeIndexOutlined',
63+
routes: [
64+
{ path: '/authn', redirect: '/authn/identity-source/social' },
65+
{
66+
path: '/authn/identity-source/social',
67+
name: 'identity-source.social.list',
68+
component: './IdentityProvider',
69+
},
70+
{
71+
path: '/authn/identity-source/social/edit/:instanceId',
72+
name: 'identity-source.social.edit',
73+
component: './IdentityProvider/Create',
74+
hideInMenu: true,
75+
},
76+
{
77+
path: '/authn/identity-source/social/create',
78+
name: 'identity-source.social.create',
79+
component: './IdentityProvider/Create',
80+
hideInMenu: true,
81+
},
82+
],
83+
},
7284
{
7385
name: 'resource',
7486
path: '/resource',

src/components/Icon/CodingIcon.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Icon from '@ant-design/icons';
2+
import type { CustomIconComponentProps } from '@ant-design/icons/lib/components/Icon';
3+
4+
const CodingSvg = () => {
5+
return (
6+
<svg
7+
className="icon"
8+
viewBox="0 0 1024 1024"
9+
version="1.1"
10+
xmlns="http://www.w3.org/2000/svg"
11+
width="1.1em"
12+
height="1.1em"
13+
>
14+
<path
15+
d="M465.76 64.704c-104.864 11.52-197.824 55.936-271.456 129.536-74.656 74.656-118.24 166.976-129.536 274.336-3.712 35.168-3.712 51.616 0 86.784 11.296 107.328 55.104 199.872 129.536 274.336s166.976 118.24 274.336 129.568c35.168 3.712 51.616 3.712 86.784 0 86.368-9.056 160.8-38.24 229.888-90.08 25.28-18.912 64.992-58.592 83.904-83.904 51.616-68.896 81.024-143.744 90.08-229.888 3.712-35.168 3.712-51.616 0-86.784-9.056-86.368-38.24-160.8-90.08-229.888-18.912-25.28-58.592-64.992-83.904-83.904-68.896-51.616-143.744-81.024-229.888-90.08a380.48 380.48 0 0 0-91.488 0.192l1.824-0.192z m51.2 208.928c10.08 32.288 37.216 55.104 89.664 75.072 58.4 22.4 119.072 76.896 148.064 133.056l6.976 13.376 5.76-8.032c22.4-30.848 64.576-25.696 82.24 10.272 3.904 8.032 4.736 12.736 4.736 30.016 0 23.232-3.488 33.504-15.84 46.272-13.152 13.152-33.92 18.112-49.76 11.52l-6.976-2.88-1.44 11.52c-2.272 19.744-5.152 29.408-14.4 48.736-29.6 61.472-102.208 104.448-198.24 117.216-27.968 3.904-83.488 3.904-111.456 0-104.448-13.792-181.376-63.968-205.44-133.664a206.336 206.336 0 0 1-6.208-26.24l-0.192-1.312-2.528-16.192-6.784 2.88c-22.208 9.248-48.928-2.88-60.864-27.776-5.952-12.544-7.392-36.608-2.88-52.032 4.128-14.816 18.304-30.848 31.04-35.776 19.328-7.392 41.12-0.416 54.08 17.472l5.76 8.032 7.008-13.376c18.72-36.384 57.792-79.392 94.176-103.648 21.376-14.4 51.616-30.016 67.232-34.752 33.728-10.272 68.48-42.144 76.704-70.336 1.856-6.592 3.904-11.936 4.512-11.936s2.944 5.728 4.992 12.512z m-109.792 203.584c-37.632 4.32-75.264 26.72-91.936 54.912-7.808 13.152-15.008 38.24-16.448 56.96-2.464 33.312 7.008 56.128 34.144 83.296 20.96 20.768 39.072 31.68 72.192 43.392 34.944 12.352 63.744 16.864 106.944 16.864s71.968-4.512 106.944-16.864c32.896-11.52 51.2-22.624 72.192-43.392 34.144-33.728 42.56-68.672 27.968-115.584-6.368-20.16-12.736-30.848-26.528-44.224-43.168-41.952-113.92-48.32-165.344-14.592l-15.232 9.856-11.936-8.224c-27.136-18.496-59.232-26.112-92.96-22.4z m-22.624 67.04c6.784 8.64 2.272 21.184-7.392 21.184s-14.592-15.008-7.008-22.624c5.504-5.568 9.056-5.152 14.4 1.44z m264.864-2.272c8.64 5.952 4.32 23.456-5.76 23.456s-14.4-17.472-5.76-23.456a19.584 19.584 0 0 1 5.632-3.232l0.128-0.032c2.208 0.832 4.128 1.92 5.792 3.328l-0.032-0.032z m-434.528-20.16a16.448 16.448 0 0 0-11.904 10.368l-0.032 0.128c-1.44 6.176 4.128 16.256 11.296 20.768q13.28 8.032 23.456-0.608c4.736-4.128 5.344-5.76 4.128-12.128-2.048-11.712-15.424-20.96-26.944-18.496z m584.224 0.64a23.744 23.744 0 0 0-16.832 17.728l-0.032 0.16c-1.248 6.368-0.608 8.032 4.128 12.128q10.176 8.64 23.456 0.608c7.2-4.512 12.736-14.592 11.296-20.768-2.272-8.224-11.936-12.544-22.016-9.856z"
16+
fill="currentColor"
17+
></path>
18+
</svg>
19+
);
20+
};
21+
22+
export const CodingIcon = (props: Partial<CustomIconComponentProps>) => (
23+
<Icon component={CodingSvg} {...props} />
24+
);

src/components/Icon/GiteeIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const GiteeSvg = () => {
88
viewBox="0 0 1024 1024"
99
version="1.1"
1010
xmlns="http://www.w3.org/2000/svg"
11-
width="28"
12-
height="28"
11+
width="1em"
12+
height="1.1em"
1313
>
1414
<path
1515
d="M512 1024C229.248 1024 0 794.752 0 512S229.248 0 512 0s512 229.248 512 512-229.248 512-512 512z m259.168-568.896h-290.752a25.28 25.28 0 0 0-25.28 25.28l-0.032 63.232c0 13.952 11.296 25.28 25.28 25.28h177.024a25.28 25.28 0 0 1 25.28 25.28v12.64a75.84 75.84 0 0 1-75.84 75.84h-240.224a25.28 25.28 0 0 1-25.28-25.28v-240.192a75.84 75.84 0 0 1 75.84-75.84h353.92a25.28 25.28 0 0 0 25.28-25.28l0.064-63.2a25.312 25.312 0 0 0-25.28-25.312H417.184a189.632 189.632 0 0 0-189.632 189.6v353.952c0 13.952 11.328 25.28 25.28 25.28h372.928a170.656 170.656 0 0 0 170.656-170.656v-145.376a25.28 25.28 0 0 0-25.28-25.28z"

src/constant/basicIntl.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ export const BASIC_INTL = {
22
TITLE_OPTION: {
33
id: 'pages.searchTable.titleOption',
44
},
5+
NAME_TIP: {
6+
id: 'pages.common.form.name.tip',
7+
},
8+
DISPLAY_NAME_TIP: {
9+
id: 'pages.common.form.displayName.tip',
10+
},
511
BTN_MORE: {
612
id: 'pages.common.btn.more',
713
},

src/enums/appEnum.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ export const DEFAULT_APP = 'built-in-app';
33
export enum IdentityProviderType {
44
GitHub = 'GitHub',
55
Gitee = 'Gitee',
6+
Coding = 'Coding',
67
WeChat = 'WeChat',
78
LDAP = 'LDAP',
89
WeChatMiniProgram = 'WeChatMiniProgram',
910
}
11+
12+
export enum ProviderCategory {
13+
OAuth = 'OAuth',
14+
Generic = 'Generic',
15+
}

src/locales/zh-CN/menu.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ export default {
3030
'menu.org-management.user.list': '用户管理',
3131
'menu.org-management.user.edit': '编辑用户',
3232

33-
'menu.authn': '认证管理',
34-
'menu.authn.identity-provider-list': '身份提供商',
33+
'menu.authn': '身份认证',
34+
'menu.authn.identity-source.social.list': '社会化认证源',
35+
'menu.authn.identity-source.social.create': '创建社会化认证源',
36+
'menu.authn.identity-source.social.edit': '编辑社会化认证源',
37+
'menu.authn.identity-source.enterprise': '企业认证源',
3538

3639
'menu.resource': '资源权限',
3740
'menu.resource.resource-list': '资源管理',

src/locales/zh-CN/pages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ export default {
1919
'pages.common.btn.edit': '编辑',
2020
'pages.common.btn.delete': '删除',
2121
'pages.common.btn.add': '新增',
22+
23+
'pages.common.form.name.tip': '唯一的、字符串式的ID',
24+
'pages.common.form.displayName.tip': '公开显示的、用户易读的名称',
2225
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { useIntl } from '@umijs/max';
3+
import { getRedirectURL } from '@/services/system/oauth';
4+
import { ProFormDependency, ProFormText } from '@ant-design/pro-components';
5+
6+
const INTL = {
7+
NAME: {
8+
id: 'idp.form.name',
9+
},
10+
AUTH_URL: {
11+
id: 'idp.form.authURL',
12+
},
13+
};
14+
15+
export const CallbackURL = () => {
16+
const intl = useIntl();
17+
18+
return (
19+
<ProFormDependency name={['name']}>
20+
{({ name }) => {
21+
const redirectURL = getRedirectURL(name ? name : `{${intl.formatMessage(INTL.NAME)}}`);
22+
return (
23+
<ProFormText
24+
width="xl"
25+
label={intl.formatMessage(INTL.AUTH_URL)}
26+
name={['config', 'redirectURL']}
27+
allowClear={false}
28+
initialValue={redirectURL}
29+
></ProFormText>
30+
);
31+
}}
32+
</ProFormDependency>
33+
);
34+
};
35+
36+
export default CallbackURL;
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import React from 'react';
2+
import { useIntl } from '@umijs/max';
3+
import { Checkbox, Col, Row } from 'antd';
4+
import { ProForm, ProFormText } from '@ant-design/pro-components';
5+
6+
import CallbackURL from './CallbackURL';
7+
8+
const INTL = {
9+
CLIENT_ID: {
10+
id: 'idp.form.clientID',
11+
},
12+
SCOPES: {
13+
id: 'idp.form.scopes',
14+
},
15+
CLIENT_SECRET: {
16+
id: 'idp.form.clientSecret',
17+
},
18+
CALLBACK_URL: {
19+
id: 'idp.form.callbackURL',
20+
},
21+
CALLBACK_URL_PLACEHOLDER: {
22+
id: 'idp.form.callbackURL.placeholder',
23+
},
24+
CODING_TEAM: {
25+
id: 'idp.form.codingTeam',
26+
},
27+
CODING_TEAM_PLACEHOLDER: {
28+
id: 'idp.form.codingTeam.placeholder',
29+
},
30+
CLIENT_ID_PLACEHOLDER: {
31+
id: 'idp.form.clientID.placeholder',
32+
},
33+
CLIENT_SECRET_PLACEHOLDER: {
34+
id: 'idp.form.clientSecret.placeholder',
35+
},
36+
};
37+
38+
export const Coding: React.FC = () => {
39+
const intl = useIntl();
40+
41+
const scopes = [
42+
{ name: 'user', desc: '' },
43+
{ name: 'user:email', desc: '' },
44+
{ name: 'notification', desc: '' },
45+
{ name: 'project', desc: '' },
46+
{ name: 'project:api_doc', desc: '' },
47+
{ name: 'project:artifacts', desc: '' },
48+
{ name: 'project:depot', desc: '' },
49+
{ name: 'project:file', desc: '' },
50+
{ name: 'project:issue', desc: '' },
51+
{ name: 'project:key', desc: '' },
52+
{ name: 'project:members', desc: '' },
53+
{ name: 'project:notice', desc: '' },
54+
];
55+
56+
return (
57+
<>
58+
<ProForm.Group align="center">
59+
<ProFormText
60+
width="lg"
61+
required
62+
name={['config', 'clientID']}
63+
fieldProps={{ autoComplete: 'off' }}
64+
label={intl.formatMessage(INTL.CLIENT_ID)}
65+
placeholder={intl.formatMessage(INTL.CLIENT_ID_PLACEHOLDER)}
66+
rules={[{ required: true }]}
67+
/>
68+
<ProFormText.Password
69+
width="lg"
70+
name={['config', 'clientSecret']}
71+
fieldProps={{ autoComplete: 'off' }}
72+
label={intl.formatMessage(INTL.CLIENT_SECRET)}
73+
placeholder={intl.formatMessage(INTL.CLIENT_SECRET_PLACEHOLDER)}
74+
rules={[{ required: true }]}
75+
/>
76+
</ProForm.Group>
77+
<ProForm.Group align="center">
78+
<ProFormText
79+
width="lg"
80+
name={['config', 'team']}
81+
fieldProps={{ autoComplete: 'off' }}
82+
label={intl.formatMessage(INTL.CODING_TEAM)}
83+
placeholder={intl.formatMessage(INTL.CODING_TEAM_PLACEHOLDER)}
84+
rules={[{ required: true }]}
85+
/>
86+
<ProFormText
87+
width="lg"
88+
name="callbackURL"
89+
fieldProps={{ autoComplete: 'off' }}
90+
label={intl.formatMessage(INTL.CALLBACK_URL)}
91+
placeholder={intl.formatMessage(INTL.CALLBACK_URL_PLACEHOLDER)}
92+
/>
93+
</ProForm.Group>
94+
<ProForm.Group align="center">
95+
<ProForm.Item name={['config', 'scopes']} label={intl.formatMessage(INTL.SCOPES)}>
96+
<Checkbox.Group style={{ maxWidth: 912 }}>
97+
<Row gutter={[4, 8]}>
98+
{scopes.map((act) => {
99+
return (
100+
<Col span={6} key={`${act.name}-scope`}>
101+
<Checkbox value={act.name}>
102+
{act.name}
103+
{act.desc ? `(${act.desc})` : ''}
104+
</Checkbox>
105+
</Col>
106+
);
107+
})}
108+
</Row>
109+
</Checkbox.Group>
110+
</ProForm.Item>
111+
</ProForm.Group>
112+
<ProForm.Group align="center">
113+
<CallbackURL />
114+
</ProForm.Group>
115+
</>
116+
);
117+
};

0 commit comments

Comments
 (0)