From 087a1881336f529213548e8eeb68ca54fec55be4 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:32:04 +0300 Subject: [PATCH] Remove auth gateway code --- .env.example | 2 -- .../auth/core/DiscordStrategy.server.ts | 20 ++++--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/.env.example b/.env.example index a3ef29be0..ba371c31f 100644 --- a/.env.example +++ b/.env.example @@ -5,8 +5,6 @@ SESSION_SECRET=secret // Auth https://discord.com/developers DISCORD_CLIENT_ID= DISCORD_CLIENT_SECRET= -AUTH_GATEWAY_PROFILE_URL= -AUTH_GATEWAY_TOKEN_URL= // Patreon integration https://www.patreon.com/portal/registration/register-clients PATREON_ACCESS_TOKEN= diff --git a/app/features/auth/core/DiscordStrategy.server.ts b/app/features/auth/core/DiscordStrategy.server.ts index 4cf638e84..d97d83192 100644 --- a/app/features/auth/core/DiscordStrategy.server.ts +++ b/app/features/auth/core/DiscordStrategy.server.ts @@ -29,10 +29,6 @@ const discordUserDetailsSchema = z.tuple([ export const DiscordStrategy = () => { const envVars = authEnvVars(); - const authGatewayEnabled = () => { - return Boolean(process.env.AUTH_GATEWAY_TOKEN_URL); - }; - const jsonIfOk = (res: Response) => { if (!res.ok) { throw new Error( @@ -56,30 +52,22 @@ export const DiscordStrategy = () => { ]); }; - const fetchProfileViaGateway = (token: string) => { - const url = `${process.env.AUTH_GATEWAY_PROFILE_URL}?token=${token}`; - - return fetch(url).then(jsonIfOk); - }; - return new OAuth2Strategy( { clientId: envVars.DISCORD_CLIENT_ID, clientSecret: envVars.DISCORD_CLIENT_SECRET, authorizationEndpoint: "https://discord.com/api/oauth2/authorize", - tokenEndpoint: - process.env.AUTH_GATEWAY_TOKEN_URL || - "https://discord.com/api/oauth2/token", + tokenEndpoint: "https://discord.com/api/oauth2/token", redirectURI: new URL("/auth/callback", envVars.BASE_URL).toString(), scopes: ["identify", "connections", "email"], }, async ({ tokens }) => { try { - const discordResponses = authGatewayEnabled() - ? await fetchProfileViaGateway(tokens.accessToken()) - : await fetchProfileViaDiscordApi(tokens.accessToken()); + const discordResponses = await fetchProfileViaDiscordApi( + tokens.accessToken(), + ); const [user, connections] = discordUserDetailsSchema.parse(discordResponses);