Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: new login page with GitLab login button (#359)

Luke Zhou7f528acd7c0f
diff --git a/api/auth.go b/api/auth.go
index bb47840aa3..a49937e9cc 100644
--- a/api/auth.go
+++ b/api/auth.go
@@ -3,9 +3,10 @@ package api
import "github.com/bytebase/bytebase/plugin/vcs"
type AuthProvider struct {
- Type *vcs.Type `jsonapi:"attr,type"`
- InstanceURL string `jsonapi:"attr,instanceUrl"`
- ApplicationID string `jsonapi:"attr,applicationId"`
+ Type vcs.Type `jsonapi:"attr,type"`
+ Name string `jsonapi:"attr,name"`
+ InstanceURL string `jsonapi:"attr,instanceUrl"`
+ ApplicationID string `jsonapi:"attr,applicationId"`
// Secret will be used for OAuth on the client side when user choose to login via Gitlab
Secret string `jsonapi:"attr,secret"`
}
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index 7c066a311a..77c79ca4ba 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -155,6 +155,7 @@ common:
by: by
ok: OK
share: Share
+ or: or
error-page:
go-back-home: Go back home
anomaly-center: Anomaly Center
@@ -578,6 +579,7 @@ auth:
forget-password: Forgot your password?
new-user: New to Bytebase?
third-party: You can reach to your Admin to enable third party login.
+ gitlab: Login with GitLab
password-forget:
title: Forgot your password?
content: Please contact your Bytebase Admin to reset your password.
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index fe12cd34dd..a0b8ff5d79 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -155,6 +155,7 @@ common:
by: 由
ok: OK
share: 分享
+ or: 或者
error-page:
go-back-home: 回到主页
anomaly-center: 异常中心
@@ -525,6 +526,7 @@ auth:
forget-password: 忘记密码?
new-user: 第一次使用 Bytebase?
third-party: 您可联系管理员开启第三方认证登录
+ gitlab: 通过 GitLab 登录
password-forget:
title: 忘记了您的密码?
content: 请联系的您的 Bytebase 管理员重置密码
diff --git a/frontend/src/types/auth.ts b/frontend/src/types/auth.ts
index cee794234e..aeaf28cb8c 100644
--- a/frontend/src/types/auth.ts
+++ b/frontend/src/types/auth.ts
@@ -28,6 +28,7 @@ export type BytebaseLoginInfo = {
export type AuthProvider = {
type: AuthProviderType;
+ name: string;
instanceUrl: string;
applicationId: string;
secret: string;
@@ -35,6 +36,7 @@ export type AuthProvider = {
export const EmptyAuthProvider: AuthProvider = {
type: "BYTEBASE",
+ name: "",
instanceUrl: "",
applicationId: "",
secret: "",
diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vue
index b917ddaa92..5ed7888750 100644
--- a/frontend/src/views/auth/Signin.vue
+++ b/frontend/src/views/auth/Signin.vue
@@ -6,19 +6,64 @@
src="../../assets/logo-full.svg"
alt="Bytebase"
/>
- <h2 class="mt-6 text-3xl leading-9 font-extrabold text-main">
- {{ $t("auth.sign-in.title") }}
- </h2>
- <h2
- v-if="authProviderList.length == 0"
- class="text-gray-500 leading-4 tracking-wide font-light text-sm"
+ </div>
+
+ <div class="mt-8 mb-3">
+ <template
+ v-for="authProvider in authProviderList"
+ :key="authProvider.type"
>
- {{ $t("auth.sign-in.third-party") }}
- </h2>
+ <n-button
+ class="w-full h-10 mb-2"
+ @click.prevent="
+ () => {
+ state.activeAuthProvider = authProvider;
+ const window = openWindowForOAuth(
+ `${authProvider.instanceUrl}/${
+ AuthProviderConfig[authProvider.type].apiPath
+ }`,
+ authProvider.applicationId,
+ 'login'
+ );
+ }
+ "
+ >
+ <img
+ class="w-5 mr-1"
+ :src="AuthProviderConfig[authProvider.type].iconPath"
+ /><span class="text-center font-semibold align-middle">{{
+ authProviderList.length == 1
+ ? $t("auth.sign-in.gitlab")
+ : authProvider.name
+ }}</span>
+ </n-button>
+ </template>
+
+ <template v-if="authProviderList.length == 0">
+ <n-button class="w-full h-10 mb-2" disabled>
+ <img
+ class="w-5 mr-1"
+ :src="AuthProviderConfig['GITLAB_SELF_HOST'].iconPath"
+ /><span class="text-center font-semibold align-middle">
+ {{ $t("auth.sign-in.third-party") }}
+ </span>
+ </n-button>
+ </template>
+ </div>
+
+ <div class="relative">
+ <div class="absolute inset-0 flex items-center" aria-hidden="true">
+ <div class="w-full border-t border-control-border"></div>
+ </div>
+ <div class="relative flex justify-center text-sm">
+ <span class="px-2 bg-white text-control">
+ {{ $t("common.or") }}
+ </span>
+ </div>
</div>
- <div class="mt-4">
- <div class="mt-4">
+ <div class="mt-2">
+ <div class="mt-2">
<form class="space-y-6" @submit.prevent="trySignin">
<div>
<label
@@ -75,35 +120,6 @@
>
{{ $t("common.sign-in") }}
</button>
-
- <template
- v-for="authProvider in authProviderList"
- :key="authProvider.type"
- >
- <!-- GitLab auth provider -->
- <n-button
- circle
- quaternary
- :bordered="false"
- @click.prevent="
- () => {
- state.activeAuthProvider = authProvider;
- const window = openWindowForOAuth(
- `${authProvider.instanceUrl}/${
- AuthProviderConfig[authProvider.type].apiPath
- }`,
- authProvider.applicationId,
- 'login'
- );
- }
- "
- >
- <img
- class="w-4"
- :src="AuthProviderConfig[authProvider.type].iconPath"
- />
- </n-button>
- </template>
</span>
</div>
</form>
@@ -111,9 +127,6 @@
</div>
<div class="mt-6 relative">
- <div class="absolute inset-0 flex items-center" aria-hidden="true">
- <div class="w-full border-t border-control-border"></div>
- </div>
<div class="relative flex justify-center text-sm">
<span class="pl-2 bg-white text-control">
{{ $t("auth.sign-in.new-user") }}
diff --git a/server/auth.go b/server/auth.go
index 7c485e28b8..59840f2368 100644
--- a/server/auth.go
+++ b/server/auth.go
@@ -28,7 +28,8 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
authProvider := make([]*api.AuthProvider, 0)
for _, vcs := range list {
newProvider := &api.AuthProvider{
- Type: &vcs.Type,
+ Type: vcs.Type,
+ Name: vcs.Name,
InstanceURL: vcs.InstanceURL,
ApplicationID: vcs.ApplicationID,
Secret: vcs.Secret,