@authing/react-ui-components 2.4.55 → 2.4.56-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +14 -2
- package/lib/index.min.js +1 -1
- package/package.json +3 -3
- package/src/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +3 -1
- package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +3 -3
- package/src/components/AuthingGuard/GuardLayout/index.tsx +11 -0
- package/src/components/AuthingGuard/LoginLayout/index.tsx +67 -23
- package/src/components/AuthingGuard/api/appConfig.ts +18 -1
- package/src/components/AuthingGuard/api/userPoolConfig.ts +2 -0
- package/src/components/AuthingGuard/style.less +1 -0
- package/src/components/AuthingGuard/types/Forms.ts +1 -0
- package/src/components/AuthingGuard/types/GuardConfig.ts +3 -0
- package/src/index.tsx +16 -5
- package/yarn-error.log +20371 -0
- package/build/asset-manifest.json +0 -26
- package/build/favicon.ico +0 -0
- package/build/index.html +0 -1
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
- package/build/static/css/2.51c07e65.chunk.css +0 -3
- package/build/static/css/2.51c07e65.chunk.css.map +0 -1
- package/build/static/css/main.779f221a.chunk.css +0 -2
- package/build/static/css/main.779f221a.chunk.css.map +0 -1
- package/build/static/js/2.bbae9fdb.chunk.js +0 -3
- package/build/static/js/2.bbae9fdb.chunk.js.LICENSE.txt +0 -102
- package/build/static/js/2.bbae9fdb.chunk.js.map +0 -1
- package/build/static/js/3.fd17f196.chunk.js +0 -2
- package/build/static/js/3.fd17f196.chunk.js.map +0 -1
- package/build/static/js/main.5f341531.chunk.js +0 -2
- package/build/static/js/main.5f341531.chunk.js.map +0 -1
- package/build/static/js/runtime-main.ef138021.js +0 -2
- package/build/static/js/runtime-main.ef138021.js.map +0 -1
- package/build/static/media/loading.4a67a5f3.svg +0 -29
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authing/react-ui-components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.56-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "lib/index.min.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"antd": "^4.8.0",
|
|
9
|
-
"authing-js-sdk": "4.22.
|
|
9
|
+
"authing-js-sdk": "4.22.26-alpha.9",
|
|
10
10
|
"qs": "^6.9.4"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
@@ -185,5 +185,5 @@
|
|
|
185
185
|
"webpack-manifest-plugin": "2.2.0",
|
|
186
186
|
"workbox-webpack-plugin": "5.1.4"
|
|
187
187
|
},
|
|
188
|
-
"gitHead": "
|
|
188
|
+
"gitHead": "7bb7b153c3c4836b084f4cb08fe8124af5d8e5fd"
|
|
189
189
|
}
|
|
@@ -14,6 +14,7 @@ export const QrCodeLoginForm: FC<QrLoginFormProps> = ({
|
|
|
14
14
|
onFail,
|
|
15
15
|
onSuccess,
|
|
16
16
|
type,
|
|
17
|
+
idpId,
|
|
17
18
|
}) => {
|
|
18
19
|
const {
|
|
19
20
|
state: { authClient, config },
|
|
@@ -31,6 +32,7 @@ export const QrCodeLoginForm: FC<QrLoginFormProps> = ({
|
|
|
31
32
|
|
|
32
33
|
useEffect(() => {
|
|
33
34
|
client.startScanning('authingGuardQrcode', {
|
|
35
|
+
extIdpConnId: idpId,
|
|
34
36
|
autoExchangeUserInfo: true,
|
|
35
37
|
...config.qrCodeScanOptions,
|
|
36
38
|
onStart(timer) {
|
|
@@ -46,7 +48,7 @@ export const QrCodeLoginForm: FC<QrLoginFormProps> = ({
|
|
|
46
48
|
},
|
|
47
49
|
})
|
|
48
50
|
return () => clearInterval(timerRef.current)
|
|
49
|
-
}, [client, config.qrCodeScanOptions, onFail, onSuccess])
|
|
51
|
+
}, [client, config.qrCodeScanOptions, idpId, onFail, onSuccess])
|
|
50
52
|
|
|
51
53
|
return (
|
|
52
54
|
<div className="authing-guard-qr-form">
|
|
@@ -218,7 +218,7 @@ export const SocialAndIdpLogin: FC<SocialAndIdpLoginProps> = ({
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
const onLogin = () => {
|
|
221
|
-
authClient.social.authorize(item.
|
|
221
|
+
authClient.social.authorize(item.identifier, {
|
|
222
222
|
onSuccess(user) {
|
|
223
223
|
onSuccess(user)
|
|
224
224
|
},
|
|
@@ -254,12 +254,12 @@ export const SocialAndIdpLogin: FC<SocialAndIdpLoginProps> = ({
|
|
|
254
254
|
}
|
|
255
255
|
onClick={onLogin}
|
|
256
256
|
>
|
|
257
|
-
{item.tooltip?.[i18n.language as Lang] || item.
|
|
257
|
+
{item.tooltip?.[i18n.language as Lang] || item.displayName}
|
|
258
258
|
</Button>
|
|
259
259
|
) : (
|
|
260
260
|
<Tooltip
|
|
261
261
|
key={item.provider}
|
|
262
|
-
title={item.tooltip?.[i18n.language as Lang] || item.
|
|
262
|
+
title={item.tooltip?.[i18n.language as Lang] || item.displayName}
|
|
263
263
|
>
|
|
264
264
|
<div className="authing-social-login-item" onClick={onLogin}>
|
|
265
265
|
<IconFont type={iconType} />
|
|
@@ -156,6 +156,9 @@ const useGuardConfig = () => {
|
|
|
156
156
|
appConfig.loginTabs?.list ||
|
|
157
157
|
defaultGuardConfig.loginMethods
|
|
158
158
|
|
|
159
|
+
// 扫码多源配置
|
|
160
|
+
const qrcodeTabsSettings = appConfig.qrcodeTabsSettings ?? {}
|
|
161
|
+
|
|
159
162
|
// 账密登录的登录拆分
|
|
160
163
|
const passwordLoginMethods =
|
|
161
164
|
userConfig.passwordLoginMethods ||
|
|
@@ -168,6 +171,8 @@ const useGuardConfig = () => {
|
|
|
168
171
|
appConfig.loginTabs?.default ||
|
|
169
172
|
defaultGuardConfig.defaultLoginMethod
|
|
170
173
|
|
|
174
|
+
const loginMethodTitleMapping = appConfig.loginTabs?.title
|
|
175
|
+
|
|
171
176
|
// 注册方式
|
|
172
177
|
const registerMethods =
|
|
173
178
|
userConfig.registerMethods ||
|
|
@@ -233,18 +238,24 @@ const useGuardConfig = () => {
|
|
|
233
238
|
defaultRegisterMethod,
|
|
234
239
|
enterpriseConnectionObjs,
|
|
235
240
|
publicKey: appConfig.publicKey,
|
|
241
|
+
qrcodeTabsSettings,
|
|
236
242
|
agreementEnabled: appConfig.agreementEnabled,
|
|
237
243
|
agreements: appConfig.agreements,
|
|
244
|
+
loginMethodTitleMapping: loginMethodTitleMapping,
|
|
238
245
|
}
|
|
239
246
|
)
|
|
240
247
|
}, [
|
|
241
248
|
userConfig,
|
|
242
249
|
appConfig.loginTabs?.list,
|
|
250
|
+
appConfig.loginTabs?.defaultV2,
|
|
243
251
|
appConfig.loginTabs?.default,
|
|
252
|
+
appConfig.loginTabs?.title,
|
|
253
|
+
appConfig.qrcodeTabsSettings,
|
|
244
254
|
appConfig.passwordTabConfig?.enabledLoginMethods,
|
|
245
255
|
appConfig.registerTabs?.list,
|
|
246
256
|
appConfig.registerTabs?.default,
|
|
247
257
|
appConfig.name,
|
|
258
|
+
appConfig.description,
|
|
248
259
|
appConfig.logo,
|
|
249
260
|
appConfig.ssoPageComponentDisplay?.autoRegisterThenLoginHintInfo,
|
|
250
261
|
appConfig.ssoPageComponentDisplay?.registerBtn,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { message } from 'antd'
|
|
2
2
|
import { User } from 'authing-js-sdk'
|
|
3
3
|
import { FormInstance } from 'antd/lib/form'
|
|
4
|
-
import React, { useCallback, useRef } from 'react'
|
|
4
|
+
import React, { useCallback, useMemo, useRef } from 'react'
|
|
5
5
|
|
|
6
6
|
import { useGuardContext } from '../../../context/global/context'
|
|
7
7
|
import {
|
|
@@ -75,36 +75,36 @@ const useNormalLoginTabs = ({ onSuccess, onFail }: BaseFormProps) => {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
const LOGIN_FORM_MAP = {
|
|
78
|
-
[LoginMethods.Password]: (
|
|
78
|
+
[LoginMethods.Password]: (props: any) => (
|
|
79
79
|
<PasswordLoginForm
|
|
80
|
-
{...
|
|
80
|
+
{...props}
|
|
81
81
|
ref={(v) => (formRef.current[LoginMethods.Password] = v!)}
|
|
82
82
|
/>
|
|
83
83
|
),
|
|
84
|
-
[LoginMethods.PhoneCode]: (
|
|
84
|
+
[LoginMethods.PhoneCode]: (props: any) => (
|
|
85
85
|
<PhoneCodeLoginForm
|
|
86
|
-
{...
|
|
86
|
+
{...props}
|
|
87
87
|
ref={(v) => (formRef.current[LoginMethods.PhoneCode] = v!)}
|
|
88
88
|
/>
|
|
89
89
|
),
|
|
90
|
-
[LoginMethods.AppQr]: (
|
|
91
|
-
<QrCodeLoginForm type={LoginMethods.AppQr} {...
|
|
90
|
+
[LoginMethods.AppQr]: (props: any) => (
|
|
91
|
+
<QrCodeLoginForm type={LoginMethods.AppQr} {...props} />
|
|
92
92
|
),
|
|
93
|
-
[LoginMethods.WxMinQr]: (
|
|
94
|
-
<QrCodeLoginForm type={LoginMethods.WxMinQr} {...
|
|
93
|
+
[LoginMethods.WxMinQr]: (props: any) => (
|
|
94
|
+
<QrCodeLoginForm type={LoginMethods.WxMinQr} {...props} />
|
|
95
95
|
),
|
|
96
|
-
[LoginMethods.LDAP]: (
|
|
96
|
+
[LoginMethods.LDAP]: (props: any) => (
|
|
97
97
|
<LdapLoginForm
|
|
98
|
-
{...
|
|
98
|
+
{...props}
|
|
99
99
|
ref={(v) => (formRef.current[LoginMethods.LDAP] = v!)}
|
|
100
100
|
/>
|
|
101
101
|
),
|
|
102
|
-
[LoginMethods.WechatMpQrcode]: (
|
|
103
|
-
<QrCodeLoginForm type={LoginMethods.WechatMpQrcode} {...
|
|
102
|
+
[LoginMethods.WechatMpQrcode]: (props: any) => (
|
|
103
|
+
<QrCodeLoginForm type={LoginMethods.WechatMpQrcode} {...props} />
|
|
104
104
|
),
|
|
105
|
-
[LoginMethods.AD]: (
|
|
105
|
+
[LoginMethods.AD]: (props: any) => (
|
|
106
106
|
<ADLoginForm
|
|
107
|
-
{...
|
|
107
|
+
{...props}
|
|
108
108
|
ref={(v) => (formRef.current[LoginMethods.AD] = v!)}
|
|
109
109
|
/>
|
|
110
110
|
),
|
|
@@ -113,14 +113,46 @@ const useNormalLoginTabs = ({ onSuccess, onFail }: BaseFormProps) => {
|
|
|
113
113
|
const {
|
|
114
114
|
state: { config },
|
|
115
115
|
} = useGuardContext()
|
|
116
|
-
const {
|
|
116
|
+
const {
|
|
117
|
+
loginMethods = [],
|
|
118
|
+
loginMethodTitleMapping,
|
|
119
|
+
qrcodeTabsSettings,
|
|
120
|
+
} = config
|
|
117
121
|
|
|
118
|
-
|
|
119
|
-
key: item,
|
|
120
|
-
label: LOGIN_METHODS_MAP()?.[item]!,
|
|
121
|
-
component: LOGIN_FORM_MAP[item],
|
|
122
|
-
}))
|
|
122
|
+
let tabs: any[] = []
|
|
123
123
|
|
|
124
|
+
// 兼容 密码登陆 donglyc
|
|
125
|
+
let filterLoginMethods = loginMethods.filter(
|
|
126
|
+
(d) => d.indexOf('password') === -1
|
|
127
|
+
)
|
|
128
|
+
const hasPassword = loginMethods.some((d) => d.indexOf('password') !== -1)
|
|
129
|
+
if (hasPassword) filterLoginMethods.push(LoginMethods.Password)
|
|
130
|
+
|
|
131
|
+
filterLoginMethods.forEach((method: LoginMethods) => {
|
|
132
|
+
if (
|
|
133
|
+
[LoginMethods.WechatMpQrcode, LoginMethods.WxMinQr].includes(method) &&
|
|
134
|
+
qrcodeTabsSettings[method]
|
|
135
|
+
) {
|
|
136
|
+
tabs.push(
|
|
137
|
+
...qrcodeTabsSettings[method].map((idp) => {
|
|
138
|
+
return {
|
|
139
|
+
key: idp.id,
|
|
140
|
+
label: idp.title || loginMethodTitleMapping[method],
|
|
141
|
+
component: LOGIN_FORM_MAP[method]({
|
|
142
|
+
...formProps,
|
|
143
|
+
idp,
|
|
144
|
+
}),
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
} else {
|
|
149
|
+
tabs.push({
|
|
150
|
+
key: method,
|
|
151
|
+
label: LOGIN_METHODS_MAP()[method],
|
|
152
|
+
component: LOGIN_FORM_MAP[method](formProps),
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
})
|
|
124
156
|
return {
|
|
125
157
|
tabs,
|
|
126
158
|
}
|
|
@@ -133,13 +165,25 @@ const SHOW_SOCIAL_LOGIN_TAB = [
|
|
|
133
165
|
]
|
|
134
166
|
export const LoginLayout = () => {
|
|
135
167
|
const {
|
|
136
|
-
state: { activeTabs },
|
|
168
|
+
state: { activeTabs, config },
|
|
137
169
|
setValue,
|
|
138
170
|
} = useGuardContext()
|
|
171
|
+
const { qrcodeTabsSettings } = config
|
|
139
172
|
|
|
140
173
|
const { onFail, onSuccess } = useFormActions()
|
|
141
174
|
const { tabs } = useNormalLoginTabs({ onSuccess, onFail })
|
|
142
175
|
|
|
176
|
+
const activeKey = useMemo(() => {
|
|
177
|
+
const activeTab = activeTabs[GuardScenes.Login]
|
|
178
|
+
if (
|
|
179
|
+
[LoginMethods.WechatMpQrcode, LoginMethods.WxMinQr].includes(activeTab) &&
|
|
180
|
+
qrcodeTabsSettings[activeTab]
|
|
181
|
+
) {
|
|
182
|
+
return qrcodeTabsSettings[activeTab].find((item) => item.isDefault)?.id
|
|
183
|
+
}
|
|
184
|
+
return activeTab
|
|
185
|
+
}, [activeTabs, qrcodeTabsSettings])
|
|
186
|
+
|
|
143
187
|
return (
|
|
144
188
|
<>
|
|
145
189
|
<AuthingTabs
|
|
@@ -150,7 +194,7 @@ export const LoginLayout = () => {
|
|
|
150
194
|
[GuardScenes.Login]: t,
|
|
151
195
|
})
|
|
152
196
|
}
|
|
153
|
-
activeKey={
|
|
197
|
+
activeKey={activeKey}
|
|
154
198
|
/>
|
|
155
199
|
|
|
156
200
|
{SHOW_SOCIAL_LOGIN_TAB.includes(activeTabs[GuardScenes.Login]) && (
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { requestClient } from './http'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Lang,
|
|
4
|
+
LoginMethods,
|
|
5
|
+
Protocol,
|
|
6
|
+
} from '../../../components/AuthingGuard/types'
|
|
3
7
|
import {
|
|
4
8
|
IAzureAdConnectionConfig,
|
|
5
9
|
ICasConnectionConfig,
|
|
@@ -25,6 +29,15 @@ export const ApplicationMfaTypeLabel: () => Record<
|
|
|
25
29
|
[ApplicationMfaType.EMAIL]: i18n.t('common.EmailVerification'),
|
|
26
30
|
})
|
|
27
31
|
|
|
32
|
+
export type QrcodeTabsSettings = Record<
|
|
33
|
+
LoginMethods,
|
|
34
|
+
Array<{
|
|
35
|
+
id: string
|
|
36
|
+
title: string
|
|
37
|
+
isDefault?: boolean
|
|
38
|
+
}>
|
|
39
|
+
>
|
|
40
|
+
|
|
28
41
|
export interface OidcClientMetadata {
|
|
29
42
|
grant_types: string[]
|
|
30
43
|
client_id: string
|
|
@@ -83,9 +96,13 @@ export interface ApplicationConfig {
|
|
|
83
96
|
default: string
|
|
84
97
|
title: { [x: string]: string }
|
|
85
98
|
}
|
|
99
|
+
|
|
100
|
+
qrcodeTabsSettings: QrcodeTabsSettings
|
|
101
|
+
|
|
86
102
|
loginTabs: {
|
|
87
103
|
list: string[]
|
|
88
104
|
default: string
|
|
105
|
+
defaultV2?: string
|
|
89
106
|
title: { [x: string]: string }
|
|
90
107
|
}
|
|
91
108
|
socialConnections: SocialConnectionItem[]
|
|
@@ -72,8 +72,10 @@ export interface ICasConnectionConfig {
|
|
|
72
72
|
}
|
|
73
73
|
export interface SocialConnectionItem {
|
|
74
74
|
name: string
|
|
75
|
+
displayName: string
|
|
75
76
|
logo: string
|
|
76
77
|
description: string
|
|
78
|
+
identifier: string
|
|
77
79
|
provider: SocialConnectionProvider
|
|
78
80
|
authorizationUrl: string
|
|
79
81
|
tooltip: Record<Lang, string>
|
|
@@ -27,6 +27,7 @@ export interface LdapLoginFormProps extends BaseFormProps {
|
|
|
27
27
|
|
|
28
28
|
export interface QrLoginFormProps extends BaseFormProps {
|
|
29
29
|
type: LoginMethods.AppQr | LoginMethods.WxMinQr | LoginMethods.WechatMpQrcode
|
|
30
|
+
idpId?: string
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export interface EmailRegisterFormProps extends BaseFormProps {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
ApplicationConfig,
|
|
14
14
|
PasswordLoginMethods,
|
|
15
15
|
Agreement,
|
|
16
|
+
QrcodeTabsSettings,
|
|
16
17
|
} from '../../../components/AuthingGuard/api'
|
|
17
18
|
import { Lang } from './Locales'
|
|
18
19
|
|
|
@@ -412,6 +413,8 @@ export interface GuardConfig extends UserConfig {
|
|
|
412
413
|
publicKey: ApplicationConfig['publicKey']
|
|
413
414
|
agreementEnabled: boolean
|
|
414
415
|
agreements: Agreement[]
|
|
416
|
+
loginMethodTitleMapping: Record<string, string>
|
|
417
|
+
qrcodeTabsSettings: QrcodeTabsSettings
|
|
415
418
|
}
|
|
416
419
|
|
|
417
420
|
export interface LocalesConfig {
|
package/src/index.tsx
CHANGED
|
@@ -4,6 +4,8 @@ import ReactDOM from 'react-dom'
|
|
|
4
4
|
import { Lang } from './components'
|
|
5
5
|
import { AuthingGuard } from './components/AuthingGuard'
|
|
6
6
|
|
|
7
|
+
import { SocialConnectionProvider } from 'authing-js-sdk'
|
|
8
|
+
|
|
7
9
|
import {
|
|
8
10
|
GuardMode,
|
|
9
11
|
// LoginMethods,
|
|
@@ -21,8 +23,9 @@ const App = () => {
|
|
|
21
23
|
|
|
22
24
|
const config: UserConfig = {
|
|
23
25
|
mode: GuardMode.Modal,
|
|
24
|
-
appHost: 'https://core.dev2.authing-inc.co
|
|
25
|
-
|
|
26
|
+
// appHost: 'https://core.dev2.authing-inc.co',
|
|
27
|
+
apiHost: 'http://console.authing.localhost:3000',
|
|
28
|
+
// appHost: 'http://0w9ugz.authing.localhost:3000',
|
|
26
29
|
// apiHost: 'http://192.168.50.57:3000',
|
|
27
30
|
// loginMethods: Object.values(LoginMethods),
|
|
28
31
|
// logo:
|
|
@@ -53,7 +56,7 @@ const App = () => {
|
|
|
53
56
|
// }
|
|
54
57
|
// `,
|
|
55
58
|
// // autoRegister: true,
|
|
56
|
-
|
|
59
|
+
socialConnections: [SocialConnectionProvider.WECHATPC],
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
const [visible, setVisible] = useState(false)
|
|
@@ -70,6 +73,14 @@ const App = () => {
|
|
|
70
73
|
return (
|
|
71
74
|
// eslint-disable-next-line react/jsx-no-undef
|
|
72
75
|
<>
|
|
76
|
+
<Button
|
|
77
|
+
type="primary"
|
|
78
|
+
onClick={() => {
|
|
79
|
+
//
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
add socialConnections
|
|
83
|
+
</Button>
|
|
73
84
|
<Button
|
|
74
85
|
type="primary"
|
|
75
86
|
onClick={() => {
|
|
@@ -114,8 +125,8 @@ const App = () => {
|
|
|
114
125
|
}}
|
|
115
126
|
// onLoad={(a) => console.log(a, '加载完成')}
|
|
116
127
|
// onPwdResetError={(e) => console.log(e)}
|
|
117
|
-
appId="
|
|
118
|
-
tenantId="
|
|
128
|
+
appId="61ada57aef5ed526528ed5b6"
|
|
129
|
+
// tenantId="61a5ed126cddae656cce9007"
|
|
119
130
|
// appId="5fd877fb0ba0421962eced94"
|
|
120
131
|
config={config}
|
|
121
132
|
/>
|