-
Notifications
You must be signed in to change notification settings - Fork 618
agentgateway: http ext authz api #13044
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -948,22 +948,86 @@ type AgentExtProcPolicy struct { | |
| BackendRef gwv1.BackendObjectReference `json:"backendRef"` | ||
| } | ||
|
|
||
| // +kubebuilder:validation:ExactlyOneOf=grpc;http | ||
| type AgentExtAuthPolicy struct { | ||
| // backendRef references the External Authorization server to reach. | ||
| // | ||
| // Supported types: Service and Backend. | ||
| // +required | ||
| BackendRef gwv1.BackendObjectReference `json:"backendRef"` | ||
|
|
||
| // grpc specifies that the gRPC External Authorization | ||
| // [protocol](https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/auth/v3/external_auth.proto) should be used. | ||
| // +optional | ||
| GRPC *AgentExtAuthGRPC `json:"grpc,omitempty"` | ||
|
|
||
| // http specifies that the HTTP protocol should be used for connecting to the authorization server. | ||
| // The authorization server must return a `200` status code, otherwise the request is considered and authorization failure. | ||
| // +optional | ||
| HTTP *AgentExtAuthHTTP `json:"http,omitempty"` | ||
|
|
||
| // forwardBody configures whether to include the HTTP body in the request. If enabled, the request body will be | ||
| // buffered. | ||
| // +optional | ||
| ForwardBody *AgentExtAuthBody `json:"forwardBody,omitempty"` | ||
| } | ||
|
|
||
| type AgentExtAuthHTTP struct { | ||
| // path specifies the path to send to the authorization server. If unset, this defaults to the original request path. | ||
| // This is a CEL expression, which allows customizing the path based on the incoming request. | ||
| // For example, to add a prefix: `path: '"/prefix/" + request.path'`. | ||
| // +optional | ||
| Path *shared.CELExpression `json:"path,omitempty"` | ||
|
|
||
| // contextExtensions specifies additional arbitrary key-value pairs to send to the authorization server. | ||
| // redirect defines an optional expression to determine a path to redirect to on authorization failure. | ||
| // This is useful to redirect to a sign-in page. | ||
| // +optional | ||
| Redirect *shared.CELExpression `json:"redirect,omitempty"` | ||
|
|
||
| // allowedRequestHeaders specifies what additional headers from the client request | ||
| // will be sent to the authorization server. | ||
| // | ||
| // If unset, the following headers are sent by default: `Authorization`. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxItems=64 | ||
| AllowedRequestHeaders []ShortString `json:"allowedRequestHeaders,omitempty"` | ||
|
|
||
| // addRequestHeaders specifies what additional headers to add to the request to the authorization server. | ||
| // While allowedRequestHeaders just passes the original headers through, addRequestHeaders allows defining custom headers | ||
| // based on CEL Expressions. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxProperties=64 | ||
| AddRequestHeaders map[string]shared.CELExpression `json:"addRequestHeaders,omitempty"` | ||
|
|
||
| // allowedResponseHeaders specifies what headers from the authorization response | ||
| // will be copied into the request to the backend. | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxItems=64 | ||
| AllowedResponseHeaders []ShortString `json:"allowedResponseHeaders,omitempty"` | ||
|
|
||
| // metadata specifies what metadata fields should be constructed from the authorization response. These will be | ||
| // included under the `extauthz` variable in future CEL expressions. Setting this is useful to do things like logging | ||
| // usernames, without needing to include them as headers to the backend (as `allowedResponseHeaders` would). | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxProperties=64 | ||
| Metadata map[string]shared.CELExpression `json:"metadata,omitempty"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is a duplicated type between HTTP and gRPC is it worth moving up a level?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its duplicated type but has entirely different behavior. One is the metadata to populate in the grpc request, and the grpc server returns the response metadata. In http, there is no metadata to send in the request or response, and this field instead sets response metadata based on the HTTP response. Perhaps more explicit naming would help
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I wasn't paying close enough attention as was tricked by the similar naming. Is there a more specific term for the agentgateway metadata?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's long but maybe |
||
| } | ||
|
|
||
| type AgentExtAuthGRPC struct { | ||
| // contextExtensions specifies additional arbitrary key-value pairs to send to the authorization server in the `context_extensions` field. | ||
| // +kubebuilder:validation:MaxProperties=64 | ||
| // +optional | ||
| ContextExtensions map[string]string `json:"contextExtensions,omitempty"` | ||
| // metadata specifies metadata to be sent to the authorization server. | ||
| // This maps to the `metadata_context.filter_metadata` field of the request, and allows dynamic CEL expressions. | ||
| // If unset, by default the `envoy.filters.http.jwt_authn` key is set if the JWT policy is used as well, for compatibility. | ||
| // +kubebuilder:validation:MaxProperties=64 | ||
| // +optional | ||
| Metadata map[string]shared.CELExpression `json:"metadata,omitempty"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe |
||
| } | ||
|
|
||
| type AgentExtAuthBody struct { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
on the envoy side this was a shared type between gRPC and HTTP, is it useful to do the same here?
i.e. should we move this out of the HTTP-specific type?
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.
I kind of like it split since the docs are differnt for each (one defaults to all, the other does not) but I am fine either way.
tbh I don't get why anyone would not send all for gRPC but 🤷
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.
I can buy the split for the different defaults (it was very hard to accurately portray that in the shared envoy type!) but just to make sure I'm not missing something, I don't see this current in the gRPC extauth type yet, correct?
And separately, given:
I'm assuming this is to maintain the weird behavior envoy currently to e.g. enable compatibility with existing extauth servers?