Skip to content

Commit e8cce67

Browse files
committed
feat(auth): add DISABLE_GOOGLE_AUTH and DISABLE_GITHUB_AUTH env vars
1 parent 8372332 commit e8cce67

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { env } from '@/lib/core/config/env'
2-
import { isProd } from '@/lib/core/config/feature-flags'
2+
import {
3+
isGithubAuthDisabled,
4+
isGoogleAuthDisabled,
5+
isProd,
6+
} from '@/lib/core/config/feature-flags'
37

48
export async function getOAuthProviderStatus() {
5-
const githubAvailable = !!(env.GITHUB_CLIENT_ID && env.GITHUB_CLIENT_SECRET)
9+
const githubAvailable =
10+
!!(env.GITHUB_CLIENT_ID && env.GITHUB_CLIENT_SECRET) && !isGithubAuthDisabled
611

7-
const googleAvailable = !!(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET)
12+
const googleAvailable =
13+
!!(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) && !isGoogleAuthDisabled
814

915
return { githubAvailable, googleAvailable, isProduction: isProd }
1016
}

apps/sim/lib/core/config/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ export const env = createEnv({
260260
GOOGLE_CLIENT_SECRET: z.string().optional(), // Google OAuth client secret
261261
GITHUB_CLIENT_ID: z.string().optional(), // GitHub OAuth client ID for GitHub integration
262262
GITHUB_CLIENT_SECRET: z.string().optional(), // GitHub OAuth client secret
263+
DISABLE_GOOGLE_AUTH: z.boolean().optional(), // Disable Google OAuth login even when credentials are configured
264+
DISABLE_GITHUB_AUTH: z.boolean().optional(), // Disable GitHub OAuth login even when credentials are configured
263265

264266
X_CLIENT_ID: z.string().optional(), // X (Twitter) OAuth client ID
265267
X_CLIENT_SECRET: z.string().optional(), // X (Twitter) OAuth client secret

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ export const isInvitationsDisabled = isTruthy(env.DISABLE_INVITATIONS)
150150
*/
151151
export const isPublicApiDisabled = isTruthy(env.DISABLE_PUBLIC_API)
152152

153+
/**
154+
* Is Google OAuth login disabled
155+
* When true, the Google OAuth login button is hidden even when credentials are configured
156+
*/
157+
export const isGoogleAuthDisabled = isTruthy(env.DISABLE_GOOGLE_AUTH)
158+
159+
/**
160+
* Is GitHub OAuth login disabled
161+
* When true, the GitHub OAuth login button is hidden even when credentials are configured
162+
*/
163+
export const isGithubAuthDisabled = isTruthy(env.DISABLE_GITHUB_AUTH)
164+
153165
/**
154166
* Is React Grab enabled for UI element debugging
155167
* When true and in development mode, enables React Grab for copying UI element context to clipboard

helm/sim/examples/values-production.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ app:
4545
RESEND_API_KEY: "your-resend-api-key"
4646
GOOGLE_CLIENT_ID: "your-google-client-id"
4747
GOOGLE_CLIENT_SECRET: "your-google-client-secret"
48+
# DISABLE_GOOGLE_AUTH: "true" # Uncomment to hide Google OAuth login
49+
# DISABLE_GITHUB_AUTH: "true" # Uncomment to hide GitHub OAuth login
4850

4951
# Realtime service
5052
realtime:

helm/sim/values.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@
184184
"type": "string",
185185
"description": "GitHub OAuth client secret"
186186
},
187+
"DISABLE_GOOGLE_AUTH": {
188+
"type": "string",
189+
"description": "Set to 'true' to hide Google OAuth login even when credentials are configured"
190+
},
191+
"DISABLE_GITHUB_AUTH": {
192+
"type": "string",
193+
"description": "Set to 'true' to hide GitHub OAuth login even when credentials are configured"
194+
},
187195
"OPENAI_API_KEY": {
188196
"type": "string",
189197
"description": "Primary OpenAI API key"

helm/sim/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ app:
109109
GOOGLE_CLIENT_SECRET: "" # Google OAuth client secret
110110
GITHUB_CLIENT_ID: "" # GitHub OAuth client ID
111111
GITHUB_CLIENT_SECRET: "" # GitHub OAuth client secret
112+
DISABLE_GOOGLE_AUTH: "" # Set to "true" to hide Google OAuth login
113+
DISABLE_GITHUB_AUTH: "" # Set to "true" to hide GitHub OAuth login
112114

113115
# Google Vertex AI Configuration
114116
VERTEX_PROJECT: "" # Google Cloud project ID for Vertex AI

0 commit comments

Comments
 (0)