Skip to content
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

api: support for external authz #2435

Merged
merged 35 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f9857e2
API for external auth
zhaohuabing Jan 12, 2024
4954d41
address comments
zhaohuabing Jan 16, 2024
869866e
kube gen
zhaohuabing Jan 16, 2024
dd86ea8
Update api/v1alpha1/ext_auth_types.go
zhaohuabing Jan 17, 2024
847ba38
address comments
zhaohuabing Jan 17, 2024
f73986f
merge main
zhaohuabing Jan 17, 2024
c70b262
add validation
zhaohuabing Jan 17, 2024
de62d99
test for validation
zhaohuabing Jan 17, 2024
d010fbd
fix test
zhaohuabing Jan 17, 2024
8d531de
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 17, 2024
916f09f
fix test
zhaohuabing Jan 17, 2024
8995519
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 18, 2024
271f050
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 22, 2024
1123f10
rename AllowedHeaders to AllowedClientHeaders
zhaohuabing Jan 23, 2024
a1217d2
fix lint
zhaohuabing Jan 23, 2024
86637f1
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 23, 2024
3532abc
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 24, 2024
15a34de
address comments
zhaohuabing Jan 24, 2024
b74bd4a
use host and port instead of URL to represent HTTP ExtAuth service
zhaohuabing Jan 26, 2024
d653479
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 26, 2024
017da1f
fix test
zhaohuabing Jan 26, 2024
e3f50a4
address comments
zhaohuabing Jan 26, 2024
b6039b4
address comments
zhaohuabing Jan 26, 2024
42372f5
fix test
zhaohuabing Jan 26, 2024
b4e37b5
fix test
zhaohuabing Jan 26, 2024
36da3b4
fix test
zhaohuabing Jan 26, 2024
db09774
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 27, 2024
aa6ae0d
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 27, 2024
b5d7301
fix check
zhaohuabing Jan 27, 2024
cdab2e7
add CACert
zhaohuabing Jan 29, 2024
b310129
add CACert
zhaohuabing Jan 29, 2024
0510fe5
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 30, 2024
d6cbffa
Merge branch 'main' into ext_auth_api
zhaohuabing Jan 30, 2024
212895f
clean TLSConfig
zhaohuabing Jan 30, 2024
eb7997f
fix gen
zhaohuabing Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions api/v1alpha1/ext_auth_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package v1alpha1

import (
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)

// ExtAuthServiceType specifies the types of External Authorization.
// +kubebuilder:validation:Enum=GRPC;HTTP
type ExtAuthServiceType string

const (
// GRPC external authorization service.
GRPC ExtAuthServiceType = "GRPC"

// HTTP external authorization service.
HTTP ExtAuthServiceType = "HTTP"
)

// ExtAuth defines the configuration for External Authorization.
type ExtAuth struct {
// Type decides the type of External Authorization.
// Valid ExtAuthServiceType values are "GRPC" or "HTTP".
// +kubebuilder:validation:Enum=GRPC;HTTP
// +unionDiscriminator
Type ExtAuthServiceType `json:"type"`

// GRPC defines the gRPC External Authorization service
// Only one of GRPCService or HTTPService may be specified.
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
GRPC *GRPCExtAuthService `json:"grpcService,omitempty"`

// HTTP defines the HTTP External Authorization service
// Only one of GRPCService or HTTPService may be specified.
HTTP *HTTPExtAuthService `json:"httpService,omitempty"`

// AllowedHeaders defines the client request headers that will be included
// in the request to the external authorization service.
// Note: If not specified, the default behavior of different external authorization
// services is different. All headers will be included in the check request
// to a gRPC authorization server, whereas no headers will be included in the
// check request to an HTTP authorization server.
AllowedHeaders []string `json:"allowedHeaders,omitempty"`
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
}

// GRPCExtAuthService defines the gRPC External Authorization service
type GRPCExtAuthService struct {
// Host is the hostname of the gRPC External Authorization service
Host gwapiv1a2.Hostname `json:"host"`

// Port is the network port of the gRPC External Authorization service
Port gwapiv1a2.PortNumber `json:"port"`
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved

// TLS defines the TLS configuration for the gRPC External Authorization service.
// Note: If not specified, the proxy will talk to the gRPC External
// Authorization service in plaintext.
TLS *TLSConfig `json:"tlsSettings,omitempty"`
}

// HTTPExtAuthService defines the HTTP External Authorization service
type HTTPExtAuthService struct {
// URL is the URL of the HTTP External Authorization service.
// The URL must be a fully qualified URL with a scheme, hostname,
// and optional port and path. Parameters are not allowed.
// The URL must use either the http or https scheme.
// If port is not specified, 80 for http and 443 for https are assumed.
// If path is specified, the authorization request will be sent to that path,
// or else the authorization request will be sent to the root path.
URL string `json:"url" yaml:"url"`
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved

// TLS defines the TLS configuration for the HTTP External Authorization service.
// TLS is only valid when the URL scheme is https. If the URL scheme is
// https, and TLS is not specified, the proxy will use the system default
// certificate pool to verify the server certificate.
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
TLS *TLSConfig `json:"tlsSettings,omitempty"`

// Authorization response headers that will be added to the original client request
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
// before sending it to the upstream server.
// Note that coexistent headers will be overridden.
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
AllowedUpstreamHeaders []string `json:"allowedUpstreamHeaders,omitempty"`
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
}

// TLSConfig describes a TLS configuration.
type TLSConfig struct {
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
// CertificateRefs contains a series of references to Kubernetes objects that
// contains TLS certificates and private keys. These certificates are used to
// establish a TLS handshake with the external authorization server.
//
// If this field is not specified, the proxy will not present a client certificate
// and will use the system default certificate pool to verify the server certificate.
// +optional
// +kubebuilder:validation:MaxItems=64
CertificateRefs []gwapiv1a2.SecretObjectReference `json:"certificateRefs,omitempty"`
}
5 changes: 5 additions & 0 deletions api/v1alpha1/securitypolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ type SecurityPolicySpec struct {
//
// +optional
OIDC *OIDC `json:"oidc,omitempty"`

// ExtAuth defines the configuration for External Authorization.
//
// +optional
ExtAuth *ExtAuth `json:"extAuth,omitempty"`
}

// SecurityPolicyStatus defines the state of SecurityPolicy
Expand Down
102 changes: 102 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading