-
Notifications
You must be signed in to change notification settings - Fork 6k
POC for Oidc #3589
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: master
Are you sure you want to change the base?
POC for Oidc #3589
Conversation
|
@halkeye is attempting to deploy a commit to the umami-software 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.
Greptile Summary
This PR implements a proof-of-concept for OIDC (OpenID Connect) authentication in Umami. The implementation adds a complete OAuth2/OIDC authorization code flow with PKCE support, allowing users to authenticate via external identity providers.
The key changes include:
- Database Schema: Adds a new
OidcStatetable across PostgreSQL and MySQL schemas to store temporary authentication state and PKCE code verifiers during the OAuth flow - Authentication Logic: Creates a new API route (
/api/auth/login/oidc) that handles both authorization initiation and callback processing, integrating with the existing token generation system - User Interface: Implements frontend components for OIDC login entry point and callback handling, with automatic redirection to the dashboard upon successful authentication
- Database Queries: Adds Prisma queries for managing OIDC state with creation and retrieval functions
- Dependencies: Integrates the
openid-clientlibrary (v6.6.4) for OIDC protocol handling and provider discovery - Security Enhancement: Strengthens password validation to prevent authentication bypass with empty strings
- Type Safety: Improves TypeScript support in the Prisma client configuration
The implementation supports OIDC discovery via .well-known/openid-configuration, matches users by username, creates new users automatically when none exist, and integrates with Umami's existing authentication token system. The PR includes several TODO items for cleanup mechanisms, configuration options for user creation control, and alternative user matching strategies.
Confidence score: 2/5
- This PR requires significant review and improvements before merging due to multiple security and reliability concerns
- Score reflects missing error handling, security vulnerabilities, database inconsistencies, and incomplete implementation of critical features
- Pay close attention to
src/app/api/auth/login/oidc/route.ts,db/mysql/schema.prisma, andsrc/app/login/oidc/callback/page.tsx
10 files reviewed, 8 comments
db/mysql/schema.prisma
Outdated
| } | ||
|
|
||
| model OidcState { | ||
| state String @id() @unique() @db.Uuid |
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: Database type inconsistency: MySQL schema uses @db.Uuid but MySQL doesn't have native UUID type. This should be @db.VarChar(36) to match other ID fields in the MySQL schema.
| state String @id() @unique() @db.Uuid | |
| state String @id() @unique() @db.VarChar(36) |
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.
neither of these are db.uuid, so note to self, change to varchar
src/app/login/oidc/page.tsx
Outdated
| @@ -0,0 +1,9 @@ | |||
| import { redirect } from 'next/navigation'; | |||
|
|
|||
| export default function () { | |||
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: Consider naming this function for better debugging and stack traces
| const oidcConfig = await oidcClient.discovery( | ||
| new URL(process.env.OIDC_ISSUER), | ||
| process.env.OIDC_CLIENT_ID, | ||
| process.env.OIDC_CLIENT_SECRET, | ||
| ); |
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: Module-level async OIDC discovery will cause startup failures if environment variables are missing or OIDC server is unreachable
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Would love OIDC, great work |
|
@mikecao @franciscao633 Could you take a look at this or leave some instructions what needs to be done to keep going? |
Mostly want to know if its worth cleaning up and continuing
[ ] TODO - need to implement cleanup
[ ] TODO - Add config for matching other criteria, or just add oidc subs => username table
[ ] TODO - Add config to disable creating new users