fix(auth): infer RS256 from RSA+sig when JWK alg is missing#65
Open
AdvenRanises wants to merge 1 commit into
Open
fix(auth): infer RS256 from RSA+sig when JWK alg is missing#65AdvenRanises wants to merge 1 commit into
AdvenRanises wants to merge 1 commit into
Conversation
RFC 7517 defines alg as OPTIONAL. Microsoft Entra omits it from JWKS keys. This change infers RS256 for RSA keys with use=sig, and replaces the opaque InternalError with a descriptive MissingAlgorithm error. Signed-off-by: AdvenRanises <evanderranises@gmail.com>
43c164a to
2361dc2
Compare
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 #60.
Microsoft Entra ID JWKS endpoints cause the Lore Server to fail on startup with a generic "Internal Error" because Entra omits the optional "alg" field from its JWKS keys. The current implementation incorrectly treats "alg" as required, causing valid JWKS documents to be rejected without any useful error message.
This change falls back to "RS256" for RSA keys when "alg" is missing and replaces the generic "InternalError" with a descriptive "MissingAlgorithm { kid }" error when the algorithm cannot be determined.
Verified with "cargo check -p lore-server --lib". Existing providers continue to work, and Microsoft Entra JWKS endpoints now load successfully.