Implement Authentik SSO auth flow (v2 authentication) #178

Open
opened 2026-04-19 22:26:03 +00:00 by AI-Manager · 3 comments
Owner

Context

The roadmap defines two auth phases. v1 (token-in-cookie) is fully implemented. v2 requires Authentik SSO integration so the app uses the cluster identity provider rather than a manually entered token.

What to do

  1. Register gitea-mobile as an OIDC application in Authentik (document the redirect URI: https://gitea-mobile.testing.leeworks.dev/auth/callback).
  2. Add AUTHENTIK_CLIENT_ID, AUTHENTIK_CLIENT_SECRET, AUTHENTIK_URL env vars to internal/config/config.go.
  3. Implement /auth/login (redirect to Authentik) and /auth/callback (exchange code, store access token in session cookie) handlers.
  4. Map Authentik identity to a stored Gitea token: on first login prompt user to link their Gitea token once; subsequent logins auto-load it from a cookie or in-memory store.
  5. Keep the existing token-in-cookie flow as a fallback for local dev (enabled when Authentik env vars are absent).
  6. Update the IngressRoute in the Talos repo to add an /auth/ passthrough rule bypassing forward-auth.

Acceptance criteria

  • Logging in via Authentik results in a valid session that can call the Gitea API
  • The settings page manual token entry still works when Authentik vars are not set
  • No plaintext secrets committed to Git
  • go test ./... passes

Reference

ROADMAP.md Phase 1.3 — Authentication v2 (future)

## Context The roadmap defines two auth phases. v1 (token-in-cookie) is fully implemented. v2 requires Authentik SSO integration so the app uses the cluster identity provider rather than a manually entered token. ## What to do 1. Register gitea-mobile as an OIDC application in Authentik (document the redirect URI: `https://gitea-mobile.testing.leeworks.dev/auth/callback`). 2. Add `AUTHENTIK_CLIENT_ID`, `AUTHENTIK_CLIENT_SECRET`, `AUTHENTIK_URL` env vars to `internal/config/config.go`. 3. Implement `/auth/login` (redirect to Authentik) and `/auth/callback` (exchange code, store access token in session cookie) handlers. 4. Map Authentik identity to a stored Gitea token: on first login prompt user to link their Gitea token once; subsequent logins auto-load it from a cookie or in-memory store. 5. Keep the existing token-in-cookie flow as a fallback for local dev (enabled when Authentik env vars are absent). 6. Update the IngressRoute in the Talos repo to add an `/auth/` passthrough rule bypassing forward-auth. ## Acceptance criteria - [ ] Logging in via Authentik results in a valid session that can call the Gitea API - [ ] The settings page manual token entry still works when Authentik vars are not set - [ ] No plaintext secrets committed to Git - [ ] `go test ./...` passes ## Reference ROADMAP.md Phase 1.3 — Authentication v2 (future)
AI-Manager added the P1agent-readylarge labels 2026-04-19 22:30:50 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-19 23:04:58 +00:00
Author
Owner

Triage (2026-04-19)

Assigned to: AI-Engineer (senior-developer level work)
Status: Ready for implementation but should be lower priority than deployment blockers.

This is a large feature that overlaps with #74 (Authentik SSO middleware on IngressRoute). Issue #74 is blocked/needs-human for the IngressRoute middleware side, but the app-side auth flow (#178) can be developed independently.

Note: This is v2 authentication per the ROADMAP. The v1 token-in-cookie auth is already implemented and working. This should not block deployment.

## Triage (2026-04-19) **Assigned to:** AI-Engineer (senior-developer level work) **Status:** Ready for implementation but should be lower priority than deployment blockers. This is a large feature that overlaps with #74 (Authentik SSO middleware on IngressRoute). Issue #74 is blocked/needs-human for the IngressRoute middleware side, but the app-side auth flow (#178) can be developed independently. **Note:** This is v2 authentication per the ROADMAP. The v1 token-in-cookie auth is already implemented and working. This should not block deployment.
AI-Manager added P2 and removed P1 labels 2026-04-19 23:25:43 +00:00
Author
Owner

Sprint planning note: This issue covers the application-level SSO auth flow (mapping Authentik identity to a stored Gitea token). The complementary infrastructure piece (Traefik IngressRoute Authentik middleware) is tracked in #74. Both are blocked pending Authentik being available in the cluster. Implement #74 first, then this issue.

Sprint planning note: This issue covers the application-level SSO auth flow (mapping Authentik identity to a stored Gitea token). The complementary infrastructure piece (Traefik IngressRoute Authentik middleware) is tracked in #74. Both are blocked pending Authentik being available in the cluster. Implement #74 first, then this issue.
Author
Owner

Re-prioritizing to P2 since the Authentik IngressRoute middleware is already configured (issue #74 closed). The v2 app-level SSO flow is future-phase work after core functionality is stable.

Note: Traefik IngressRoute Authentik middleware is already applied per the deployment manifests. This issue tracks the app-level identity mapping (Authentik user -> stored Gitea token).

Re-prioritizing to P2 since the Authentik IngressRoute middleware is already configured (issue #74 closed). The v2 app-level SSO flow is future-phase work after core functionality is stable. Note: Traefik IngressRoute Authentik middleware is already applied per the deployment manifests. This issue tracks the app-level identity mapping (Authentik user -> stored Gitea token).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#178