Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/sim/app/(auth)/components/oauth-provider-checker.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { env } from '@/lib/core/config/env'
import { isProd } from '@/lib/core/config/feature-flags'
import { isGithubAuthDisabled, isGoogleAuthDisabled, isProd } from '@/lib/core/config/feature-flags'

export async function getOAuthProviderStatus() {
const githubAvailable = !!(env.GITHUB_CLIENT_ID && env.GITHUB_CLIENT_SECRET)
const githubAvailable =
!!(env.GITHUB_CLIENT_ID && env.GITHUB_CLIENT_SECRET) && !isGithubAuthDisabled

const googleAvailable = !!(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET)
const googleAvailable =
!!(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) && !isGoogleAuthDisabled

return { githubAvailable, googleAvailable, isProduction: isProd }
}
32 changes: 19 additions & 13 deletions apps/sim/lib/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import {
isBillingEnabled,
isEmailPasswordEnabled,
isEmailVerificationEnabled,
isGithubAuthDisabled,
isGoogleAuthDisabled,
isHosted,
isOrganizationsEnabled,
isRegistrationDisabled,
Expand Down Expand Up @@ -607,19 +609,23 @@ export const auth = betterAuth({
},
},
socialProviders: {
github: {
clientId: env.GITHUB_CLIENT_ID as string,
clientSecret: env.GITHUB_CLIENT_SECRET as string,
scope: ['user:email', 'repo'],
},
google: {
clientId: env.GOOGLE_CLIENT_ID as string,
clientSecret: env.GOOGLE_CLIENT_SECRET as string,
scope: [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
],
},
...(!isGithubAuthDisabled && {
github: {
clientId: env.GITHUB_CLIENT_ID as string,
clientSecret: env.GITHUB_CLIENT_SECRET as string,
scope: ['user:email', 'repo'],
},
}),
...(!isGoogleAuthDisabled && {
google: {
clientId: env.GOOGLE_CLIENT_ID as string,
clientSecret: env.GOOGLE_CLIENT_SECRET as string,
scope: [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
],
},
}),
},
emailVerification: {
autoSignInAfterVerification: true,
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/lib/core/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ export const env = createEnv({
GOOGLE_CLIENT_SECRET: z.string().optional(), // Google OAuth client secret
GITHUB_CLIENT_ID: z.string().optional(), // GitHub OAuth client ID for GitHub integration
GITHUB_CLIENT_SECRET: z.string().optional(), // GitHub OAuth client secret
DISABLE_GOOGLE_AUTH: z.boolean().optional(), // Disable Google OAuth login even when credentials are configured
DISABLE_GITHUB_AUTH: z.boolean().optional(), // Disable GitHub OAuth login even when credentials are configured

X_CLIENT_ID: z.string().optional(), // X (Twitter) OAuth client ID
X_CLIENT_SECRET: z.string().optional(), // X (Twitter) OAuth client secret
Expand Down
12 changes: 12 additions & 0 deletions apps/sim/lib/core/config/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ export const isInvitationsDisabled = isTruthy(env.DISABLE_INVITATIONS)
*/
export const isPublicApiDisabled = isTruthy(env.DISABLE_PUBLIC_API)

/**
* Is Google OAuth login disabled
* When true, the Google OAuth login button is hidden even when credentials are configured
*/
export const isGoogleAuthDisabled = isTruthy(env.DISABLE_GOOGLE_AUTH)

/**
* Is GitHub OAuth login disabled
* When true, the GitHub OAuth login button is hidden even when credentials are configured
*/
export const isGithubAuthDisabled = isTruthy(env.DISABLE_GITHUB_AUTH)

/**
* Is React Grab enabled for UI element debugging
* When true and in development mode, enables React Grab for copying UI element context to clipboard
Expand Down
2 changes: 2 additions & 0 deletions helm/sim/examples/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ app:
RESEND_API_KEY: "your-resend-api-key"
GOOGLE_CLIENT_ID: "your-google-client-id"
GOOGLE_CLIENT_SECRET: "your-google-client-secret"
# DISABLE_GOOGLE_AUTH: "true" # Uncomment to hide Google OAuth login
# DISABLE_GITHUB_AUTH: "true" # Uncomment to hide GitHub OAuth login

# Realtime service
realtime:
Expand Down
8 changes: 8 additions & 0 deletions helm/sim/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@
"type": "string",
"description": "GitHub OAuth client secret"
},
"DISABLE_GOOGLE_AUTH": {
"type": "string",
"description": "Set to 'true' to hide Google OAuth login even when credentials are configured"
},
"DISABLE_GITHUB_AUTH": {
"type": "string",
"description": "Set to 'true' to hide GitHub OAuth login even when credentials are configured"
},
"OPENAI_API_KEY": {
"type": "string",
"description": "Primary OpenAI API key"
Expand Down
2 changes: 2 additions & 0 deletions helm/sim/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ app:
GOOGLE_CLIENT_SECRET: "" # Google OAuth client secret
GITHUB_CLIENT_ID: "" # GitHub OAuth client ID
GITHUB_CLIENT_SECRET: "" # GitHub OAuth client secret
DISABLE_GOOGLE_AUTH: "" # Set to "true" to hide Google OAuth login
DISABLE_GITHUB_AUTH: "" # Set to "true" to hide GitHub OAuth login

# Google Vertex AI Configuration
VERTEX_PROJECT: "" # Google Cloud project ID for Vertex AI
Expand Down
Loading