Skip to content

Commit

Permalink
chore: adjust comment and use pointer for non-manandatory field
Browse files Browse the repository at this point in the history
Signed-off-by: Ardika Bagus <me@ardikabs.com>
  • Loading branch information
ardikabs committed Apr 12, 2024
1 parent b95ff0a commit 3b44bf1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions api/v1alpha1/jwt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package v1alpha1
// JWT defines the configuration for JSON Web Token (JWT) authentication.
type JWT struct {

// AllowMissing specifies whether a missing JWT is acceptable, but it will fail if an invalid JWT is presented.
//
AllowMissing bool `json:"allowMissing,omitempty"`
// AllowMissing determines whether a missing JWT is acceptable, defaulting to false if not specified.
// Note: Even if allowMissing is set to true, JWT authentication will still fail if an invalid JWT is presented.
AllowMissing *bool `json:"allowMissing,omitempty"`

// Providers defines the JSON Web Token (JWT) authentication provider type.
// When multiple JWT providers are specified, the JWT is considered valid if
Expand Down
5 changes: 5 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.

Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ spec:
authentication.
properties:
allowMissing:
description: AllowMissing specifies whether a missing JWT is acceptable,
but it will fail if an invalid JWT is presented.
description: |-
AllowMissing determines whether a missing JWT is acceptable, defaulting to false if not specified.
Note: Even if allowMissing is set to true, JWT authentication will still fail if an invalid JWT is presented.
type: boolean
providers:
description: |-
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/securitypolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func wildcard2regex(wildcard string) string {

func (t *Translator) buildJWT(jwt *egv1a1.JWT) *ir.JWT {
return &ir.JWT{
AllowMissing: jwt.AllowMissing,
AllowMissing: ptr.Deref(jwt.AllowMissing, false),
Providers: jwt.Providers,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ir/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ type CORS struct {
//
// +k8s:deepcopy-gen=true
type JWT struct {
// AllowMissing specifies whether JWT authentication could be optionally required.
// AllowMissing determines whether a missing JWT is acceptable.
//
AllowMissing bool `json:"allowMissing,omitempty" yaml:"allowMissing,omitempty"`

Expand Down
6 changes: 1 addition & 5 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1514,12 +1514,8 @@ _Appears in:_

| Field | Type | Required | Description |
| --- | --- | --- | --- |
<<<<<<< HEAD
=======
| `allowMissing` | _boolean_ | true | AllowMissing specifies whether a missing JWT is acceptable, but it will fail if an invalid JWT is presented. |
| `providers` | _[JWTProvider](#jwtprovider) array_ | true | Providers defines the JSON Web Token (JWT) authentication provider type.<br />When multiple JWT providers are specified, the JWT is considered valid if<br />any of the providers successfully validate the JWT. For additional details,<br />see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/jwt_authn_filter.html. |
>>>>>>> e79687da (feat: add support for optional JWT authentication)

| `allowMissing` | _boolean_ | true | AllowMissing determines whether a missing JWT is acceptable, defaulting to false if not specified.<br />Note: Even if allowMissing is set to true, JWT authentication will still fail if an invalid JWT is presented. |
| `providers` | _[JWTProvider](#jwtprovider) array_ | true | Providers defines the JSON Web Token (JWT) authentication provider type.<br />When multiple JWT providers are specified, the JWT is considered valid if<br />any of the providers successfully validate the JWT. For additional details,<br />see https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/jwt_authn_filter.html. |

#### JWTExtractor
Expand Down

0 comments on commit 3b44bf1

Please sign in to comment.