fix(basic-auth): validate anonymous_consumer against schema#13682
Open
shreemaan-abhishek wants to merge 1 commit into
Open
fix(basic-auth): validate anonymous_consumer against schema#13682shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
anonymous_consumer sat as a sibling of properties rather than inside it, so core.schema.check() never validated it and any value was accepted. Move it into properties, matching key-auth, jwt-auth and hmac-auth.
membphis
approved these changes
Jul 10, 2026
nic-6443
approved these changes
Jul 10, 2026
AlinsRan
approved these changes
Jul 10, 2026
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.
Description
In
basic-auth, theanonymous_consumerfield is declared as a sibling ofpropertiesinstead of inside it:anonymous_consumeris not a JSON-Schema keyword at that level, and the schema does not setadditionalProperties = false, socore.schema.check()silently ignores it. The field is therefore never validated:anonymous_consumercan be a number, a boolean, a table, or an empty string andcheck_schemastill returnstrue.rewrite()then hands that value straight toconsumer.get_anonymous_consumer(), which expects a string.The other three auth plugins place the field correctly inside
properties— seekey-auth.lua:38,jwt-auth.lua:63,hmac-auth.lua:78— sobasic-authis the outlier. The field was introduced in #11917.This PR moves
anonymous_consumerintoproperties, so it is validated as the non-empty string it is already documented to be.Impact is limited to misconfiguration: there is no authentication bypass, and a correctly-configured
anonymous_consumer(a string) behaves exactly as before. Configs that set a non-string value now fail admin-API validation instead of being accepted and failing later at request time.No documentation change is needed —
docs/en/latest/plugins/basic-auth.mdalready documentsanonymous_consumerasstring, matching the other auth plugins; the code was what disagreed with the docs.Which issue(s) this PR fixes:
N/A
Checklist