-
Notifications
You must be signed in to change notification settings - Fork 428
Add an OAuth provider for Twitch #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
@Nachwahl is attempting to deploy a commit to the Stack Team on Vercel. A member of the Team first needs to authorize it. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Added Twitch OAuth provider integration across the stack with UI components and backend support.
- Potential security concern in
apps/backend/src/oauth/providers/twitch.tsx
needs attention for proper error handling and data validation - Uses Plain Object for response handling in Twitch provider instead of Map, consider using Map to prevent prototype pollution (see
postProcessUserInfo
method) - New Twitch provider follows consistent pattern with existing OAuth providers but needs additional validation
- Added brand-consistent purple (#9146FF) Twitch icon implementation in
packages/stack-ui/src/components/brand-icons.tsx
- Standardized OAuth provider type with 'TWITCH' enum in Prisma schema for database consistency
7 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile
"Client-Id": this.oauthClient.client_id as string, | ||
}, | ||
}).then((res) => res.json()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Remove extra blank line.
}).then((res) => res.json()); | |
const userInfo = info.data?.[0]; |
@@ -215,4 +273,5 @@ export const BRAND_COLORS: Record<string, string> = { | |||
linkedin: '#0A66C2', | |||
x: '#000000', | |||
apple: '#000000', | |||
twitch: '#ffffff' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: The twitch brand color should be '#9146FF' to match the official Twitch purple used in the icon
@@ -17,6 +17,7 @@ import { MicrosoftProvider } from "./providers/microsoft"; | |||
import { MockProvider } from "./providers/mock"; | |||
import { SpotifyProvider } from "./providers/spotify"; | |||
import { XProvider } from "./providers/x"; | |||
import { TwitchProvider } from "./providers/twitch"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of TwitchProvider might not be fully compatible with the OAuth provider system. While the provider file exists and extends OAuthBaseProvider, it has not implemented the required static 'create' method that is used in the getProvider() function. This will cause runtime errors when trying to initialize the Twitch provider through getProvider().
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
}).then((res) => res.json()); | ||
|
||
|
||
const userInfo = info.data?.[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsafe access of user info properties. While info.data is checked with optional chaining (?.), the code proceeds to access properties of userInfo without verifying its existence. If the API response is malformed or empty, accessing properties like userInfo.id will cause runtime errors. Should add validation like: if (!userInfo) { throw new Error('Failed to get user info from Twitch response'); }
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
@@ -1,4 +1,4 @@ | |||
export const standardProviders = ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple", "x"] as const; | |||
export const standardProviders = ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple", "x", "twitch"] as const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding 'twitch' to standardProviders requires a corresponding update to the StandardOAuthProviderType enum in the Prisma schema (schema.prisma). The enum is missing the TWITCH value which will cause type mismatches and potential runtime errors when handling OAuth authentication for Twitch. A database migration will be needed to add this new enum value.
React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)
😱 Found 3 issues. Time to roll up your sleeves! 😱 🗒️ View all ignored comments in this repo
Need help? Join our Discord for support! |
oauth-button.mdx
This change is required to reflect the addition of Twitch as a new OAuth provider in the OAuthButton component. Please ensure these changes are made in the documentation to keep it consistent with the recent updates. |
authorizationEndpoint: "https://id.twitch.tv/oauth2/authorize", | ||
tokenEndpoint: "https://id.twitch.tv/oauth2/token", | ||
tokenEndpointAuthMethod: "client_secret_post", | ||
redirectUri: getEnvVariable("NEXT_PUBLIC_STACK_API_URL") + "/api/v1/auth/oauth/callback/twitch", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a tagged template literal (e.g. urlString``) for constructing the redirect URI, and check response.ok before parsing JSON in fetch to better handle errors.
This comment was generated because it violated a code review rule: mrule_pmzJAgHDlFZgwIwD.
Can you give me permission to edit this PR? |
Sure! Do you need permission to our respository? |
|
Done 👍 |
Important
Add Twitch as a new OAuth provider, updating backend logic and UI components to support Twitch authentication.
TwitchProvider
class inproviders/twitch.tsx
to handle OAuth with Twitch, including user info post-processing._providers
inindex.tsx
to includeTwitchProvider
.TWITCH
toStandardOAuthProviderType
enum inschema.prisma
.brand-icons.tsx
andBRAND_COLORS
.ProviderIcon
,ProviderSettingDialog
, andOAuthButton
to support Twitch inproviders.tsx
andoauth-button.tsx
.twitch
tostandardProviders
inoauth.tsx
.This description was created by
for 08c0de5. You can customize this summary. It will automatically update as commits are pushed.