Skip to content

fix: refresh SAML signing certificates and fail logins cleanly when the IdP is unreachable - #31

Merged
jbeers merged 1 commit into
coldbox-modules:developmentfrom
dougcain:fix/provider-resilience
Nov 9, 2026
Merged

jbeers merged 1 commit into
coldbox-modules:developmentfrom
dougcain:fix/provider-resilience

Conversation

@dougcain

@dougcain dougcain commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Three fixes in MicrosoftSAMLProvider and Auth.start, all to do with the IdP's metadata endpoint:

  1. Signing certificates never refreshed. initializeOpenSAMLLib() set certificatesCached = true once and never re-read the metadata. When the IdP rotated its signing certificate (Entra does this on expiry, or whenever an admin activates a new one), every login failed signature verification until the application restarted. The metadata is now re-read every certificateRefreshMinutes (default 60, settable on the provider definition). If a refresh fails, the certificates already held stay in use: cacheCerts only replaces them once new ones parse. The refresh is then retried after 5 minutes. A failed first fetch still throws, because there is nothing to verify with.
  2. processAuthorizationEvent threw on an unreachable metadata URL. initializeOpenSAMLLib() ran before the try, so a metadata timeout surfaced as an unhandled error instead of a failed SSOAuthorizationResponse. It now runs inside the try.
  3. Auth.start threw on the same failure. Since 3.x moved initialisation and the metadata fetch to first use, startAuthenticationWorflow() is where they first run. start() now logs the error and redirects to errorRedirect. The relocate() stays outside the try, because relocate aborts the request and a catch would swallow that.

The changelog has entries under Unreleased, and the readme has a short "SAML signing certificates" section.

Tests

  • New MicrosoftSAMLProviderSpec covers:
    • a failed login when initialisation throws
    • certificates fetched once and reused while fresh
    • a re-fetch after the interval
    • a configured interval
    • held certificates kept on a failed refresh, with a 5-minute retry and a warning logged
    • a failed first fetch throwing
    • a re-fetch after a URL change
  • AuthHandlerSpec adds a check that start() redirects to errorRedirect when the provider throws.
  • I ran equivalent specs against these files in a ColdBox 8 / BoxLang app. All pass. On the 3.3.0 code, the four that cover new behaviour fail and the rest pass. I haven't run the test-harness itself locally.
  • cfformat check passes on the changed files.

🤖 Generated with Claude Code

…he IdP is unreachable

The provider read its federation metadata once per application lifetime,
so an IdP certificate rotation broke every login until a restart. It now
re-reads the metadata every certificateRefreshMinutes (default 60) and keeps
the held certificates when a refresh fails.

OpenSAML initialisation and the metadata fetch moved to first use, so an
unreachable metadata URL surfaced as an unhandled error from both entry
points. processAuthorizationEvent now reports a failed login, and Auth.start
redirects to errorRedirect.
@jbeers
jbeers merged commit 56ae92c into coldbox-modules:development Nov 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants