Skip to content

[Bug]: OIDC Redirect Loop, Timeout 3500 within openid-client following successful negotiation #441

@mdnguy

Description

@mdnguy

Important: Log Requirement for Troubleshooting

To effectively troubleshoot and resolve issues, it is crucial to provide relevant server and/or browser console logs that replicate the problem. Issues submitted without adequate logs may be difficult to diagnose and are at risk of being automatically closed.

Bug Description

I've little experience with OIDC, but I think there's a bug in the code that creates a loop that ultimately results in the timeout.

The code in these two calls seem to call each other in a loop, which I believe is triggering the timeout.

SparkyFitnessServer/openidRoutes.js:

// Handle the callback from the frontend
router.post("/callback", async (req, res, next) => {

...

    log('debug', `[OIDC Callback] Session state before callback: ${req.session.state}`);
    const tokenSet = await client.callback(
      redirectUri,
      params,
      {
        code_verifier: req.session.codeVerifier,
        state: req.session.state,
        nonce: req.session.nonce,
        response_type: 'code',
        check: {
          issuer: provider.issuer_url,
          id_token_signed_response_alg: provider.signing_algorithm
        }
      }
    );

...

SparkyFitnessFrontend/src/components/OidcCallback.tsx:

const OidcCallback: React.FC = () => {
  const [error, setError] = useState<string | null>(null);
  const location = useLocation();
  const navigate = useNavigate();
  const { signIn } = useAuth();

  useEffect(() => {

...

      try {
        const response = await apiCall('/openid/callback', {
          method: 'POST',
          body: { code, state },
        });

...

Steps to Reproduce

Steps to reproduce the behavior:

Using the 'latest' image from Docker, 0.16.1

Using Portainer running within Container Manager on Synology NAS

Using Synology Reverse Proxy, all proper headers configured

Expected Behavior

Working OIDC login

Actual Behavior

Timeout after 3500ms

Environment

  • SparkyFitness Version: 0.16.1, Docker image hash: sha256:f8fb91fec8cb82810a583caf9717237d2ca7fe1c5a48df62e180f3c4267ac4bf
  • Running Env: Portainer, Synology NAS

Frontend URL: https://fitness.nas.domain

OIDC redirect: https://fitness.nas.domain/oidc-callback

Authelia with Traefik is running in its own container, client config, running on https://auth.nas.domain

identity_providers:
  oidc:
    hmac_secret: ''
    jwks:
      - key: |
          -----BEGIN RSA PRIVATE KEY-----
          -----END RSA PRIVATE KEY-----
    clients:
      - client_id: 'sparkyfitness'
        client_name: 'SparkyFitness Server'
        client_secret: ''
        public: false
        authorization_policy: 'one_factor'
        token_endpoint_auth_method: 'client_secret_post'
        consent_mode: 'implicit'
        redirect_uris:
          - https://fitness.nas.domain/oidc-callback
        scopes: ['openid', 'profile', 'groups', 'email']
        userinfo_signed_response_alg: 'none'

Relevant Environment Variables (if applicable)

Please list any environment variables you have set that might be relevant to this issue (e.g., API keys, specific configuration flags). Do not share sensitive information like full API keys or passwords.

# Example:
# SPARKY_FITNESS_LOG_LEVEL=DEBUG
# NODE_ENV=development
# TZ=Etc/UTC

Preference Settings

Screenshot of your preference settings

Browser Console Log

Container Log for SparkyFitness

Please provide the container logs for the sparkyfitness service. You can usually obtain these logs using docker logs sparkyfitness or by checking your container orchestration platform's logging interface.

# Paste SparkyFitness container log here

Container Log for SparkyFitness_Server

Please provide the container logs for the sparkyfitness_server service. You can usually obtain these logs using docker logs sparkyfitness_server or by checking your container orchestration platform's logging interface.


[2025-12-27T00:41:38.805Z] [ERROR] OIDC callback error: outgoing request timed out after 3500ms
[2025-12-27T00:41:38.805Z] [ERROR] Error caught by centralized handler: outgoing request timed out after 3500ms RPError: outgoing request timed out after 3500ms
    at /app/SparkyFitnessServer/node_modules/openid-client/lib/helpers/request.js:140:13
    at async Client.grant (/app/SparkyFitnessServer/node_modules/openid-client/lib/client.js:1370:22)
    at async Client.callback (/app/SparkyFitnessServer/node_modules/openid-client/lib/client.js:520:24)
    at async /app/SparkyFitnessServer/openidRoutes.js:176:22
[2025-12-27T01:25:44.093Z] [ERROR] Error fetching OIDC discovery document from https://auth.nas.domain/.well-known/openid-configuration: TypeError: fetch is not a function
    at Object.getOidcProviderById (/app/SparkyFitnessServer/models/oidcProviderRepository.js:69:53)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getOidcClient (/app/SparkyFitnessServer/openidRoutes.js:17:22)
    at async /app/SparkyFitnessServer/openidRoutes.js:103:27

Screenshots/Videos (Optional)

If applicable, add screenshots or a short video to help explain your problem.

Additional Context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions