Skip to content

Commit eb0b8ee

Browse files
committed
Fix typos and indentation
1 parent f1b1df6 commit eb0b8ee

File tree

1 file changed

+59
-62
lines changed

1 file changed

+59
-62
lines changed

docs/proposals/authentication-filter.md

Lines changed: 59 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This new filter should eventually expose all forms of authentication available t
1414
- Design Authentication CRD with Basic Auth and JWT Auth in mind
1515
- Determine initial resource specification
1616
- Evaluate filter early in request processing, occurring before URLRewrite, header modifiers and backend selection
17-
- Authentication failures returns 401 Unauthorized by default
17+
- Authentication failures return 401 Unauthorized by default
1818
- Ensure response codes are configurable
1919

2020
## Non-Goals
@@ -25,9 +25,9 @@ This new filter should eventually expose all forms of authentication available t
2525

2626
## Introduction
2727

28-
This document focuses explicitly on Authentication (AuthN) and not Authorization (AuthZ). Authentication (AuthN) defines the verification of identity. It asks the question, "Who are you?". This is different from Authorization (AuthZ), which preceeds Authentication. It asks the question, "What are you allowed to do".
28+
This document focuses explicitly on Authentication (AuthN) and not Authorization (AuthZ). Authentication (AuthN) defines the verification of identity. It asks the question, "Who are you?". This is different from Authorization (AuthZ), which follows Authentication. It asks the question, "What are you allowed to do?"
2929

30-
This document also focus on HTTP Basic Authentication and JWT Authentication. Other authentication methods such as OpenID Connect (OIDC) are mentioned, but are not part of the CRD design. These will be covered in future design and implementation tasks.
30+
This document also focuses on HTTP Basic Authentication and JWT Authentication. Other authentication methods such as OpenID Connect (OIDC) are mentioned, but are not part of the CRD design. These will be covered in future design and implementation tasks.
3131

3232

3333
## Use Cases
@@ -68,7 +68,7 @@ This portion also contains:
6868
- Example HTTPRoutes and NGINX configuration
6969
3. Example spec for JWT Auth
7070
- Example HTTPRoutes
71-
- Examples for Local & Remote JWKS configration
71+
- Examples for Local & Remote JWKS configuration
7272
- Example NGINX configuration for both Local & Remote JWKS
7373
- Example of additional optional fields
7474

@@ -80,7 +80,7 @@ Below is the Golang API for the `AuthenticationFilter` API:
8080
package v1alpha1
8181

8282
import (
83-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
83+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8484
"github.com/nginx/nginx-gateway-fabric/v2/apis/v1alpha1"
8585
)
8686

