Add OAuth login flow for admin dashboard#21
Open
adrw wants to merge 4 commits intoadrw/admin-dashboardfrom
Open
Add OAuth login flow for admin dashboard#21adrw wants to merge 4 commits intoadrw/admin-dashboardfrom
adrw wants to merge 4 commits intoadrw/admin-dashboardfrom
Conversation
The admin dashboard serves HTML pages, but verify() only checks the Authorization header for bearer tokens. Browsers don't send bearer tokens on page navigation, causing 401 errors when auth is configured. Changes: - AuthReceiver: Add BearerTokenOverride attribute key so verify() checks call attributes before falling back to the Authorization header - AdminDashboardHandler: Read kairo_admin_token cookie and set it as a BearerTokenOverride attribute on each request. On auth failure, redirect to login page instead of returning 401. - LoginView: Simple login page where users paste a bearer token, which gets stored as an HttpOnly cookie Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the manual JWT paste approach with a proper OAuth redirect flow. When AdminOAuthConfig is provided, the login page shows a "Sign in with [provider]" button that initiates the standard authorization code exchange. Includes CSRF protection via state parameter cookie validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When OAuth is configured, GET /login now redirects directly to the OAuth provider. The manual token textarea and POST /login route are removed. If OAuth is not configured but auth is required, the login page shows a configuration error message. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GET /login now directly starts the OAuth flow when configured, removing the intermediate redirect. LoginView is only rendered as an error page when OAuth is not configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kairo-adminmodule: a full-featured admin dashboard for Kairo serverskairo-kdocsmodule: serves Dokka-generated API docs at/_kdocsAuthReceiver.BearerTokenOverrideOAuth login flow
/_admin/→ no cookie → auth fails → redirect to/_admin/login/_admin/login→ generates CSRF state cookie → redirects to OAuth provider (e.g. Auth0)/_admin/callback?code=...&state=...kairo_admin_tokenHttpOnly cookie/_admin/→ cookie present →verify()succeeds viaBearerTokenOverrideKey changes
kairo-admin(new module)AdminDashboardFeature— Kairo feature with HTML dashboard, OAuth routes, and data collectorsAdminOAuthConfig— Generic OAuth 2.0 config (authorizeUrl,tokenUrl,clientId,clientSecret,scopes,audience,providerName,logoutUrl)AdminDashboardHandler— Routes:GET /login(start OAuth),GET /callback(exchange code),POST /logout(clear cookie), plusauthGet/authPostwrappers that redirect to login on auth failureLoginView— Error page shown only when OAuth is not configured; when configured,/loginredirects directly to providerkairo-kdocs(new module)KdocsFeature— Serves Dokka HTML docs from the classpath at/_kdocskairo-rest(modified)AuthReceiver.kt— AddedBearerTokenOverrideattribute key so admin dashboard can supply JWT from cookie instead ofAuthorizationheader; addedforCall()factory for non-endpoint auth checksConsumer code
Test plan
/_admin/without cookie redirects to/_admin/login/_admin/loginredirects to OAuth provider with correct params/_admin/with valid cookie loads the dashboard/_admin/logoutclears cookieAuthorization: Bearerheader still works for API access/_kdocsserves Dokka docs🤖 Generated with Claude Code