SAML auth failing with HTTP 403 “Unexpected request origin” at /securityRealm/finishLogin (NGINX ingress, Ping Identity)

Summary
Jenkins suddenly started throwing HTTP 403: Unexpected request origin (check your reverse proxy settings) during SAML authentication via Ping Identity. The failure occurs at the /securityRealm/finishLogin endpoint.

Note: Issue occurs with both the default SAML plugin and miniOrange SAML (free) to allow local+SAML troubleshooting.

Environment

  • Jenkins Version: 2.516.3-jdk21

  • Deployment: Kubernetes (Helm) with ArgoCD

  • Access: External NGINX Ingress (not via Helm chart)

  • IdP: Ping Identity (Ping reports no changes)

  • Started: A few days ago; previously working

Plugins tested

  • Default SAML plugin → same 403

  • miniOrange SAML (free) → same 403

Changes tried (no effect)

  • CSRF flags:

    -Dhudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID=true
    -Dhudson.security.csrf.requestfield=Jenkins-Crumb
    -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true
    
    
  • Ingress annotations (excerpt):

    nginx.ingress.kubernetes.io/proxy-body-size: "50m"
    nginx.ingress.kubernetes.io/proxy-buffer-size: "16k"
    nginx.ingress.kubernetes.io/use-forwarded-headers: "true"
    nginx.ingress.kubernetes.io/proxy-set-headers: jenkins-proxy-headers
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    
    
  • Added X-Forwarded-* headers via proxy config

  • Jenkins URL: explicitly set jenkinsUrl and jenkinsUrlProtocol in values.yaml

Questions

  1. Why would SAML auth suddenly fail with 403 without changes on our side or Ping’s side?

  2. Why do both SAML plugins fail identically—does this indicate a proxy/headers issue?

  3. What exact NGINX ingress headers/annotations are required for SAML callbacks to be accepted?

  4. What diagnostics help determine why /securityRealm/finishLogin rejects the Ping callback?

Context
Both plugins failing suggests an infrastructure / reverse-proxy header or origin validation issue.

Any help would be greatly appreciated!

The exact error text is an important clue. In Jenkins 2.516.3 source, CLIAction.doWs returns that message in the X-CLI-Error response header when the WebSocket CLI request’s Origin differs from the origin Jenkins derives from the request. That is a different check from a missing CSRF crumb.

Before changing more settings, identify the actual failing request in the browser Network panel: its URL, method, status and whether it has X-CLI-Error. Correlate its timestamp/path with the ingress and controller logs. If that header is present, check the routing/rewrites to explain why this CLI handler is involved when you expect /securityRealm/finishLogin. Temporarily setting the hudson.cli.CLIAction logger to FINE also records the rejected and expected origins. Share only the redacted path/header comparison, not SAML assertions, cookies or tokens.

If the failing request really is the SAML callback and has no such header, capture its own controller exception before treating the two failures as the same problem. Two plugins failing does not by itself identify which layer rejected the request.

Also, use-forwarded-headers is an ingress-nginx controller ConfigMap setting; adding nginx.ingress.kubernetes.io/use-forwarded-headers to an Ingress does not configure it. Verify the running controller’s effective configuration and the scheme/host/port reaching Jenkins, rather than just Helm values. Restore CSRF protection; disabling it is not a fix for this origin comparison.