@@ -111,9 +111,9 @@ type AuthenticationFilter struct {
111111

112112
// AuthenticationFilterList contains a list of AuthenticationFilter resources.
113113
type AuthenticationFilterList struct {
114-
metav1.TypeMeta `json:",inline"`
115-
metav1.ListMeta `json:"metadata,omitempty"`
116-
Items []AuthenticationFilter `json:"items"`
114+
metav1.TypeMeta `json:",inline"`
115+
metav1.ListMeta `json:"metadata,omitempty"`
116+
Items []AuthenticationFilter `json:"items"`
117117
}
118118

119119
// AuthenticationFilterSpec defines the desired configuration.
@@ -151,19 +151,19 @@ const (
151151

152152
// BasicAuth configures HTTP Basic Authentication.
153153
type BasicAuth struct {
154-
// SecretRef allows referencing a Secret in the same namespace.
155-
SecretRef LocalObjectReference `json:"secretRef"`
154+
// SecretRef allows referencing a Secret in the same namespace.
155+
SecretRef LocalObjectReference `json:"secretRef"`
156156

157-
// Realm used by NGINX `auth_basic` directive.
158-
// https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic
159-
// Also configures "realm="<realm_value>" in WWW-Authenticate header in error page location.
160-
Realm string `json:"realm"`
157+
// Realm used by NGINX `auth_basic` directive.
158+
// https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic
159+
// Also configures "realm="<realm_value>" in WWW-Authenticate header in error page location.
160+
Realm string `json:"realm"`
161161
}
162162

163163
// LocalObjectReference specifies a local Kubernetes object.
164164
type LocalObjectReference struct {
165-
// Name is the referenced object.
166-
Name string `json:"name"`
165+
// Name is the referenced object.
166+
Name string `json:"name"`
167167
}
168168

169169
// JWTKeyMode selects where JWT keys come from.
@@ -296,9 +296,9 @@ type JWKSCache struct {
296296
type JWTType string
297297

298298
const (
299-
JWTTypeSigned JWTType = "signed"
300-
JWTTypeEncrypted JWTType = "encrypted"
301-
JWTTypeNested JWTType = "nested"
299+
JWTTypeSigned JWTType = "signed"
300+
JWTTypeEncrypted JWTType = "encrypted"
301+
JWTTypeNested JWTType = "nested"
302302
)
303303

304304
// AuthScheme enumerates supported WWW-Authenticate schemes.
@@ -364,20 +364,20 @@ In the case of Basic Auth, the deployed Secret and HTTPRoute may look like this:
364364
365365
#### Secret referenced by filter
366366
367-
To create this kind of secreet for Basic Auth first run this command:
367+
To create this kind of secret for Basic Auth first run this command:
368368
369369
```bash
370370
htpasswd -c auth user
371371
```
372372

373-
This will create a file called `auth` with the user name and an MD5 hashes password:
373+
This will create a file called `auth` with the username and an MD5-hashed password:
374374

375375
```bash
376376
cat auth
377377
user:$apr1$prQ3Bh4t$A6bmTv7VgmemGe5eqR61j0
378378
```
379379

380-
Use these options in the `htpasswd` command for stronger hashing algorithims:
380+
Use these options in the `htpasswd` command for stronger hashing algorithms:
381381

382382
```bash
383383
-2 Force SHA-256 hashing of the password (secure).
@@ -391,7 +391,7 @@ You can then run this command to generate the secret from the `auth` file:
391391
kubectl create secret generic basic-auth --from-file=auth
392392
```
393393

394-
Note: `auth` will be the default key for secrets referenced `AuthenticationFilters` of `Type: Basic`.
394+
Note: `auth` will be the default key for secrets referenced by `AuthenticationFilters` of `Type: Basic`.
395395

396396
Example secret:
397397

@@ -437,7 +437,7 @@ spec:
437437
438438
Note: For Basic Auth, NGF will store the file used by `auth_basic_user_file` in `/etc/nginx/secrets/`
439439
The full path will use the `name` and `key` of the secret referenced by `AuthenticationFilter`
440-
In this case, the full path will be `/etc/nginx/secrets/basic-auth-users/htpasswd`
440+
In this case, the full path will be `/etc/nginx/secrets/basic-auth-users/auth`
441441

442442
```nginx
443443
http {
@@ -475,9 +475,9 @@ http {
475475

476476
### Example spec for JWT Auth
477477

478-
For JWT Auth, there is two options.
478+
For JWT Auth, there are two options.
479479

480-
1. Local JWKS file stored as as a Secret
480+
1. Local JWKS file stored as a Secret
481481
2. Remote JWKS from an IdP provider like Keycloak
482482

483483
#### Example JWT AuthenticationFilter with Local JWKS
@@ -534,7 +534,7 @@ To create the example secret, run the following command:
534534
kubectl create secret generic basic-auth --from-file=jwks.json
535535
```
536536

537-
Note: `jwks.json` will be the default key for secrets referenced `AuthenticationFilters` of `Type: JWT`.
537+
Note: `jwks.json` will be the default key for secrets referenced by `AuthenticationFilters` of `Type: JWT`.
538538

539539
```yaml
540540
apiVersion: v1
@@ -610,7 +610,7 @@ http {
610610
611611
# File-based JWKS
612612
# Path is generated by NGF using the name and key from the secret
613-
auth_jwt_key_file /etc/nginx/keys/jwt-keys-secure/jwks;
613+
auth_jwt_key_file /etc/nginx/keys/jwt-keys-secure/jwks.json;
614614
615615
# Optional: key cache duration
616616
auth_jwt_key_cache 10m;
@@ -650,8 +650,8 @@ http {
650650

651651
These are some directives the `Remote` mode uses over the `File` mode:
652652

653-
- `auth_jwt_key_request`: When using the `Remote` mode, this is used in place of `auth_jwt_key_file`. This will call the `internal` NGINX location `/_ngf-internal_jwks_uri` to redirect the request to the external auth provider (e.g. KeyCloak)
654-
- `proxy_cache_path`: This is used to configuring caching of the JWKS after an initial request allowing subsequent requests to not request re-authenticaiton for a time
653+
- `auth_jwt_key_request`: When using the `Remote` mode, this is used in place of `auth_jwt_key_file`. This will call the `internal` NGINX location `/_ngf-internal_jwks_uri` to redirect the request to the external auth provider (e.g. Keycloak)
654+
- `proxy_cache_path`: This is used to configure caching of the JWKS after an initial request, allowing subsequent requests to avoid re-authentication for a time
655655

656656
```nginx
657657
http {
@@ -753,8 +753,8 @@ spec:
753753

754754
### Attachment
755755

756-
Filters must be attached to a HTTPRoute at the `rules.matches` level.
757-
This means that a single `AuthenticationFilter` may be attached mutliple times to a single HTTPRoute.
756+
Filters must be attached to an HTTPRoute at the `rules.matches` level.
757+
This means that a single `AuthenticationFilter` may be attached multiple times to a single HTTPRoute.
758758

759759
#### Basic example
760760

@@ -766,10 +766,10 @@ This example shows a single HTTPRoute, with a single `filter` defined in a `rule
766766

767767
#### Referencing multiple AuthenticationFilter resources in a single rule
768768

769-
Only a single `AuthenticationFilter` may be referened in a single rule.
769+
Only a single `AuthenticationFilter` may be referenced in a single rule.
770770

771-
The `Status` the HTTPRoute/GRPCRoute in this scenario should be set to `Invalid`, and the resource should be `Rejected`.
772-
In this scenario, the route rule that is referencing multiple `AuthenticationFilter` resources will be `Rejected`/
771+
The Status of the HTTPRoute/GRPCRoute in this scenario should be set to `Invalid`, and the resource should be `Rejected`.
772+
In this scenario, the route rule that is referencing multiple `AuthenticationFilter` resources will be `Rejected`.
773773
All other route rules will remain working.
774774

775775
The HTTPRoute/GRPCRoute resource will display an `UnresolvedRef` message to inform the user that the rule has been `Rejected`.
@@ -812,7 +812,7 @@ spec:
812812
#### Referencing an AuthenticationFilter resource that is invalid
813813

814814
Note: With appropriate use of CEL validation, we are less likely to encounter a scenario where an AuthenticationFilter has been deployed to the cluster with an invalid configuration.
815-
If this does happen, and a route rule references this AuthenticationFilter, the route rule will be set to `Invalid` and the the HTTPRoute/GRPCRoute will display the `UnresolvedRef` status.
815+
If this does happen, and a route rule references this AuthenticationFilter, the route rule will be set to `Invalid` and the HTTPRoute/GRPCRoute will display the `UnresolvedRef` status.
816816

817817
#### Attaching a JWT AuthenticationFilter to a route when using NGINX OSS
818818

@@ -836,13 +836,13 @@ For a filter to be considered "resolved", it must:
836836
Invalid resolved filter scenarios:
837837

838838
- Resolved filter that references a secret that does not exist
839-
- Resolved filter that referenced a secret with the incorrect data key
839+
- Resolved filter that references a secret with the incorrect data key
840840

841841
Valid reference scenarios:
842842

843843
- Resolved filter referenced by a single route rule within a single HTTP/GRPCRoute
844844
- Resolved filter referenced by multiple route rules within a single HTTP/GRPCRoute
845-
- Resolved filter reference by multiple HTTP/GRPCRoutes
845+
- Resolved filter referenced by multiple HTTP/GRPCRoutes
846846

847847
Invalid reference scenarios:
848848

@@ -871,12 +871,12 @@ Proxy cache TTL should be configurable and set to a reasonable default, reducing
871871

872872
### Key rotation
873873

874-
Users should be advised to regularly rotate their JWKS keys in cases where they chose to reference a local JWKS via a `secrefRef`
874+
Users should be advised to regularly rotate their JWKS keys in cases where they choose to reference a local JWKS via a `secretRef`.
875875

876876
### Optional headers
877877

878-
Below are a list of optional defensive headers that user's may choose to include.
879-
In certain scenarios, these headers may be deployed to improve overall security from client reponses.
878+
Below are a list of optional defensive headers that users may choose to include.
879+
In certain scenarios, these headers may be deployed to improve overall security from client responses.
880880

881881
```nginx
882882
add_header Content-Type "text/plain; charset=utf-8" always;
@@ -887,42 +887,42 @@ add_header Cache-Control "no-store" always;
887887
Detailed header breakdown:
888888

889889
- Content-Type: "text/plain; charset=utf-8"
890-
- This header explicitly set the body as plain text. This prevents browsers from treating the response as HTML or JavaScript, and is effective at mitigating Cross-side scrpting (XSS) through error pages
890+
- This header explicitly sets the body as plain text. This prevents browsers from treating the response as HTML or JavaScript, and is effective at mitigating Cross-site scripting (XSS) through error pages
891891

892892
- X-Content-Type-Options: "nosniff"
893-
- This header prevents content type confusion. This occurrs when browsers guesses HTML & JavaScript, and executes it despite a benign type.
893+
- This header prevents content type confusion. This occurs when browsers guess HTML and JavaScript, and execute it despite a benign type.
894894

895895
- Cache-Control: "no-store"
896-
- This header informs browsers and proxies not to cache the response. Avoids sensitive, auth-related content, from being being stored and served later to unintended recipients.
896+
- This header informs browsers and proxies not to cache the response. Avoids sensitive, auth-related content from being stored and served later to unintended recipients.
897897

898898

899899
### Validation
900900

901-
When referencing an `AuthenticationFilter` in either a HTTPRoute or GRPCRoute, it is important that we ensure all configurable fields are validated, and that the resulting NGINX configuration is correct and secure.
901+
When referencing an `AuthenticationFilter` in either an HTTPRoute or GRPCRoute, it is important that we ensure all configurable fields are validated, and that the resulting NGINX configuration is correct and secure.
902902

903-
All fields in the `AuthenticationFilter` will be validated with Open API Schema.
903+
All fields in the `AuthenticationFilter` will be validated with OpenAPI Schema.
904904
We should also include [CEL](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) validation where required.
905905

906-
We should validated that only one `AuthenticationFilter` is referenced per-rule. Multiple references to an `AuthenticationFilter` in a single rule should result in an `Invalid` HTTPRoute/GRPCRoute, and the rule should be `Rejected`.
906+
We should validate that only one `AuthenticationFilter` is referenced per-rule. Multiple references to an `AuthenticationFilter` in a single rule should result in an `Invalid` HTTPRoute/GRPCRoute, and the rule should be `Rejected`.
907907

908908
This scenario can use the status `RouteConditionPartiallyInvalid` defined in the Gateway API here: https://github.com/nginx/nginx-gateway-fabric/blob/3934c5c8c60b5aea91be4337d63d4e1d8640baa8/internal/controller/state/conditions/conditions.go#L402
909909

910910
## Alternatives
911911

912912
The Gateway API defines a means to standardise authentication through use of the [HTTPExternalAuthFilter](https://gateway-api.sigs.k8s.io/reference/spec/#httpexternalauthfilter) available in the HTTPRoute specification.
913913

914-
This allows users to reference an external authentication services, such as Keycloak, to handle the authentication requests.
914+
This allows users to reference an external authentication service, such as Keycloak, to handle the authentication requests.
915915
While this API is available in the experimental channel, it is subject to change.
916916

917917
Our decision to go forward with our own `AuthenticationFilter` was to ensure we could quickly provide authentication to our users while allowing us to closely monitor progress of the ExternalAuthFilter.
918918

919-
It is certainly possible for us to provide an External Authentication Services that leverages NGINX and is something we can further investigate as the API progresses.
919+
It is certainly possible for us to provide an External Authentication Service that leverages NGINX and is something we can further investigate as the API progresses.
920920

921921
## Additional considerations
922922

923-
### Documenting filter behavour
923+
### Documenting filter behavior
924924

925-
In regards to documentation of filter behaviour with the `AuthenticationFilter`, the Gateway API documentation on filters states the following:
925+
In regards to documentation of filter behavior with the `AuthenticationFilter`, the Gateway API documentation on filters states the following:
926926

927927
```text
928928
Wherever possible, implementations SHOULD implement filters in the order they are specified.
@@ -935,10 +935,10 @@ document that behavior.
935935

936936
## Stretch Goals
937937

938-
### Custom authentiation failure response
938+
### Custom authentication failure response
939939

940940
By default, authentication failures return a 401 response.
941-
If a used wanted to change this response code, or include additioanl headers in this response, we can include a custom named location that can be called by the [error_page](https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page) directive.
941+
If a user wanted to change this response code, or include additional headers in this response, we can include a custom named location that can be called by the [error_page](https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page) directive.
942942

943943
Example AuthenticationFilter configuration:
944944

@@ -977,15 +977,15 @@ server{
977977
}
978978
```
979979

980-
If we support this configuration, 3xx response codes should not be allowed and AuthenticationFilter.onFailure must not support redirect targets. This is to prevent to prevent open-redirect abuse.
980+
If we support this configuration, 3xx response codes should not be allowed and AuthenticationFilter.onFailure must not support redirect targets. This is to prevent open-redirect abuse.
981981

982982
We should only allow 401 and 403 response codes.
983983

984984
### Cross namespace access
985985

986986
When referencing secrets for Basic Auth and JWT Auth, the initial implementation will use `LocalObjectReference`.
987987

988-
Future updates to this will use the `NamespacedSecretKeyReference` in conjunction with `ReferenceGrants` to support access to secrets in different namespace`
988+
Future updates to this will use the `NamespacedSecretKeyReference` in conjunction with `ReferenceGrants` to support access to secrets in different namespaces.
989989

990990
Struct for `NamespacedSecretKeyReference`:
991991

@@ -1001,9 +1001,8 @@ type NamespacedSecretKeyReference struct {
10011001
}
10021002
```
10031003

1004-
For initial implementaion, both Basic Auth and Local JWKS should will only have access to Secrets in the same namespace.
1004+
For the initial implementation, both Basic Auth and Local JWKS will only have access to Secrets in the same namespace.
10051005

1006-
Example: Grant BasicAuth in app-ns to read a Secret in security-ns
10071006
Example: Grant BasicAuth in app-ns to read a Secret in security-ns
10081007

10091008
```yaml
@@ -1023,7 +1022,6 @@ spec:
10231022
name: basic-auth-users
10241023
```
10251024
1026-
AuthenticationFilter referencing the cross-namespace Secret
10271025
AuthenticationFilter referencing the cross-namespace Secret
10281026
10291027
```yaml
@@ -1043,10 +1041,9 @@ spec:
10431041
10441042
### Additional Fields for JWT
10451043
1046-
`require`, `tokenSource` and `propagation` are some additional fields that may be incldued in future updates to the API.
1044+
`require`, `tokenSource` and `propagation` are some additional fields that may be included in future updates to the API.
10471045
These fields allow for more customization of how the JWT auth behaves, but aren't required for the minimal delivery of JWT Auth.
10481046

1049-
Example of what implementation of these fields might look like:
10501047
Example of what implementation of these fields might look like:
10511048

10521049
```yaml
@@ -1073,7 +1070,7 @@ spec:
10731070
- "cli"
10741071
10751072
# Where client presents the token
1076-
# By defaults to reading from Authorization header (Bearer)
1073+
# By default, reading from Authorization header (Bearer)
10771074
tokenSource:
10781075
type: Header
10791076
# Alternative: read from a cookie named tokenName
@@ -1194,7 +1191,7 @@ type HeaderValue struct {
11941191

11951192
- [Gateway API ExternalAuthFilter GEP](https://gateway-api.sigs.k8s.io/geps/gep-1494/)
11961193
- [HTTPExternalAuthFilter Specification](https://gateway-api.sigs.k8s.io/reference/spec/#httpexternalauthfilter)
1197-
- [Kubernetes documentation on CEL validaton](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules)
1194+
- [Kubernetes documentation on CEL validation](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules)
11981195
- [NGINX HTTP Basic Auth Module](https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html)
11991196
- [NGINX JWT Auth Module](https://nginx.org/en/docs/http/ngx_http_auth_jwt_module.html)
12001197
- [NGINX OIDC Module](https://nginx.org/en/docs/http/ngx_http_oidc_module.html)

0 commit comments

Comments
 (0)