diff --git a/deploy/kubernetes/service.yaml b/deploy/kubernetes/service.yaml
deleted file mode 100644
index 6b797c05..00000000
--- a/deploy/kubernetes/service.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- labels:
- app: zhishuyun-auth-frontend
- name: zhishuyun-auth-frontend
- namespace: zhishuyun
-spec:
- ports:
- - name: '8083'
- port: 8083
- targetPort: 80
- selector:
- app: zhishuyun-auth-frontend
diff --git a/deploy/kubernetes/deployment.yaml b/deploy/test/deployment.yaml
similarity index 61%
rename from deploy/kubernetes/deployment.yaml
rename to deploy/test/deployment.yaml
index d90c8c7d..a4d2739d 100644
--- a/deploy/kubernetes/deployment.yaml
+++ b/deploy/test/deployment.yaml
@@ -2,23 +2,23 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
- app: zhishuyun-auth-frontend
- name: zhishuyun-auth-frontend
- namespace: zhishuyun
+ app: zhishuyun-academy-frontend
+ name: zhishuyun-academy-frontend
+ namespace: zhishuyun-test
spec:
- replicas: 2
+ replicas: 1
revisionHistoryLimit: 5
selector:
matchLabels:
- app: zhishuyun-auth-frontend
+ app: zhishuyun-academy-frontend
template:
metadata:
labels:
- app: zhishuyun-auth-frontend
+ app: zhishuyun-academy-frontend
spec:
containers:
- - image: ghcr.io/zhishuyun/zhishuyun-auth-frontend:${TAG}
- name: zhishuyun-auth-frontend
+ - image: ghcr.io/zhishuyun/zhishuyun-academy-frontend:${TAG}
+ name: zhishuyun-academy-frontend
ports:
- containerPort: 80
resources:
diff --git a/deploy/kubernetes/ingress.yaml b/deploy/test/ingress.yaml
similarity index 58%
rename from deploy/kubernetes/ingress.yaml
rename to deploy/test/ingress.yaml
index 66a8e2b1..51c3cfd9 100644
--- a/deploy/kubernetes/ingress.yaml
+++ b/deploy/test/ingress.yaml
@@ -1,8 +1,8 @@
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
- name: ingress-zhishuyun-auth-frontend
- namespace: zhishuyun
+ name: ingress-zhishuyun-academy-frontend
+ namespace: zhishuyun-test
annotations:
kubernetes.io/ingress.class: 'nginx'
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
@@ -10,13 +10,13 @@ metadata:
spec:
tls:
- hosts:
- - auth.zhishuyun.com
- secretName: tls-auth-zhishuyun-com
+ - academy.test.zhishuyun.com
+ secretName: tls-wildcard-test-zhishuyun-com
rules:
- - host: auth.zhishuyun.com
+ - host: academy.test.zhishuyun.com
http:
paths:
- backend:
- serviceName: zhishuyun-auth-frontend
+ serviceName: zhishuyun-academy-frontend
servicePort: 8083
path: /
diff --git a/deploy/test/service.yaml b/deploy/test/service.yaml
new file mode 100644
index 00000000..b3658e96
--- /dev/null
+++ b/deploy/test/service.yaml
@@ -0,0 +1,14 @@
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ app: zhishuyun-academy-frontend
+ name: zhishuyun-academy-frontend
+ namespace: zhishuyun-test
+spec:
+ ports:
+ - name: '8083'
+ port: 8083
+ targetPort: 80
+ selector:
+ app: zhishuyun-academy-frontend
diff --git a/package.json b/package.json
index d4623eaa..a4e459d1 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"element-plus": "^1.3.0-beta.10",
"humps": "^2.0.1",
"qrcode.vue": "3.3.0",
+ "typescript-cookie": "^1.0.3",
"vue": "^3.2.6",
"vue-i18n": "^9.1.7",
"vue-router": "^4.0.11",
diff --git a/src/pages/auth/Callback.vue b/src/pages/auth/Callback.vue
new file mode 100644
index 00000000..7440ef0e
--- /dev/null
+++ b/src/pages/auth/Callback.vue
@@ -0,0 +1,49 @@
+
+
+
+
+
+
diff --git a/src/pages/auth/Login.vue b/src/pages/auth/Login.vue
index 3228a526..9e68298a 100644
--- a/src/pages/auth/Login.vue
+++ b/src/pages/auth/Login.vue
@@ -5,8 +5,6 @@
import { defineComponent } from 'vue';
interface IData {
- accessToken: string | undefined;
- refreshToken: string | undefined;
redirect: string | undefined;
}
@@ -14,23 +12,17 @@ export default defineComponent({
name: 'Login',
data(): IData {
return {
- accessToken: this.$route.query['access-token']?.toString(),
- refreshToken: this.$route.query['refresh-token']?.toString(),
redirect: this.$route.query.redirect?.toString()
};
},
async mounted() {
- if (this.accessToken && this.refreshToken) {
- await this.$store.dispatch('setAccessToken', this.accessToken);
- await this.$store.dispatch('setRefreshToken', this.refreshToken);
- if (this.redirect) {
- this.$router.push(this.redirect);
- }
- } else {
- const currentUrl = window.location.href;
- const targetUrl = `https://auth.zhishuyun.com?redirect=${currentUrl}`;
- window.location.href = targetUrl;
- }
+ const host = window.location.host;
+ const subDomain = host.substring(host.indexOf('.') + 1);
+ // callback url used to init access token and then redirect back of `redirect`
+ const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
+ // redirect to auth service to get access token then redirect back
+ const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
+ window.location.href = targetUrl;
},
methods: {}
});
diff --git a/src/router/auth.ts b/src/router/auth.ts
index 1602dcff..730692eb 100644
--- a/src/router/auth.ts
+++ b/src/router/auth.ts
@@ -10,11 +10,19 @@ export default {
children: [
{
path: 'login',
- name: 'login',
+ name: 'auth-login',
meta: {
title: t('common.nav.article')
},
component: () => import('@/pages/auth/Login.vue')
+ },
+ {
+ path: 'callback',
+ name: 'auth-callback',
+ meta: {
+ title: t('common.nav.article')
+ },
+ component: () => import('@/pages/auth/Callback.vue')
}
]
};
diff --git a/yarn.lock b/yarn.lock
index 3a23bd38..15406651 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2258,6 +2258,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
+typescript-cookie@^1.0.3:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/typescript-cookie/-/typescript-cookie-1.0.3.tgz#fa036aac4937ee528258035b7495a7813a7656d5"
+ integrity sha512-eGu8HYw2oI+NXV7JJ1QDFi02EWYTl8zENevq5kSI3JcAdCxtUvjW6Nj5Mjrej83/oK8O/5OyRDuivhSFU49GcA==
+
typescript@^4.3.2:
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"