-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to parameterize unauthenticated paths #12668
Conversation
Looks like CI caught a failure related to these changes. |
If we ever encounter a mismatched segment, break and set a flag to prevent false positives for prefix matches. If it is a match we need to do a prefix check. But we should not return unless HasPrefix also evaluates to true. Otherwise we should let the for loop continue to check other possibilities and only return false once all wildcard paths have been evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last question, otherwise looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but it'd be good to get an additional approver on this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Description
This PR adds support to parameterize unauthenticated paths for a framework.Backend. This is needed to allow the following unauthenticated API paths for the upcoming OIDC Provider feature:
oidc/provider/+/.well-known/*
oidc/provider/+/token
Background
Today, unauthenticated paths get stored in the loginPaths in the router when the backend is mounted. The structure used is a radix tree which is ultimately stored in an
atomic.Value
.The approach used in this PR is to store any unauthenticated paths containing wildcards in an array* of pre-split slices. All other unauthenticated paths (not containing wildcards) will continue to be stored in a radix tree. This PR introduces a new struct
loginPathsEntry
to hold both the array and radix tree.*Note that this sits in the hot path of requests so we are micro-optimizing by storing pre-split slices of path segments.
Alternative approaches
Several alternative approaches were considered:
*
character that is currently used to indicate a prefix match has a different meaning as a regular expression