Skip to content

Handle a missing email or ID token in domain verification - #56

Open
fjaeger wants to merge 1 commit into
synth:mainfrom
Mailbutler:domain-verifier-nil-guards
Open

fjaeger wants to merge 1 commit into
synth:mainfrom
Mailbutler:domain-verifier-nil-guards

Conversation

@fjaeger

@fjaeger fjaeger commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Two crashes in `DomainVerifier#verify!`:

  • No email in the auth hash. `email_domain.casecmp?(upn_domain)` is evaluated before `skip_domain_verification` is checked, so an auth hash without an email raises `NoMethodError` even when verification is turned off. This happens, for example, for tokens that only carry Outlook scopes. Fixed with `email_domain&.casecmp?`.
  • No ID token. When the token response has no `id_token` (no `openid` scope, or the tenant doesn't issue one), `domain_verified_jwt_claim` passes `nil` to `JWT.decode`, which raises `JWT::DecodeError`; that error isn't rescued. A missing ID token is now treated as "claim not present".

Specs are added for both cases. The existing "all strategies fail" spec now uses a non-nil ID token, so it still exercises the OIDC request path.

🤖 Generated with Claude Code

DomainVerifier#verify! called casecmp? on the email domain before checking
skip_domain_verification, so an auth hash without an email raised
NoMethodError even with verification turned off.

Without an ID token, domain_verified_jwt_claim passed nil to JWT.decode,
which raises JWT::DecodeError (not rescued). Treat a missing ID token as
'claim not present' instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant