Skip to content

Commit

Permalink
Merge pull request #2641 from ever-co/fix/oAuth-env-vars-naming
Browse files Browse the repository at this point in the history
OAuth configs using consistent naming
  • Loading branch information
evereq authored Jun 18, 2024
2 parents 7611403 + ec5c404 commit 5d6da8f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 10 deletions.
29 changes: 29 additions & 0 deletions apps/web/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,32 @@ export const languagesFlags = [
code: 'he'
}
];

// OAuth providers keys

export const APPLE_CLIENT_ID = process.env.APPLE_CLIENT_ID;
export const APPLE_CLIENT_SECRET = process.env.APPLE_CLIENT_SECRET;

export const DISCORD_CLIENT_ID = process.env.DISCORD_CLIENT_ID;
export const DISCORD_CLIENT_SECRET = process.env.DISCORD_CLIENT_SECRET;

export const FACEBOOK_CLIENT_ID = process.env.FACEBOOK_CLIENT_ID;
export const FACEBOOK_CLIENT_SECRET = process.env.FACEBOOK_CLIENT_SECRET;

export const GOOGLE_CLIENT_ID = process.env.GOOGLE_CLIENT_ID;
export const GOOGLE_CLIENT_SECRET = process.env.GOOGLE_CLIENT_SECRET;

export const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID;
export const GITHUB_CLIENT_SECRET = process.env.GITHUB_CLIENT_SECRET;

export const LINKEDIN_CLIENT_ID = process.env.LINKEDIN_CLIENT_ID;
export const LINKEDIN_CLIENT_SECRET = process.env.LINKEDIN_CLIENT_SECRET;

export const MICROSOFT_CLIENT_ID = process.env.MICROSOFT_CLIENT_ID;
export const MICROSOFT_CLIENT_SECRET = process.env.MICROSOFT_CLIENT_SECRET;

export const SLACK_CLIENT_ID = process.env.SLACK_CLIENT_ID;
export const SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET;

export const TWITTER_CLIENT_ID = process.env.TWITTER_CLIENT_ID;
export const TWITTER_CLIENT_SECRET = process.env.TWITTER_CLIENT_SECRET;
1 change: 0 additions & 1 deletion apps/web/app/services/server/requests/OAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export enum ProviderEnum {
export function GauzyAdapter(req: NextRequest): Adapter {
return {
createUser: async (user): Promise<any> => {
console.log('=========================== CREATE');
const url = new URL(req.url);

const { email, name } = user;
Expand Down
65 changes: 56 additions & 9 deletions apps/web/app/utils/check-provider-env-vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ import MicrosoftEntraID from '@auth/core/providers/microsoft-entra-id';
import Slack from '@auth/core/providers/slack';
import Twitter from '@auth/core/providers/twitter';
import type { Provider } from '@auth/core/providers';
import {
APPLE_CLIENT_ID,
APPLE_CLIENT_SECRET,
DISCORD_CLIENT_ID,
DISCORD_CLIENT_SECRET,
FACEBOOK_CLIENT_ID,
FACEBOOK_CLIENT_SECRET,
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET,
LINKEDIN_CLIENT_ID,
LINKEDIN_CLIENT_SECRET,
MICROSOFT_CLIENT_ID,
MICROSOFT_CLIENT_SECRET,
SLACK_CLIENT_ID,
SLACK_CLIENT_SECRET,
TWITTER_CLIENT_ID,
TWITTER_CLIENT_SECRET
} from '@app/constants';

type ProviderNames = {
[key: string]: string | undefined;
Expand All @@ -26,15 +46,42 @@ export const providerNames: ProviderNames = {
};

export const providers: Provider[] = [
Apple,
Discord,
Facebook,
Google,
Github,
Linkedin,
MicrosoftEntraID,
Slack,
Twitter
Apple({
clientId: APPLE_CLIENT_ID,
clientSecret: APPLE_CLIENT_SECRET || ''
}),
Discord({
clientId: DISCORD_CLIENT_ID,
clientSecret: DISCORD_CLIENT_SECRET
}),
Facebook({
clientId: FACEBOOK_CLIENT_ID,
clientSecret: FACEBOOK_CLIENT_SECRET
}),
Google({
clientId: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET
}),
Github({
clientId: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET
}),
Linkedin({
clientId: LINKEDIN_CLIENT_ID,
clientSecret: LINKEDIN_CLIENT_SECRET
}),
MicrosoftEntraID({
clientId: MICROSOFT_CLIENT_ID,
clientSecret: MICROSOFT_CLIENT_SECRET
}),
Slack({
clientId: SLACK_CLIENT_ID,
clientSecret: SLACK_CLIENT_SECRET
}),
Twitter({
clientId: TWITTER_CLIENT_ID,
clientSecret: TWITTER_CLIENT_SECRET
})
];

export const filteredProviders = providers.filter((provider) => {
Expand Down

0 comments on commit 5d6da8f

Please sign in to comment.