-
Notifications
You must be signed in to change notification settings - Fork 149
Generate CRD for AuthenticationFilter with BasicAuth #4349
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
Merged
shaun-nx
merged 20 commits into
feat/authentication-filter-basic-auth
from
feat/basic-auth-crd
Dec 4, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a7bb5df
Add base AuthenticationFilter CRD for Basic Auth
shaun-nx 494a8d1
Fix validation for StatusCode
shaun-nx b7ef465
Merge branch 'feat/authentication-filter-basic-auth' into feat/basic-…
shaun-nx a127e6b
Run linter
shaun-nx da97201
Re-generate CRD
shaun-nx 1c6843d
Re-generate CRD
shaun-nx 8f5f2a4
Remove Bearer Auth Scheme
shaun-nx 89440ce
Re-generate CRD
shaun-nx 429367a
Fix lint error
shaun-nx 822ff85
Update comments. Make spec.basic an optional field
shaun-nx 0e495c1
Re-generate CRD. Format comments
shaun-nx 87aae3b
Add comments to AuthFailureBodyPolicy constants and AuthType constants
shaun-nx bf5de8f
Merge branch 'feat/authentication-filter-basic-auth' into feat/basic-…
shaun-nx 069104e
Merge branch 'feat/authentication-filter-basic-auth' into feat/basic-…
shaun-nx ac8f23f
Remove OnFailure type
shaun-nx 84a386b
Remove OnFailure from examples
shaun-nx 5d6d1fd
Remove status field from top level struct. Generate CRD
shaun-nx ca712fa
Re-add status field. Add `omitempty`
shaun-nx 864d161
Update validataion rule. Remove un-needed validation
shaun-nx 334c586
Add omitempty to BasicAuth
shaun-nx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
shaun-nx marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // +genclient | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:storageversion | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:resource:categories=nginx-gateway-fabric,shortName=authfilter;authenticationfilter | ||
| // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||
|
|
||
| // AuthenticationFilter configures request authentication and is | ||
| // referenced by HTTPRoute and GRPCRoute filters using ExtensionRef. | ||
| type AuthenticationFilter struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata"` | ||
|
|
||
| // Spec defines the desired state of the AuthenticationFilter. | ||
| Spec AuthenticationFilterSpec `json:"spec"` | ||
|
|
||
| // Status defines the state of the AuthenticationFilter. | ||
| Status AuthenticationFilterStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // AuthenticationFilterList contains a list of AuthenticationFilter resources. | ||
| type AuthenticationFilterList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata"` | ||
| Items []AuthenticationFilter `json:"items"` | ||
| } | ||
|
|
||
| // AuthenticationFilterSpec defines the desired configuration. | ||
| // +kubebuilder:validation:XValidation:message="for type=Basic, spec.basic must be set",rule="!(!has(self.basic) && self.type == 'Basic')" | ||
| // | ||
| //nolint:lll | ||
tataruty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type AuthenticationFilterSpec struct { | ||
| // Basic configures HTTP Basic Authentication. | ||
| // | ||
| // +optional | ||
| Basic *BasicAuth `json:"basic,omitempty"` | ||
|
|
||
| // Type selects the authentication mechanism. | ||
| Type AuthType `json:"type"` | ||
| } | ||
tataruty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // AuthType defines the authentication mechanism. | ||
| // | ||
| // +kubebuilder:validation:Enum=Basic; | ||
| type AuthType string | ||
|
|
||
| const ( | ||
| // AuthTypeBasic is the HTTP Basic Authentication mechanism. | ||
| AuthTypeBasic AuthType = "Basic" | ||
| ) | ||
|
|
||
| // BasicAuth configures HTTP Basic Authentication. | ||
| type BasicAuth struct { | ||
| // SecretRef allows referencing a Secret in the same namespace. | ||
| SecretRef LocalObjectReference `json:"secretRef"` | ||
|
|
||
| // Realm used by NGINX `auth_basic` directive. | ||
| // https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic | ||
| // Also configures "realm="<realm_value>" in WWW-Authenticate header in error page location. | ||
| Realm string `json:"realm"` | ||
| } | ||
tataruty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // LocalObjectReference specifies a local Kubernetes object. | ||
| type LocalObjectReference struct { | ||
| // Name is the referenced object. | ||
| Name string `json:"name"` | ||
| } | ||
|
|
||
| // AuthenticationFilterStatus defines the state of AuthenticationFilter. | ||
| type AuthenticationFilterStatus struct { | ||
| // Controllers is a list of Gateway API controllers that processed the AuthenticationFilter | ||
| // and the status of the AuthenticationFilter with respect to each controller. | ||
| // | ||
| // +kubebuilder:validation:MaxItems=16 | ||
| Controllers []ControllerStatus `json:"controllers,omitempty"` | ||
| } | ||
|
|
||
| // AuthenticationFilterConditionType is a type of condition associated with AuthenticationFilter. | ||
| type AuthenticationFilterConditionType string | ||
|
|
||
| // AuthenticationFilterConditionReason is a reason for an AuthenticationFilter condition type. | ||
| type AuthenticationFilterConditionReason string | ||
|
|
||
| const ( | ||
| // AuthenticationFilterConditionTypeAccepted indicates that the AuthenticationFilter is accepted. | ||
| // | ||
| // Possible reasons for this condition to be True: | ||
| // * Accepted | ||
| // | ||
| // Possible reasons for this condition to be False: | ||
| // * Invalid. | ||
| AuthenticationFilterConditionTypeAccepted AuthenticationFilterConditionType = "Accepted" | ||
|
|
||
| // AuthenticationFilterConditionReasonAccepted is used with the Accepted condition type when | ||
| // the condition is true. | ||
| AuthenticationFilterConditionReasonAccepted AuthenticationFilterConditionReason = "Accepted" | ||
|
|
||
| // AuthenticationFilterConditionReasonInvalid is used with the Accepted condition type when | ||
| // the filter is invalid. | ||
| AuthenticationFilterConditionReasonInvalid AuthenticationFilterConditionReason = "Invalid" | ||
| ) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.