Add support for HTTP Basic Authentication #2626
Replies: 5 comments 13 replies
-
Here's how Kuadrant supports this use case using policies: https://docs.kuadrant.io/kuadrant-operator/doc/user-guides/auth-for-app-devs-and-platform-engineers/#3-protect-the-toy-store-application-persona-app-developer. The example covers authentication and authorization. The latter you can ignore, but the former can easily shapeshift from API key to HTTP Basic Auth (RFC 7235) by simply replacing The |
Beta Was this translation helpful? Give feedback.
-
Thanks for raising this @zhaohuabing! x-ref #1494 which has some overlap |
Beta Was this translation helpful? Give feedback.
-
This is how Envoy Gateway supports Basic Auth: Envoy Gateway uses .htpasswd format to store the username-password pairs for authentication. The file is stored in a kubernetes secret and referenced in the SecurityPolicy configuration. The secret is an Opaque secret, and the username-password pairs must be stored in the key ".htpasswd". https://github.com/envoyproxy/gateway/blob/main/site/content/en/latest/user/basic-auth.md apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
name: basic-auth-example
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: backend
basicAuth:
users:
name: "basic-auth" Secret:
The username-password pairs: $ cat .htpasswd
foo:{SHA}Ys23Ag/5IOWqZCw9QGaVDdHwH00=
foo1:{SHA}djZ11qHY0KOijeymK7aKvYuvhvM= |
Beta Was this translation helpful? Give feedback.
-
The more I think about this and other auth concepts, the more that I think I'd like to see these as standard Filters. We don't have to use Policy for this, and these operations feel similar to me to Extended Filters like Request Redirect or URL Rewrite (at least to begin with). Each of them manipulates the HTTP request to add additional behavior, which feels to me like the definition of a Filter. The existing Envoy Gateway prior art (which is really neat, btw), is actually an example of a Policy that's actually an Inherited Policy, not a Direct one - since it can be applied at the Gateway level and affect config on HTTPRoute objects. I think that behavior is desirable, but we should make it more explicit. First, we introduce the Filters for whatever auth methods we want (Basic, JWT, and Oauth2 seem pretty reasonable to target, with others left for ExtensionRef). This can be done as a discreet set of changes. Then, we add an My reason for suggesting this is that I think that the main reason that EG went with a Policy is that the additional overhead of managing an Policy vs an ExtensionRef Filter CRD is not too big, and can also be used at the Gateway level. But because we're doing this upstream now, we can add new fields to HTTPRoute itself and make them experimental fields that will probably end up in Extended support once they move to the Standard channel. (That is, they'll be optional but have conformance tests). Then, we can add defaulting or overriding at a Gateway or above level at a later date if we need it. I'm pretty confident at least some users will want that, but this way we're getting something useful into the spec as quickly as possible. |
Beta Was this translation helpful? Give feedback.
-
@youngnick, separate discussion about this sentence:
I thought Inherited Policy Attachment was "all about the defaults and overrides." If I simply attach an AuthPolicy A to a Gateway object, I would expect that policy to apply to all routes accepted through that gateway. At least until a more specific AuthPolicy B is attached to a particular HTTPRoute; in which case, without defaults and overrides, AuthPolicy B would fully replace the behavior previously imposed by AuthPolicy A, but only for the particular HTTPRoute AuthPolicy B is attached to. For all other HTTPRoutes, AuthPolicy A remains. Wouldn't this be a typical description of Direct Policy Attachment? |
Beta Was this translation helpful? Give feedback.
-
What would you like to be added:
The ability to configure HTTP Basic Authentication on a Gateway or an HTTPRoute.
Why this is needed:
HTTP Basic Authentication is a simple authentication scheme that uses a username and password pair in the HTTP request header. It's widely used in web applications and APIs and supported by Gateway implementations.
Existing Implementations:
Some existing data planes that support Basic Authentication
Some existing control planes that support Basic Authentication
Relates to envoyproxy/gateway#1660
Beta Was this translation helpful? Give feedback.
All reactions