Skip to content

Commit 40b8224

Browse files
committed
Update comments in GolangAPI to decribe relative NGINX directives
1 parent 47ff38b commit 40b8224

File tree

1 file changed

+46
-20
lines changed

1 file changed

+46
-20
lines changed

docs/proposals/authentication-filter.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ type BasicAuth struct {
141141
Secret string `json:"secret"`
142142

143143
// Key is the key within the Secret that contains the htpasswd data.
144-
//
145-
// +optional
146-
Key *string `json:"key,omitempty"`
144+
Key string `json:"key,omitempty"`
147145

148-
// Realm used by NGINX auth_basic; helps with logging and WWW-Authenticate.
146+
// Realm used by NGINX `auth_basic`.
147+
// Configures "realm="<realm_value>" in WWW-Authenticate header in error page location.
149148
//
150149
// +optional
151150
Realm *string `json:"realm,omitempty"`
@@ -162,17 +161,19 @@ type BasicAuth struct {
162161
// +kubebuilder:validation:XValidation:message="when file is set, mode must be 'File'",rule="self.file != null ? self.mode == 'File' : true"
163162
// +kubebuilder:validation:XValidation:message="when remote is set, mode must be 'Remote'",rule="self.remote != null ? self.mode == 'Remote' : true"
164163
type JWTAuth struct {
165-
// Realm used by NGINX auth_jwt; sets realm in the auth challenge.
164+
// Realm used by NGINX `auth_jwt` directive.
165+
// Configures "realm="<realm_value>" in WWW-Authenticate header in error page location.
166166
//
167167
// +optional
168+
// +kubebuilder:default="Restricted"
168169
Realm *string `json:"realm,omitempty"`
169170

170171
// Mode selects how JWT keys are provided: local file or remote JWKS.
171172
// Default: File.
172173
//
173174
// +optional
174-
// +kubebuilder:validation:Enum=File;Remote
175175
// +kubebuilder:default=File
176+
// +kubebuilder:validation:Enum=File;Remote
176177
// +kubebuilder:validation:XValidation:message="mode must be one of [File, Remote]",rule="self in ['File','Remote']"
177178
Mode JWTKeyMode `json:"mode,omitempty"`
178179

@@ -188,23 +189,27 @@ type JWTAuth struct {
188189
// +optional
189190
Remote *JWTRemoteKeySource `json:"remote,omitempty"`
190191

191-
// Leeway is the acceptable clock skew for exp/nbf checks (auth_jwt_leeway).
192-
// Example: "60s".
192+
// Leeway is the acceptable clock skew for exp/nbf checks.
193+
// Configures `auth_jwt_leeway` directive.
194+
// Example: "auth_jwt_leeway 60s".
193195
//
194196
// +optional
195197
// +kubebuilder:default=60s
196198
Leeway *v1alpha1.Duration `json:"leeway,omitempty"`
197199

198-
// Type sets token type: signed | encrypted | nested (auth_jwt_type).
199-
// Default: "signed".
200+
// Type sets token type: signed | encrypted | nested.
201+
// Default: signed.
202+
// Configures `auth_jwt_type` directive.
203+
// Example: "auth_jwt_type signed;".
200204
//
201205
// +optional
202-
// +kubebuilder:validation:Enum=signed;encrypted;nested
203206
// +kubebuilder:default=signed
207+
// +kubebuilder:validation:Enum=signed;encrypted;nested
204208
Type *JWTTokenType `json:"type,omitempty"`
205209

206-
// KeyCache is the cache duration for keys (auth_jwt_key_cache).
207-
// Example: "10m".
210+
// KeyCache is the cache duration for keys.
211+
// Configures auth_jwt_key_cache directive.
212+
// Example: "auth_jwt_key_cache 10m".
208213
//
209214
// +optional
210215
KeyCache *string `json:"keyCache,omitempty"`
@@ -214,8 +219,23 @@ type JWTAuth struct {
214219
// +optional
215220
OnFailure *AuthFailureResponse `json:"onFailure,omitempty"`
216221

217-
// Require defines claims that must match exactly (e.g., iss, aud).
218-
// NGF will translate these into NGINX maps and auth_jwt_require directives.
222+
// Require defines claims that must match exactly (e.g. iss, aud).
223+
// These translate into NGINX maps and auth_jwt_require directives.
224+
// Example directives and maps:
225+
//
226+
// auth_jwt_require $valid_jwt_iss;
227+
// auth_jwt_require $valid_jwt_aud;
228+
//
229+
// map $jwt_claim_iss $valid_jwt_iss {
230+
// "https://issuer.example.com" 1;
231+
// "https://issuer.example1.com" 1;
232+
// default 0;
233+
// }
234+
// map $jwt_claim_aud $valid_jwt_aud {
235+
// "api" 1;
236+
// "cli" 1;
237+
// default 0;
238+
// }
219239
//
220240
// +optional
221241
Require *JWTRequiredClaims `json:"require,omitempty"`
@@ -256,15 +276,18 @@ type JWTFileKeySource struct {
256276
SecretRef *SecretKeyReference `json:"secretRef,omitempty"`
257277

258278
// MountPath is the path where NGF will mount the data into the NGINX container.
279+
// Used in `auth_jwt_key_file` directive.
259280
// Example: "/etc/nginx/keys".
260281
MountPath string `json:"mountPath"`
261282

262283
// FileName is the file name of the JWKS within the mount path.
284+
// Used in `auth_jwt_key_file` directive.
263285
// Example: "jwks.json".
264286
FileName string `json:"fileName"`
265287

266-
// KeyCache is the cache duration for keys (auth_jwt_key_cache).
267-
// Example: "10m".
288+
// KeyCache is the cache duration for keys.
289+
// Configures `auth_jwt_key_cache` directive
290+
// Example: "auth_jwt_key_cache 10m;".
268291
//
269292
// +optional
270293
KeyCache *string `json:"keyCache,omitempty"`
@@ -282,14 +305,15 @@ type JWTRemoteKeySource struct {
282305
Cache *JWKSCache `json:"cache,omitempty"`
283306
}
284307

285-
// JWKSCache controls NGINX proxy_cache_path and proxy_cache settings used for JWKS responses.
308+
// JWKSCache controls NGINX `proxy_cache_path` and `proxy_cache` settings used for JWKS responses.
286309
type JWKSCache struct {
287310
// Path is the filesystem path for cached JWKS objects.
288311
// Example: "/var/cache/nginx/jwks".
289312
Path string `json:"path"`
290313

291314
// Levels specifies the directory hierarchy for cached files.
292-
// Example: "1:2".
315+
// Used in `proxy_cache_path` directive.
316+
// Example: "levels=1:2".
293317
//
294318
// +optional
295319
Levels *string `json:"levels,omitempty"`
@@ -424,17 +448,19 @@ type AuthFailureResponse struct {
424448
StatusCode *int32 `json:"statusCode,omitempty"`
425449

426450
// Challenge scheme. If omitted, inferred from filter Type (Basic|Bearer).
451+
// Configures WWW-Authenticate header in error page location.
427452
//
428453
// +optional
454+
// +kubebuilder:default=Basic
429455
// +kubebuilder:validation:Enum=Basic;Bearer
430456
Scheme *AuthScheme `json:"scheme,omitempty"`
431457

432458
// Controls whether a default canned body is sent or an empty body.
433459
// Default: Unauthorized.
434460
//
435461
// +optional
436-
// +kubebuilder:validation:Enum=Unauthorized;Forbidden;Empty
437462
// +kubebuilder:default=Unauthorized
463+
// +kubebuilder:validation:Enum=Unauthorized;Forbidden;Empty
438464
BodyPolicy *AuthFailureBodyPolicy `json:"bodyPolicy,omitempty"`
439465
}
440466

0 commit comments

Comments
 (0)