feat(http): make tenant-id reject status configurable (#29)#34
Open
lu1tr0n wants to merge 1 commit into
Open
Conversation
Syntactic tenant-id validation failures now return 400 by default via quarkus.multi-tenant.http.tenant-id.reject-status; an auth-related TenantResolution.Rejected still returns 401.
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.
Hi @mathias82 — thanks again for the clear framing on #29. This implements it.
Closes #29.
What changed
quarkus.multi-tenant.http.tenant-id.reject-status(default 400) on thetenant-idconfig group.TenantFilteruses it only for the syntactic tenant-id validation failure (theResolved-but-invalid branch). An authentication-relatedTenantResolution.Rejected(e.g. an untrusted bearer token) is untouched and still returns 401.reject-status=401restores the previous single-status behaviour.One nuance worth a look during review:
TenantIdValidatorruns on everyResolvedoutcome, so a valid JWT whose tenant claim value breaks the length/charset policy is treated as a syntactic failure (→reject-status), while a bad token staysRejected(→ 401). That keeps "bad value" and "bad credential" cleanly separated, which I think matches the intent — happy to guard it differently if you'd prefer an authenticated-but-malformed claim to stay 401.Verification
TenantIdRejectStatusTestcovers the custom status plus "auth rejection stays 401";TenantIdValidationTestupdated to the new 400 default;TenantFilterDispatchTestconfirms theRejectedpath is unaffected.reject-status=422→ 422,reject-status=401→ back-compat,validation-enabled=false→ off), with the auth rejection staying 401 throughout.Docs and CHANGELOG are updated with the property and the auth-vs-syntactic distinction.
On the default: I went with 400 as proposed in the issue, but it's a one-liner to flip if you'd rather ship 401 as the default and let adopters opt into 400 — let me know and I'll adjust. Thanks!