-
Notifications
You must be signed in to change notification settings - Fork 749
Adds AuthenticationFilter Support to Kubernetes Provider #791
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
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ release-artifacts/ | |
|
|
||
| # Outputs | ||
| coverage.xml | ||
| cover.out | ||
|
|
||
| # `go mod vendor` | ||
| vendor/ | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ import ( | |
| gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" | ||
| gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" | ||
|
|
||
| "github.com/envoyproxy/gateway/api/config/v1alpha1" | ||
| egcfgv1a1 "github.com/envoyproxy/gateway/api/config/v1alpha1" | ||
|
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. can we combine these two into one ?
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. Shouldn't we keep them separate to simplify moving the Gateway API extensions, e.g. AuthenticationFilter, out of EG into a separate repo in the future? If we decide to remove the
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. trying to highlight the fact that current dir structure is confusing - either we have
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. Agreed. Per your request, I removed the
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. xref #809 to make a decision on API type grouping. IMO a separate PR should be submitted to resolve this issue. |
||
| egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -28,9 +29,14 @@ func init() { | |
| if err := clientgoscheme.AddToScheme(scheme); err != nil { | ||
| panic(err) | ||
| } | ||
| if err := v1alpha1.AddToScheme(scheme); err != nil { | ||
| // Add Envoy Gateway types. | ||
| if err := egcfgv1a1.AddToScheme(scheme); err != nil { | ||
| panic(err) | ||
| } | ||
| if err := egv1a1.AddToScheme(scheme); err != nil { | ||
| panic(err) | ||
| } | ||
| // Add Gateway API types. | ||
| if err := gwapiv1b1.AddToScheme(scheme); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // 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. | ||
|
|
||
| // This file contains code derived from Contour, | ||
| // https://github.com/projectcontour/contour | ||
| // and is provided here subject to the following: | ||
| // Copyright Project Contour Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package gatewayapi | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" | ||
|
|
||
| egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" | ||
| ) | ||
|
|
||
| func TestValidateAuthenFilterRef(t *testing.T) { | ||
| testCases := []struct { | ||
| name string | ||
| filter *gwapiv1b1.HTTPRouteFilter | ||
| expected bool | ||
| }{ | ||
| { | ||
| name: "request mirror filter", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterRequestMirror, | ||
| }, | ||
| expected: true, | ||
| }, | ||
| { | ||
| name: "url rewrite filter", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterURLRewrite, | ||
| }, | ||
| expected: true, | ||
| }, | ||
| { | ||
| name: "request header modifier filter", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterRequestHeaderModifier, | ||
| }, | ||
| expected: true, | ||
| }, | ||
| { | ||
| name: "request redirect filter", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterRequestRedirect, | ||
| }, | ||
| expected: true, | ||
| }, | ||
| { | ||
| name: "unsupported extended filter", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterExtensionRef, | ||
| ExtensionRef: &gwapiv1b1.LocalObjectReference{ | ||
| Group: "UnsupportedGroup", | ||
| Kind: "UnsupportedKind", | ||
| Name: "test", | ||
| }, | ||
| }, | ||
| expected: false, | ||
| }, | ||
| { | ||
| name: "extended filter with missing reference", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterExtensionRef, | ||
| }, | ||
| expected: false, | ||
| }, | ||
| { | ||
| name: "invalid authenticationfilter group", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterExtensionRef, | ||
| ExtensionRef: &gwapiv1b1.LocalObjectReference{ | ||
| Group: "UnsupportedGroup", | ||
| Kind: egv1a1.AuthenticationFilterKind, | ||
| Name: "test", | ||
| }, | ||
| }, | ||
| expected: false, | ||
| }, | ||
| { | ||
| name: "invalid authenticationfilter kind", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterExtensionRef, | ||
| ExtensionRef: &gwapiv1b1.LocalObjectReference{ | ||
| Group: gwapiv1b1.Group(egv1a1.GroupVersion.Group), | ||
| Kind: "UnsupportedKind", | ||
| Name: "test", | ||
| }, | ||
| }, | ||
| expected: false, | ||
| }, | ||
| { | ||
| name: "valid authenticationfilter", | ||
| filter: &gwapiv1b1.HTTPRouteFilter{ | ||
| Type: gwapiv1b1.HTTPRouteFilterExtensionRef, | ||
| ExtensionRef: &gwapiv1b1.LocalObjectReference{ | ||
| Group: gwapiv1b1.Group(egv1a1.GroupVersion.Group), | ||
| Kind: egv1a1.AuthenticationFilterKind, | ||
| Name: "test", | ||
| }, | ||
| }, | ||
| expected: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| tc := tc | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| err := ValidateHTTPRouteFilter(tc.filter) | ||
| if tc.expected { | ||
| require.NoError(t, err) | ||
| } else { | ||
| require.Error(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.