-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add generic OAuth provider #2091
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: main
Are you sure you want to change the base?
Conversation
|
@CodeMan62 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile OverviewGreptile SummaryAdded generic OAuth provider support to enable Auth0, Okta, Keycloak, and other OIDC providers through environment variables and Helm configuration. Key Changes:
Critical Issue: Additional Improvement: Confidence Score: 2/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant U as User
participant S as Sim
participant B as Better Auth
participant P as Provider
U->>S: Click login
S->>B: Start flow
B->>P: Authorize
P->>U: Show form
U->>P: Submit
P->>B: Callback
B->>P: Get token
P->>B: Token
Note over B: Missing getUserInfo<br/>Cannot fetch profile
B->>P: Fetch profile
P->>B: Profile data
B->>S: Session
S->>U: Complete
|
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.
4 files reviewed, 2 comments
| { | ||
| providerId: env.OAUTH_PROVIDER_ID, | ||
| clientId: env.OAUTH_CLIENT_ID, | ||
| clientSecret: env.OAUTH_CLIENT_SECRET, | ||
| authorizationUrl: env.OAUTH_AUTHORIZATION_URL, | ||
| tokenUrl: env.OAUTH_TOKEN_URL, | ||
| userInfoUrl: env.OAUTH_USERINFO_URL, | ||
| scopes: env.OAUTH_SCOPES | ||
| ? env.OAUTH_SCOPES.split(' ').filter(Boolean) | ||
| : ['openid', 'profile', 'email'], | ||
| redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/${env.OAUTH_PROVIDER_ID}`, | ||
| }, |
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.
logic: missing getUserInfo function - this will cause authentication to fail
All other genericOAuth providers in this file (github-repo, wealthbox, pipedrive, hubspot, salesforce, supabase, x, webflow) include a getUserInfo function that fetches user data from the provider and returns it in Better Auth's expected format.
The generic OAuth configuration needs a getUserInfo async function that:
- Fetches user data from
OAUTH_USERINFO_URLusing the access token - Maps the response to Better Auth's user schema (id, name, email, emailVerified, image, createdAt, updatedAt)
- Handles errors and returns null on failure
See apps/sim/lib/auth.ts:833-868 (Salesforce) for a standard OIDC implementation pattern.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/auth.ts
Line: 1597:1608
Comment:
**logic:** missing `getUserInfo` function - this will cause authentication to fail
All other genericOAuth providers in this file (github-repo, wealthbox, pipedrive, hubspot, salesforce, supabase, x, webflow) include a `getUserInfo` function that fetches user data from the provider and returns it in Better Auth's expected format.
The generic OAuth configuration needs a `getUserInfo` async function that:
1. Fetches user data from `OAUTH_USERINFO_URL` using the access token
2. Maps the response to Better Auth's user schema (id, name, email, emailVerified, image, createdAt, updatedAt)
3. Handles errors and returns null on failure
See `apps/sim/lib/auth.ts:833-868` (Salesforce) for a standard OIDC implementation pattern.
How can I resolve this? If you propose a fix, please make it concise.| OAUTH_AUTHORIZATION_URL: z.string().optional(), // OAuth authorization URL | ||
| OAUTH_TOKEN_URL: z.string().optional(), // OAuth token URL | ||
| OAUTH_USERINFO_URL: z.string().optional(), // OAuth userinfo URL |
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: missing URL validation - use .url() validator like other URL fields
Other URL fields in this file use .url() validation (e.g., DATABASE_URL: z.string().url() on line 19, OLLAMA_URL: z.string().url().optional() on line 79). This validates URL format and prevents configuration errors.
| OAUTH_AUTHORIZATION_URL: z.string().optional(), // OAuth authorization URL | |
| OAUTH_TOKEN_URL: z.string().optional(), // OAuth token URL | |
| OAUTH_USERINFO_URL: z.string().optional(), // OAuth userinfo URL | |
| OAUTH_AUTHORIZATION_URL: z.string().url().optional(), // OAuth authorization URL | |
| OAUTH_TOKEN_URL: z.string().url().optional(), // OAuth token URL | |
| OAUTH_USERINFO_URL: z.string().url().optional(), // OAuth userinfo URL |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/env.ts
Line: 179:181
Comment:
**style:** missing URL validation - use `.url()` validator like other URL fields
Other URL fields in this file use `.url()` validation (e.g., `DATABASE_URL: z.string().url()` on line 19, `OLLAMA_URL: z.string().url().optional()` on line 79). This validates URL format and prevents configuration errors.
```suggestion
OAUTH_AUTHORIZATION_URL: z.string().url().optional(), // OAuth authorization URL
OAUTH_TOKEN_URL: z.string().url().optional(), // OAuth token URL
OAUTH_USERINFO_URL: z.string().url().optional(), // OAuth userinfo URL
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
Added generic OAuth support in sim helm
Fixes #2080
Type of Change
Testing
let me know if we have to add unit tests?
Checklist