Add generic OAuth provider
Summary
Added generic OAuth support in sim helm
Fixes #2080
Type of Change
- [ ] Bug fix
- [x] New feature
- [ ] Breaking change
- [ ] Documentation
- [ ] Other: ___________
Testing
let me know if we have to add unit tests?
Checklist
- [x] Code follows project style guidelines
- [x] Self-reviewed my changes
- [x] Tests added/updated and passing
- [x] No new warnings introduced
- [x] I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
@CodeMan62 is attempting to deploy a commit to the Sim Team on Vercel.
A member of the Team first needs to authorize it.
Greptile Overview
Greptile Summary
Added generic OAuth provider support to enable Auth0, Okta, Keycloak, and other OIDC providers through environment variables and Helm configuration.
Key Changes:
- Added 7 new environment variables (
OAUTH_CLIENT_ID,OAUTH_CLIENT_SECRET,OAUTH_AUTHORIZATION_URL,OAUTH_TOKEN_URL,OAUTH_USERINFO_URL,OAUTH_SCOPES,OAUTH_PROVIDER_ID) inenv.ts,values.yaml, andvalues.schema.json - Added generic OAuth provider to Better Auth's
genericOAuthplugin configuration inauth.ts - Added provider ID to trusted providers list for cross-site authentication
Critical Issue:
The OAuth provider configuration in apps/sim/lib/auth.ts:1597-1608 is missing the required getUserInfo function. All other genericOAuth providers in the codebase (github-repo, salesforce, x, webflow, etc.) implement this function to fetch and map user profile data from the OAuth provider. Without this function, authentication will fail when users attempt to log in with the generic OAuth provider.
Additional Improvement:
The OAuth URL fields in env.ts should use .url() validation like other URL fields in the codebase (e.g., DATABASE_URL, OLLAMA_URL) to prevent configuration errors.
Confidence Score: 2/5
- This PR cannot be safely merged without the missing getUserInfo function, which will cause authentication failures
- Score reflects a critical missing implementation (getUserInfo function) that will cause runtime errors when users attempt OAuth authentication. The Helm configuration and environment variable definitions are well-structured, but the core authentication logic is incomplete. The missing URL validation is a minor issue compared to the blocking authentication bug.
- Pay close attention to
apps/sim/lib/auth.ts- the generic OAuth configuration must include a getUserInfo function before this can be merged
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/auth.ts | 2/5 | Added generic OAuth provider configuration but missing critical getUserInfo function required by Better Auth's genericOAuth plugin, which will cause runtime errors during authentication |
| apps/sim/lib/env.ts | 3/5 | Added OAuth environment variables but missing URL validation (.url()) for authorization, token, and userinfo URLs, unlike other URL fields in the codebase |
Sequence Diagram
sequenceDiagram
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