Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: introduce disallow-signup flag (#4643)
ecmadaoebe2bb804e7c
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.goindex b6b4af2f3d..8af2a5a06c 100644--- a/backend/api/v1/auth_service.go+++ b/backend/api/v1/auth_service.go@@ -79,6 +79,9 @@ func (s *AuthService) ListUsers(ctx context.Context, request *v1pb.ListUsersRequ// CreateUser creates a user.func (s *AuthService) CreateUser(ctx context.Context, request *v1pb.CreateUserRequest) (*v1pb.User, error) {+ if s.profile.DisallowSignup {+ return nil, status.Errorf(codes.PermissionDenied, "sign up is disallowed")+ }if request.User == nil {return nil, status.Errorf(codes.InvalidArgument, "user must be set")}diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.goindex fc51f18915..e828e68ab4 100644--- a/backend/bin/server/cmd/profile.go+++ b/backend/bin/server/cmd/profile.go@@ -23,6 +23,7 @@ func getBaseProfile(dataDir string) config.Profile {ResourceDir: common.GetResourceDir(dataDir),Debug: flags.debug,DemoName: flags.demoName,+ DisallowSignup: flags.disallowSignup,Version: version,GitCommit: gitcommit,PgURL: flags.pgURL,diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.goindex ddacb0444e..4894115a05 100644--- a/backend/bin/server/cmd/root.go+++ b/backend/bin/server/cmd/root.go@@ -76,6 +76,8 @@ var (// empty means no demo.demoName stringdebug bool+ // disallowSignup will disallow the sign up, users can only be invited by the owner.+ disallowSignup bool// pgURL must follow PostgreSQL connection URIs pattern.// https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRINGpgURL string@@ -122,6 +124,8 @@ func init() {// Must be one of the subpath name in the ./store/demo/ directoryrootCmd.PersistentFlags().StringVar(&flags.demoName, "demo", "", "name of the demo to use. Empty means not running in demo mode.")rootCmd.PersistentFlags().BoolVar(&flags.debug, "debug", false, "whether to enable debug level logging")+ // Disallow signup+ rootCmd.PersistentFlags().BoolVar(&flags.disallowSignup, "disallow-signup", false, "whether to disallow the sign up")// Support environment variable for deploying to render.com using its blueprint file.// Render blueprint allows to specify a postgres database along with a service.// It allows to pass the postgres connection string as an ENV to the service.diff --git a/backend/component/config/profile.go b/backend/component/config/profile.goindex 7c2c6d4558..74e85aea5a 100644--- a/backend/component/config/profile.go+++ b/backend/component/config/profile.go@@ -37,6 +37,8 @@ type Profile struct {Debug bool// DemoName specifies the demo name. Empty string means no demo.DemoName string+ // DisallowSignup will disallow the sign up, users can only be invited by the owner.+ DisallowSignup bool// AppRunnerInterval is the interval for application runner.AppRunnerInterval time.Duration// BackupRunnerInterval is the interval for backup runner.diff --git a/backend/legacyapi/actuator.go b/backend/legacyapi/actuator.goindex 9abcea0c83..76acb0549d 100644--- a/backend/legacyapi/actuator.go+++ b/backend/legacyapi/actuator.go@@ -11,6 +11,7 @@ type ServerInfo struct {Port string `json:"port"`ExternalURL string `json:"externalUrl"`NeedAdminSetup bool `json:"needAdminSetup"`+ DisallowSignup bool `json:"disallowSignup"`// Rand may be based on the server start time, thus exposing startedTs to the client may cause security issues (e.g. jwt key is based on Rand).// StartedTs int64 `json:"startedTs"`}diff --git a/backend/server/actuator.go b/backend/server/actuator.goindex 07eb9167ac..d56627b78b 100644--- a/backend/server/actuator.go+++ b/backend/server/actuator.go@@ -14,11 +14,12 @@ func (s *Server) registerActuatorRoutes(g *echo.Group) {ctx := c.Request().Context()serverInfo := api.ServerInfo{- Version: s.profile.Version,- GitCommit: s.profile.GitCommit,- Readonly: s.profile.Readonly,- DemoName: s.profile.DemoName,- ExternalURL: s.profile.ExternalURL,+ Version: s.profile.Version,+ GitCommit: s.profile.GitCommit,+ Readonly: s.profile.Readonly,+ DemoName: s.profile.DemoName,+ ExternalURL: s.profile.ExternalURL,+ DisallowSignup: s.profile.DisallowSignup,}findRole := api.Ownerdiff --git a/backend/server/auth.go b/backend/server/auth.goindex 807b0ac5bb..05216639e1 100644--- a/backend/server/auth.go+++ b/backend/server/auth.go@@ -129,6 +129,9 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {// Create a new user if not existif user == nil {+ if s.profile.DisallowSignup {+ return echo.NewHTTPError(http.StatusForbidden, "Sign up is disallowed")+ }if userInfo.PublicEmail == "" {profileLink := "https://docs.github.com/en/account-and-profile"if authProvider == api.PrincipalAuthProviderGitlabSelfHost {diff --git a/backend/server/server.go b/backend/server/server.goindex 8a7f0aec39..1897e07810 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -211,6 +211,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {log.Info(fmt.Sprintf("readonly=%t", profile.Readonly))log.Info(fmt.Sprintf("debug=%t", profile.Debug))log.Info(fmt.Sprintf("demoName=%s", profile.DemoName))+ log.Info(fmt.Sprintf("disallowSignup=%t", profile.DisallowSignup))log.Info(fmt.Sprintf("backupStorageBackend=%s", profile.BackupStorageBackend))log.Info(fmt.Sprintf("backupBucket=%s", profile.BackupBucket))log.Info(fmt.Sprintf("backupRegion=%s", profile.BackupRegion))diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 19412a0595..8f32445155 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1308,7 +1308,9 @@"secret-label-gitlab": "Secret for the registered GitLab instance-wide OAuth application.","github-application-id-label": "Client ID for the registered GitHub organization-wide OAuth application.","secret-label-github": "Client secret for the registered GitHub organization-wide OAuth application.",- "delete": "To delete this provider, unlink all repositories first."+ "delete-forbidden": "To delete this provider, unlink all repositories first.",+ "delete": "Delete this Git provider",+ "delete-confirm": "Delete Git provider \"{name}\"?"}}},diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 8956101e4a..fff06cfcd2 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1308,7 +1308,9 @@"secret-label-gitlab": "注册为 GitLab 实例级 OAuth 应用的 Secret。","github-application-id-label": "注册为 GitHub 组织级别 OAuth 应用的 Client ID。","secret-label-github": "注册为 GitHub 组织级别 OAuth 应用的 Client secret。",- "delete": "删除这个提供方前,需要先解除所有仓库的关联。"+ "delete-forbidden": "删除这个提供方前,需要先解除所有仓库的关联。",+ "delete": "删除 Git 提供方",+ "delete-confirm": "删除 Git 提供方 \"{name}\"?"}}},diff --git a/frontend/src/store/modules/actuator.ts b/frontend/src/store/modules/actuator.tsindex 6c8ccb1b28..b76396d607 100644--- a/frontend/src/store/modules/actuator.ts+++ b/frontend/src/store/modules/actuator.ts@@ -39,6 +39,9 @@ export const useActuatorStore = defineStore("actuator", {needConfigureExternalUrl: (state) => {return state.serverInfo?.externalUrl === EXTERNAL_URL_PLACEHOLDER;},+ disallowSignup: (state) => {+ return state.serverInfo?.disallowSignup || false;+ },hasNewRelease: (state) => {return ((state.serverInfo?.version === "development" &&diff --git a/frontend/src/types/actuator.ts b/frontend/src/types/actuator.tsindex 4a1545696d..dbb7504e07 100644--- a/frontend/src/types/actuator.ts+++ b/frontend/src/types/actuator.ts@@ -6,6 +6,7 @@ export type ServerInfo = {externalUrl: string;needAdminSetup: boolean;startedTs: number;+ disallowSignup: boolean;};export type Release = {diff --git a/frontend/src/views/SettingWorkspaceVCSDetail.vue b/frontend/src/views/SettingWorkspaceVCSDetail.vueindex b56d1d075e..945bbb268b 100644--- a/frontend/src/views/SettingWorkspaceVCSDetail.vue+++ b/frontend/src/views/SettingWorkspaceVCSDetail.vue@@ -99,16 +99,20 @@<template v-if="repositoryList.length == 0"><BBButtonConfirm:style="'DELETE'"- :button-text="'Delete this Git provider'"- :ok-text="'Delete'"- :confirm-title="`Delete Git provider '${vcs.name}'?`"+ :button-text="$t('gitops.setting.git-provider.delete')"+ :ok-text="$t('common.delete')"+ :confirm-title="+ $t('gitops.setting.git-provider.delete-confirm', {+ name: vcs.name,+ })+ ":require-confirm="true"@confirm="deleteVCS"/></template><template v-else><div class="mt-1 textinfolabel">- {{ $t("gitops.setting.git-provider.delete") }}+ {{ $t("gitops.setting.git-provider.delete-forbidden") }}</div></template><div>diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vueindex 106744fca5..b10ba40e7e 100644--- a/frontend/src/views/auth/Signin.vue+++ b/frontend/src/views/auth/Signin.vue@@ -136,7 +136,7 @@$t("auth.sign-in.demo-note")}}</span></template>- <template v-else>+ <template v-else-if="!disallowSignup"><span class="pl-2 bg-white text-control">{{$t("auth.sign-in.new-user")}}</span>@@ -239,7 +239,7 @@ const state = reactive<LocalState>({password: "",showPassword: false,});-const { isDemo } = storeToRefs(actuatorStore);+const { isDemo, disallowSignup } = storeToRefs(actuatorStore);const identityProviderList = computed(() => identityProviderStore.identityProviderList@@ -249,7 +249,7 @@ onMounted(async () => {// Navigate to signup if needs admin setup.// Unable to achieve it in router.beforeEach because actuator/info is fetched async and returns// after router has already made the decision on first page load.- if (actuatorStore.needAdminSetup) {+ if (actuatorStore.needAdminSetup && !disallowSignup) {router.push({ name: "auth.signup", replace: true });}diff --git a/frontend/src/views/auth/Signup.vue b/frontend/src/views/auth/Signup.vueindex 3fc589bd92..c26d8f6ae6 100644--- a/frontend/src/views/auth/Signup.vue+++ b/frontend/src/views/auth/Signup.vue@@ -272,14 +272,15 @@ export default defineComponent({}});- const { needAdminSetup } = storeToRefs(actuatorStore);+ const { needAdminSetup, disallowSignup } = storeToRefs(actuatorStore);const allowSignup = computed(() => {return (isValidEmail(state.email) &&state.password &&!state.showPasswordMismatchError &&- state.acceptTermsAndPolicy+ state.acceptTermsAndPolicy &&+ !disallowSignup);});