-
Notifications
You must be signed in to change notification settings - Fork 360
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
Support optional JWT authentication for an endpoint #3081
Comments
@ardikabs Thanks for raising this use case! It looks reasonable to me. Let's wait for other @envoyproxy/gateway-maintainers for further insights. |
I hope it is acceptable for me to mention #2496 as broadly related. There the feature request is to always require a token, but to either take a JWT bearer token from the Authorization header or if absent initiate the authorization code flow. |
how does |
|
I don't think it would ever be very common where you would want to allow an invalid token even in the scenario where the token is optional. IMO that sounds like a separate use-case for something like an |
@AliceProxy Yes, it's not a legitimate use case. |
Description:
There is a use case when both authenticated and non-authenticated users can access an endpoint, it would help like when it is intended to apply a rate limit based on the user login, say authenticated users will have a dedicated rate limit threshold compared to non-authenticated users.
For example on integrating optional JWT authentication with rate limit:
/api/v1/auth/generate-otp
(authenticated): 100 requests per hour per user login/api/v1/auth/generate-otp
(non-authenticated): 10 requests per hour per originating IP addressSince our implementation is built upon the specifications outlined in https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/jwt_authn/v3/config.proto#extensions-filters-http-jwt-authn-v3-jwtrequirement, accomplishing this can be done using the following configuration:
Proposal
Therefore in the Envoy Gateway implementation, we can add a new field such as
allowMissing
to theSecurityPolicy
to support this case, like below:Luckily, as we already have the
requiresAny
implementation in the code, integrating it above should be straightforward.gateway/internal/xds/translator/jwt.go
Lines 168 to 176 in 9416798
[optional Relevant Links:]
The text was updated successfully, but these errors were encountered: