Raise on blank issuer in resolve_issuer#299
Merged
55728 merged 1 commit intoJun 3, 2026
Merged
Conversation
Since v1.10.0, `resolve_issuer` dispatches arity-2 issuer blocks with `(resource_owner, application)`. In the discovery context both are nil, so an existing arity-2 block that relied on the v1.9.0 behavior (where DiscoveryController passed the request as the first argument) can return nil. `resolve_issuer` then silently coerced that to `""` via `to_s`, producing a discovery document whose `issuer` was empty while the ID token `iss` was the configured value -- OIDC clients reject the mismatch. Guard against this by raising `Errors::InvalidConfiguration` when the resolved issuer is blank, mirroring the existing `signing_key` handling. This applies to both the static and callable paths, so a misconfigured issuer now fails loudly instead of shipping a broken discovery document. Specs that reconfigured OpenID Connect without an issuer (and only asserted unrelated fields) relied on the old silent-"" behavior; they now set a valid issuer.
ddce842 to
1ea5798
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes Doorkeeper::OpenidConnect.resolve_issuer fail fast when the configured issuer resolves to a blank value, preventing discovery documents from advertising an empty issuer and surfacing misconfigured issuer callbacks closer to the source of the problem (Fixes #298).
Changes:
- Add a
blank?guard inresolve_issuerthat raisesErrors::InvalidConfigurationwhen the resolved issuer is blank (static or callable). - Add an I18n error message for the new invalid-issuer configuration error.
- Update and extend specs to cover the new behavior and ensure existing discovery specs explicitly configure a valid issuer where needed.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/doorkeeper/openid_connect.rb | Computes issuer value (callable/static) and raises InvalidConfiguration when it resolves blank. |
| config/locales/en.yml | Adds issuer_not_configured translation string used by the new guard. |
| spec/lib/openid_connect_spec.rb | Adds test coverage for raising on blank issuer from callable and static configurations. |
| spec/controllers/discovery_controller_spec.rb | Updates partial-config contexts to set a non-blank issuer to avoid new configuration error. |
| spec/support/doorkeeper_configuration.rb | Ensures shared spec helper configures an issuer so unrelated signing-algorithm specs don’t fail. |
| CHANGELOG.md | Documents the behavior change and links it to #298 / #299. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1ea5798 to
4d4e791
Compare
Collaborator
Author
|
Thanks for the review! 👀✨🛠️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #298
Problem
Since v1.10.0,
Doorkeeper::OpenidConnect.resolve_issuerunified issuer dispatch and calls arity-2 issuer blocks with(resource_owner, application).In the discovery context both arguments are
nil. An existing arity-2 block that relied on the v1.9.0 behavior — whereDiscoveryControllercalledissuer.call(request)and the block received the request as its first argument — now receivesniland can returnnil.resolve_issuerthen silently coerced thatnilto""viato_s. The result was a discovery document advertising an emptyissuer, while the ID tokenissclaim still carried the configured value. OIDC clients reject this mismatch, so the failure surfaced far from its cause (a broken callback) instead of at the misconfiguration.This is the scenario reported in #298.
Change
resolve_issuernow raisesErrors::InvalidConfigurationwhen the resolved issuer is blank, mirroring the existingsigning_keyhandling (signing_key must resolve to at least one key). The guard covers both the static-value and callable paths, so any misconfigured issuer (anilblock result, an empty string, or whitespace) now fails loudly instead of shipping a broken discovery document.The issuer argument unification itself is intentional and unchanged — this PR only adds a fail-fast guard on the resolved value.
Migration
For blocks that previously relied on the discovery-context request:
or, for a constant issuer:
Files
lib/doorkeeper/openid_connect.rbresolve_issuercomputes the value, then raisesInvalidConfigurationifblank?. Covers static + callable paths.config/locales/en.ymlissuer_not_configuredmessage, following thesigning_key_not_configuredprecedent.spec/lib/openid_connect_spec.rbnilin the discovery context (the reported case), and a blank static value.spec/controllers/discovery_controller_spec.rbprotocol/discovery_url_options/ end-session) now set a validissuer. They previously relied on the silent-""behavior.spec/support/doorkeeper_configuration.rbconfigure_doorkeeperhelper now sets an issuer (fixes the EC/HMACas_jws_tokenexamples in one place).Notes
blank?(notempty?) is used so a whitespace-only issuer is also rejected.IdToken#as_jsontest that stubsissuer: nilto assertissis omitted is unaffected — it stubs the instance method and never reachesresolve_issuer.Testing
openid_connect_spec,id_token_spec,discovery_controller_spec): 85 examples, 0 failures