Skip to content

Conversation

@halkeye
Copy link
Contributor

@halkeye halkeye commented Aug 22, 2025

Mostly want to know if its worth cleaning up and continuing

  • Created a new table to store temporary session/validation storage
    [ ] TODO - need to implement cleanup
  • Does oidc against an oidc server with discovery (most modern ones have .well-known/openid-configuration urls)
  • Matches user based on username
    [ ] TODO - Add config for matching other criteria, or just add oidc subs => username table
  • creates user if none are found
    [ ] TODO - Add config to disable creating new users
  • Sets frontend user once auth is completed successfully

@vercel
Copy link

vercel bot commented Aug 22, 2025

@halkeye is attempting to deploy a commit to the umami-software Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 OidcState table 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-client library (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, and src/app/login/oidc/callback/page.tsx

10 files reviewed, 8 comments

Edit Code Review Bot Settings | Greptile

}

model OidcState {
state String @id() @unique() @db.Uuid
Copy link
Contributor

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.

Suggested change
state String @id() @unique() @db.Uuid
state String @id() @unique() @db.VarChar(36)

Copy link
Contributor Author

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

@@ -0,0 +1,9 @@
import { redirect } from 'next/navigation';

export default function () {
Copy link
Contributor

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

Comment on lines +13 to +17
const oidcConfig = await oidcClient.discovery(
new URL(process.env.OIDC_ISSUER),
process.env.OIDC_CLIENT_ID,
process.env.OIDC_CLIENT_SECRET,
);
Copy link
Contributor

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

halkeye and others added 6 commits August 22, 2025 16:31
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>
@tpendragon
Copy link

Would love OIDC, great work

@reyemb
Copy link

reyemb commented Aug 29, 2025

@mikecao @franciscao633 Could you take a look at this or leave some instructions what needs to be done to keep going?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants