Support multiple valid header and query keys #14
Merged
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.
Changed
ApiKeyAuthenticationOptions
to accept multiple allowedHeaderKeys
andQueryKeys
, so that multiple header and query keys can be valid.If multiple valid query/header keys are added to a request, then each value for each valid key are validated as api key.
For example:
https://localhost:44362/TestApiKey?my-first-key=ABC&my-second-key=DEF
If both
my-first-key
andmy-second-key
are configured as valid keys (throughApiKeyAuthenticationOptions.QueryKeys
), then bothABC
andDEF
are validated. The first valid API key is used to create a valid ClaimsPrinciple. If the first checked api key is not valid, then the next is checked before failing authentication.