Skip to content

Commit 3d5141d

Browse files
authored
chore(oauth): remove unused github-repo generic OAuth provider (#3543)
1 parent 75832ca commit 3d5141d

File tree

6 files changed

+2
-172
lines changed

6 files changed

+2
-172
lines changed

apps/sim/lib/auth/auth.ts

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export const auth = betterAuth({
492492
'google-meet',
493493
'google-tasks',
494494
'vertex-ai',
495-
'github-repo',
495+
496496
'microsoft-dataverse',
497497
'microsoft-teams',
498498
'microsoft-excel',
@@ -754,83 +754,6 @@ export const auth = betterAuth({
754754
}),
755755
genericOAuth({
756756
config: [
757-
{
758-
providerId: 'github-repo',
759-
clientId: env.GITHUB_REPO_CLIENT_ID as string,
760-
clientSecret: env.GITHUB_REPO_CLIENT_SECRET as string,
761-
authorizationUrl: 'https://github.com/login/oauth/authorize',
762-
accessType: 'offline',
763-
prompt: 'consent',
764-
tokenUrl: 'https://github.com/login/oauth/access_token',
765-
userInfoUrl: 'https://api.github.com/user',
766-
scopes: getCanonicalScopesForProvider('github-repo'),
767-
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/github-repo`,
768-
getUserInfo: async (tokens) => {
769-
try {
770-
const profileResponse = await fetch('https://api.github.com/user', {
771-
headers: {
772-
Authorization: `Bearer ${tokens.accessToken}`,
773-
'User-Agent': 'sim-studio',
774-
},
775-
})
776-
777-
if (!profileResponse.ok) {
778-
await profileResponse.text().catch(() => {})
779-
logger.error('Failed to fetch GitHub profile', {
780-
status: profileResponse.status,
781-
statusText: profileResponse.statusText,
782-
})
783-
throw new Error(`Failed to fetch GitHub profile: ${profileResponse.statusText}`)
784-
}
785-
786-
const profile = await profileResponse.json()
787-
788-
if (!profile.email) {
789-
const emailsResponse = await fetch('https://api.github.com/user/emails', {
790-
headers: {
791-
Authorization: `Bearer ${tokens.accessToken}`,
792-
'User-Agent': 'sim-studio',
793-
},
794-
})
795-
796-
if (emailsResponse.ok) {
797-
const emails = await emailsResponse.json()
798-
799-
const primaryEmail =
800-
emails.find(
801-
(email: { primary: boolean; email: string; verified: boolean }) =>
802-
email.primary
803-
) || emails[0]
804-
if (primaryEmail) {
805-
profile.email = primaryEmail.email
806-
profile.emailVerified = primaryEmail.verified || false
807-
}
808-
} else {
809-
logger.warn('Failed to fetch GitHub emails', {
810-
status: emailsResponse.status,
811-
statusText: emailsResponse.statusText,
812-
})
813-
}
814-
}
815-
816-
const now = new Date()
817-
818-
return {
819-
id: `${profile.id.toString()}-${crypto.randomUUID()}`,
820-
name: profile.name || profile.login,
821-
email: profile.email,
822-
image: profile.avatar_url,
823-
emailVerified: profile.emailVerified || false,
824-
createdAt: now,
825-
updatedAt: now,
826-
}
827-
} catch (error) {
828-
logger.error('Error in GitHub getUserInfo', { error })
829-
throw error
830-
}
831-
},
832-
},
833-
834757
// Google providers
835758
{
836759
providerId: 'google-email',

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ export const env = createEnv({
230230
GOOGLE_CLIENT_SECRET: z.string().optional(), // Google OAuth client secret
231231
GITHUB_CLIENT_ID: z.string().optional(), // GitHub OAuth client ID for GitHub integration
232232
GITHUB_CLIENT_SECRET: z.string().optional(), // GitHub OAuth client secret
233-
GITHUB_REPO_CLIENT_ID: z.string().optional(), // GitHub OAuth client ID for repo access
234-
GITHUB_REPO_CLIENT_SECRET: z.string().optional(), // GitHub OAuth client secret for repo access
233+
235234
X_CLIENT_ID: z.string().optional(), // X (Twitter) OAuth client ID
236235
X_CLIENT_SECRET: z.string().optional(), // X (Twitter) OAuth client secret
237236
CONFLUENCE_CLIENT_ID: z.string().optional(), // Atlassian Confluence OAuth client ID

apps/sim/lib/oauth/oauth.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ describe('OAuth Token Refresh', () => {
170170
describe('Body Credential Providers', () => {
171171
const bodyCredentialProviders = [
172172
{ name: 'Google', providerId: 'google', endpoint: 'https://oauth2.googleapis.com/token' },
173-
{
174-
name: 'GitHub',
175-
providerId: 'github',
176-
endpoint: 'https://github.com/login/oauth/access_token',
177-
},
178173
{
179174
name: 'Microsoft',
180175
providerId: 'microsoft',
@@ -279,19 +274,6 @@ describe('OAuth Token Refresh', () => {
279274
)
280275
})
281276

282-
it.concurrent('should include Accept header for GitHub requests', async () => {
283-
const mockFetch = createMockFetch(defaultOAuthResponse)
284-
const refreshToken = 'test_refresh_token'
285-
286-
await withMockFetch(mockFetch, () => refreshOAuthToken('github', refreshToken))
287-
288-
const [, requestOptions] = mockFetch.mock.calls[0] as [
289-
string,
290-
{ headers: Record<string, string>; body: string },
291-
]
292-
expect(requestOptions.headers.Accept).toBe('application/json')
293-
})
294-
295277
it.concurrent('should include User-Agent header for Reddit requests', async () => {
296278
const mockFetch = createMockFetch(defaultOAuthResponse)
297279
const refreshToken = 'test_refresh_token'

apps/sim/lib/oauth/oauth.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
CalComIcon,
77
ConfluenceIcon,
88
DropboxIcon,
9-
GithubIcon,
109
GmailIcon,
1110
GoogleBigQueryIcon,
1211
GoogleCalendarIcon,
@@ -340,21 +339,6 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
340339
},
341340
defaultService: 'outlook',
342341
},
343-
github: {
344-
name: 'GitHub',
345-
icon: GithubIcon,
346-
services: {
347-
github: {
348-
name: 'GitHub',
349-
description: 'Manage repositories, issues, and pull requests.',
350-
providerId: 'github-repo',
351-
icon: GithubIcon,
352-
baseProviderIcon: GithubIcon,
353-
scopes: ['repo', 'user:email', 'read:user', 'workflow'],
354-
},
355-
},
356-
defaultService: 'github',
357-
},
358342
x: {
359343
name: 'X',
360344
icon: xIcon,
@@ -988,19 +972,6 @@ function getProviderAuthConfig(provider: string): ProviderAuthConfig {
988972
useBasicAuth: false,
989973
}
990974
}
991-
case 'github': {
992-
const { clientId, clientSecret } = getCredentials(
993-
env.GITHUB_CLIENT_ID,
994-
env.GITHUB_CLIENT_SECRET
995-
)
996-
return {
997-
tokenEndpoint: 'https://github.com/login/oauth/access_token',
998-
clientId,
999-
clientSecret,
1000-
useBasicAuth: false,
1001-
additionalHeaders: { Accept: 'application/json' },
1002-
}
1003-
}
1004975
case 'x': {
1005976
const { clientId, clientSecret } = getCredentials(env.X_CLIENT_ID, env.X_CLIENT_SECRET)
1006977
return {

apps/sim/lib/oauth/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export type OAuthProvider =
1515
| 'google-groups'
1616
| 'google-meet'
1717
| 'vertex-ai'
18-
| 'github'
19-
| 'github-repo'
2018
| 'x'
2119
| 'confluence'
2220
| 'airtable'
@@ -64,7 +62,6 @@ export type OAuthService =
6462
| 'google-groups'
6563
| 'google-meet'
6664
| 'vertex-ai'
67-
| 'github'
6865
| 'x'
6966
| 'confluence'
7067
| 'airtable'

apps/sim/lib/oauth/utils.test.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ describe('getAllOAuthServices', () => {
6666
it.concurrent('should include single-service providers', () => {
6767
const services = getAllOAuthServices()
6868

69-
const githubService = services.find((s) => s.providerId === 'github-repo')
70-
expect(githubService).toBeDefined()
71-
expect(githubService?.name).toBe('GitHub')
72-
expect(githubService?.baseProvider).toBe('github')
73-
7469
const slackService = services.find((s) => s.providerId === 'slack')
7570
expect(slackService).toBeDefined()
7671
expect(slackService?.name).toBe('Slack')
@@ -145,14 +140,6 @@ describe('getServiceByProviderAndId', () => {
145140
expect(service.name).toBe('Microsoft Excel')
146141
})
147142

148-
it.concurrent('should work with single-service providers', () => {
149-
const service = getServiceByProviderAndId('github')
150-
151-
expect(service).toBeDefined()
152-
expect(service.providerId).toBe('github-repo')
153-
expect(service.name).toBe('GitHub')
154-
})
155-
156143
it.concurrent('should include scopes in returned service config', () => {
157144
const service = getServiceByProviderAndId('google', 'gmail')
158145

@@ -182,12 +169,6 @@ describe('getProviderIdFromServiceId', () => {
182169
expect(providerId).toBe('outlook')
183170
})
184171

185-
it.concurrent('should return correct providerId for GitHub', () => {
186-
const providerId = getProviderIdFromServiceId('github')
187-
188-
expect(providerId).toBe('github-repo')
189-
})
190-
191172
it.concurrent('should return correct providerId for Microsoft Excel', () => {
192173
const providerId = getProviderIdFromServiceId('microsoft-excel')
193174

@@ -262,14 +243,6 @@ describe('getServiceConfigByProviderId', () => {
262243
expect(excelService?.name).toBe('Microsoft Excel')
263244
})
264245

265-
it.concurrent('should work for GitHub', () => {
266-
const service = getServiceConfigByProviderId('github-repo')
267-
268-
expect(service).toBeDefined()
269-
expect(service?.providerId).toBe('github-repo')
270-
expect(service?.name).toBe('GitHub')
271-
})
272-
273246
it.concurrent('should work for Slack', () => {
274247
const service = getServiceConfigByProviderId('slack')
275248

@@ -338,14 +311,6 @@ describe('getCanonicalScopesForProvider', () => {
338311
expect(excelScopes).toContain('Files.Read')
339312
})
340313

341-
it.concurrent('should return scopes for GitHub', () => {
342-
const scopes = getCanonicalScopesForProvider('github-repo')
343-
344-
expect(scopes.length).toBeGreaterThan(0)
345-
expect(scopes).toContain('repo')
346-
expect(scopes).toContain('user:email')
347-
})
348-
349314
it.concurrent('should handle providers with empty scopes array', () => {
350315
const scopes = getCanonicalScopesForProvider('notion')
351316

@@ -397,13 +362,6 @@ describe('parseProvider', () => {
397362
expect(teamsConfig.featureType).toBe('microsoft-teams')
398363
})
399364

400-
it.concurrent('should parse GitHub provider', () => {
401-
const config = parseProvider('github-repo' as OAuthProvider)
402-
403-
expect(config.baseProvider).toBe('github')
404-
expect(config.featureType).toBe('github')
405-
})
406-
407365
it.concurrent('should parse Slack provider', () => {
408366
const config = parseProvider('slack' as OAuthProvider)
409367

0 commit comments

Comments
 (0)