yuang-framework-ui-common 1.0.82 → 1.0.83
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/utils/ssoUtils.ts +30 -0
- package/package.json +1 -1
package/lib/utils/ssoUtils.ts
CHANGED
@@ -6,6 +6,10 @@ import { getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem } from
|
|
6
6
|
import { application } from '../config/applicationConfig';
|
7
7
|
|
8
8
|
|
9
|
+
/**
|
10
|
+
* 获取sso登录地址
|
11
|
+
* @param ssoRedirectUrl
|
12
|
+
*/
|
9
13
|
const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
10
14
|
let gatewayServerBaseUrl = application.gatewayServerBaseUrl;
|
11
15
|
if (!gatewayServerBaseUrl) {
|
@@ -23,6 +27,31 @@ const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
|
23
27
|
return ssoLoginUrl;
|
24
28
|
}
|
25
29
|
|
30
|
+
/**
|
31
|
+
* 获取sso认证地址
|
32
|
+
* @param ssoRedirectUrl
|
33
|
+
*/
|
34
|
+
const getSsoAuthUrl = (ssoRedirectUrl = '') => {
|
35
|
+
let gatewayServerBaseUrl = application.gatewayServerBaseUrl;
|
36
|
+
if (!gatewayServerBaseUrl) {
|
37
|
+
throw new Error('参数[gatewayServerBaseUrl]为空');
|
38
|
+
}
|
39
|
+
if (!isFullUrl(gatewayServerBaseUrl)) {
|
40
|
+
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
41
|
+
}
|
42
|
+
let ssoAuthUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/auth`;
|
43
|
+
if (!ssoRedirectUrl) {
|
44
|
+
ssoAuthUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
45
|
+
} else {
|
46
|
+
ssoAuthUrl += `?ssoRedirectUrl=${encodeURIComponent(ssoRedirectUrl)}`;
|
47
|
+
}
|
48
|
+
return ssoAuthUrl;
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* 获取sso注销地址
|
53
|
+
* @param ssoRedirectUrl
|
54
|
+
*/
|
26
55
|
const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
27
56
|
let gatewayServerBaseUrl = application.gatewayServerBaseUrl;
|
28
57
|
if (!gatewayServerBaseUrl) {
|
@@ -169,6 +198,7 @@ const logoutSso = () => {
|
|
169
198
|
|
170
199
|
export {
|
171
200
|
getSsoLoginUrl,
|
201
|
+
getSsoAuthUrl,
|
172
202
|
getSsoLogoutUrl,
|
173
203
|
getSsoAuthRoutePath,
|
174
204
|
|