yuang-framework-ui-common 1.0.97 → 1.0.98
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
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Cookies from 'js-cookie'
|
|
2
2
|
import { getAesRandomKey, aesEncrypt } from './aesUtils';
|
|
3
3
|
import { rsaEncrypt } from './rsaUtils';
|
|
4
|
-
import { isFullUrl } from './urlUtils';
|
|
5
4
|
import { getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem } from './storageUtils';
|
|
6
5
|
import { application } from '../config/applicationConfig';
|
|
7
6
|
import { getIsDebug } from '../utils/htmlUtils';
|
|
@@ -20,9 +19,6 @@ const getSsoLoginUrl = (ssoRedirectUrl = '') => {
|
|
|
20
19
|
if (!gatewayServerBaseUrl) {
|
|
21
20
|
throw new Error('参数[gatewayServerBaseUrl]为空');
|
|
22
21
|
}
|
|
23
|
-
if (!isFullUrl(gatewayServerBaseUrl)) {
|
|
24
|
-
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
|
25
|
-
}
|
|
26
22
|
let ssoLoginUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/login`;
|
|
27
23
|
if (!ssoRedirectUrl) {
|
|
28
24
|
ssoLoginUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
|
@@ -44,9 +40,6 @@ const getSsoAuthUrl = (ssoRedirectUrl = '') => {
|
|
|
44
40
|
if (!gatewayServerBaseUrl) {
|
|
45
41
|
throw new Error('参数[gatewayServerBaseUrl]为空');
|
|
46
42
|
}
|
|
47
|
-
if (!isFullUrl(gatewayServerBaseUrl)) {
|
|
48
|
-
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
|
49
|
-
}
|
|
50
43
|
let ssoAuthUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/auth`;
|
|
51
44
|
if (!ssoRedirectUrl) {
|
|
52
45
|
ssoAuthUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
|
@@ -68,9 +61,6 @@ const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
|
|
68
61
|
if (!gatewayServerBaseUrl) {
|
|
69
62
|
throw new Error('参数[gatewayServerBaseUrl]为空');
|
|
70
63
|
}
|
|
71
|
-
if (!isFullUrl(gatewayServerBaseUrl)) {
|
|
72
|
-
throw new Error('参数[gatewayServerBaseUrl]必须是完整路径');
|
|
73
|
-
}
|
|
74
64
|
let ssoLogoutUrl = `${gatewayServerBaseUrl}/sso-api/server/sso/logout`;
|
|
75
65
|
if (!ssoRedirectUrl) {
|
|
76
66
|
ssoLogoutUrl += `?ssoRedirectUrl=${encodeURIComponent(window.location.href)}`;
|
|
@@ -79,26 +69,6 @@ const getSsoLogoutUrl = (ssoRedirectUrl = '') => {
|
|
|
79
69
|
}
|
|
80
70
|
return ssoLogoutUrl;
|
|
81
71
|
}
|
|
82
|
-
//
|
|
83
|
-
// /**
|
|
84
|
-
// * 获取sso认证路由路径
|
|
85
|
-
// * @param ssoRedirectRoutePath
|
|
86
|
-
// */
|
|
87
|
-
// const getSsoAuthRoutePath = (ssoRedirectRoutePath = '') => {
|
|
88
|
-
// if(getIsDebug()) {
|
|
89
|
-
// debugger;
|
|
90
|
-
// }
|
|
91
|
-
// let ssoAuthRoutePath = '/sso/client/sso-auth/index';
|
|
92
|
-
// if (!ssoRedirectRoutePath) {
|
|
93
|
-
// ssoAuthRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent('/sso/client/sso-auth/auth-success')}`;
|
|
94
|
-
// } else {
|
|
95
|
-
// ssoAuthRoutePath += `?ssoRedirectRoutePath=${encodeURIComponent(ssoRedirectRoutePath)}`;
|
|
96
|
-
// }
|
|
97
|
-
// if(getIsDebug()) {
|
|
98
|
-
// console.log('ssoAuthRoutePath', ssoAuthRoutePath);
|
|
99
|
-
// }
|
|
100
|
-
// return ssoAuthRoutePath;
|
|
101
|
-
// }
|
|
102
72
|
|
|
103
73
|
/**
|
|
104
74
|
* 处理sso认证
|
|
@@ -257,7 +227,6 @@ export {
|
|
|
257
227
|
getSsoLoginUrl,
|
|
258
228
|
getSsoAuthUrl,
|
|
259
229
|
getSsoLogoutUrl,
|
|
260
|
-
// getSsoAuthRoutePath,
|
|
261
230
|
handleSsoAuth,
|
|
262
231
|
|
|
263
232
|
getSsoEncrypt,
|
package/package.json
CHANGED
package/src/router/index.ts
CHANGED
|
@@ -7,13 +7,6 @@ import { handleSsoAuth } from '../../lib/utils/ssoUtils';
|
|
|
7
7
|
const router = createRouter({
|
|
8
8
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
9
9
|
routes: [
|
|
10
|
-
{
|
|
11
|
-
path: '/sso/client/sso-auth/auth-success',
|
|
12
|
-
component: () => import('@/views/sso/client/sso-auth/auth-success.vue'),
|
|
13
|
-
meta: {
|
|
14
|
-
title: '认证成功',
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
10
|
{
|
|
18
11
|
path: '/gateway/gateway-config',
|
|
19
12
|
component: () => import('@/views/gateway/gateway-config.vue')
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<h1>认证成功! {{ ssoData?.ssoTokenUser?.account }}</h1>
|
|
3
|
-
|
|
4
|
-
<h3 @click="getSsoTokenUser">获取ssoTokenUser</h3>
|
|
5
|
-
<h3 @click="getSsoIdentity">获取SsoIdentity</h3>
|
|
6
|
-
|
|
7
|
-
<a @click="logout">注销登录</a>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script setup lang="ts">
|
|
11
|
-
import { onMounted, reactive } from 'vue';
|
|
12
|
-
import { ElMessage } from 'element-plus/es';
|
|
13
|
-
|
|
14
|
-
import { getSsoAccessToken, logoutSso } from '../../../../lib/utils/ssoUtils';
|
|
15
|
-
import { http } from '../../../../lib/config/httpConfig';
|
|
16
|
-
|
|
17
|
-
let ssoData = reactive({
|
|
18
|
-
ssoTokenUser: {},
|
|
19
|
-
ssoIdentity: {}
|
|
20
|
-
});
|
|
21
|
-
onMounted(() => {
|
|
22
|
-
let ssoAccessToken = getSsoAccessToken();
|
|
23
|
-
console.log('ssoAccessToken', ssoAccessToken);
|
|
24
|
-
getSsoTokenUser();
|
|
25
|
-
});
|
|
26
|
-
const getSsoTokenUser = () => {
|
|
27
|
-
http.get(`/sso-api/client/sso-user/getSsoTokenUser`).then((res: any) => {
|
|
28
|
-
ssoData.ssoTokenUser = res.data.data;
|
|
29
|
-
console.log('ssoTokenUser', ssoData.ssoTokenUser);
|
|
30
|
-
ElMessage.success('获取成功');
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
const getSsoIdentity = () => {
|
|
34
|
-
http.get(`/sso-api/client/sso-user/getSsoIdentity`).then((res: any) => {
|
|
35
|
-
ssoData.ssoIdentity = res.data.data;
|
|
36
|
-
console.log('ssoIdentity', ssoData.ssoIdentity);
|
|
37
|
-
ElMessage.success('获取成功');
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const logout = () => {
|
|
42
|
-
logoutSso();
|
|
43
|
-
};
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<style scoped></style>
|