Skip to content

Cannot configure OIDC - /api/auth/settings requires authentication (circular dependency) #241

Description

@SamTanna

Issue Summary
The frontend cannot load OIDC provider configuration because the /api/auth/settings endpoint requires authentication, creating a circular dependency where users need to authenticate to see the authentication options.

Environment
Version: codewithcj/sparkyfitness:latest (v0.15.7.3)
Server: codewithcj/sparkyfitness_server:latest
Deployment: Docker Compose
Reverse Proxy: Traefik with Cloudflare
IdP: Authentik

Steps to Reproduce
Configure OIDC provider in oidc_providers table with encrypted client secret
Set is_oidc_active = true in global_settings table
Navigate to login page at https://fit.my-fam.org
Open browser DevTools → Network tab

Expected Behavior
OIDC login button should appear: "Sign in with Authentik"
Frontend should load OIDC providers from a public endpoint

Actual Behavior
Warning message: "Could not load login settings from server. Defaulting to email login."
Only email/password login form displayed
Network tab shows: GET /api/auth/settings → 401 Unauthorized

Technical Analysis
Working endpoint (public):
curl https://fit.my-fam.org/openid/providers
Returns: [{"id":1,"display_name":"Authentik","logo_url":null}]
Broken endpoint (protected):
curl https://fit.my-fam.org/api/auth/settings
Returns: {"error":"Authentication: No token or active session provided."}


**Server logs:**

[WARN] Authentication: No token or active session provided.
[DEBUG] Skipping authentication for public route: /openid/api/me
The authentication middleware correctly skips /openid/api/me but not /api/auth/settings.

Root Cause
The frontend attempts to fetch OIDC configuration from /api/auth/settings, but this endpoint is protected by authentication middleware. The /openid/providers endpoint exists and works correctly (returns OIDC providers without authentication), but the frontend doesn't use it.

Proposed Solutions
Option 1: Add /api/auth/settings to authentication middleware's public routes whitelist
Option 2: Update frontend to use /openid/providers instead of /api/auth/settings
Option 3: Create a new public endpoint like /api/public/auth/settings specifically for unauthenticated configuration retrieval

Additional Context
Database configuration is correct (verified via direct database queries)
All migrations applied successfully
The /openid/providers endpoint proves the OIDC configuration is stored and retrievable
This appears to be a regression from recent OIDC refactoring mentioned in v0.15.7.2 release notes

Impact
OIDC-only deployments are currently impossible. Users requiring SSO integration cannot use SparkyFitness without also enabling email/password authentication as a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions