Skip to content

Commit d61398b

Browse files
authored
crd: add runtimeFlags (#1010)
1 parent 64e5cc0 commit d61398b

File tree

6 files changed

+106
-73
lines changed

6 files changed

+106
-73
lines changed

apis/ingress/v1/pomerium_types.go

+39-36
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,16 @@ type Cookie struct {
186186

187187
// PomeriumSpec defines Pomerium-specific configuration parameters.
188188
type PomeriumSpec struct {
189+
// AccessLogFields sets the <a href="https://www.pomerium.com/docs/reference/access-log-fields">access fields</a> to log.
190+
AccessLogFields *[]string `json:"accessLogFields,omitempty"`
191+
189192
// Authenticate sets authenticate service parameters.
190193
// If not specified, a Pomerium-hosted authenticate service would be used.
191194
// +kubebuilder:validation:Optional
192195
Authenticate *Authenticate `json:"authenticate"`
193196

194-
// IdentityProvider configure single-sign-on authentication and user identity details
195-
// by integrating with your <a href="https://www.pomerium.com/docs/identity-providers/">Identity Provider</a>
196-
//
197-
// +kubebuilder:validation:Optional
198-
IdentityProvider *IdentityProvider `json:"identityProvider"`
197+
// AuthorizeLogFields sets the <a href="https://www.pomerium.com/docs/reference/authorize-log-fields">authorize fields</a> to log.
198+
AuthorizeLogFields *[]string `json:"authorizeLogFields,omitempty"`
199199

200200
// Certificates is a list of secrets of type TLS to use
201201
// +kubebuilder:validation:Format="namespace/name"
@@ -206,6 +206,35 @@ type PomeriumSpec struct {
206206
// +optional
207207
CASecrets []string `json:"caSecrets"`
208208

209+
// Cookie defines Pomerium session cookie options.
210+
// +optional
211+
Cookie *Cookie `json:"cookie,omitempty"`
212+
213+
// IdentityProvider configure single-sign-on authentication and user identity details
214+
// by integrating with your <a href="https://www.pomerium.com/docs/identity-providers/">Identity Provider</a>
215+
//
216+
// +kubebuilder:validation:Optional
217+
IdentityProvider *IdentityProvider `json:"identityProvider"`
218+
219+
// JWTClaimHeaders convert claims from the assertion token
220+
// into HTTP headers and adds them into JWT assertion header.
221+
// Please make sure to read
222+
// <a href="https://www.pomerium.com/docs/topics/getting-users-identity">
223+
// Getting User Identity</a> guide.
224+
//
225+
// +optional
226+
JWTClaimHeaders map[string]string `json:"jwtClaimHeaders,omitempty"`
227+
228+
// PassIdentityHeaders sets the <a href="https://www.pomerium.com/docs/reference/pass-identity-headers">pass identity headers</a> option.
229+
PassIdentityHeaders *bool `json:"passIdentityHeaders,omitempty"`
230+
231+
// ProgrammaticRedirectDomains specifies a list of domains that can be used for
232+
// <a href="https://www.pomerium.com/docs/capabilities/programmatic-access">programmatic redirects</a>.
233+
ProgrammaticRedirectDomains []string `json:"programmaticRedirectDomains,omitempty"`
234+
235+
// RuntimeFlags sets the <a href="https://www.pomerium.com/docs/reference/runtime-flags">runtime flags</a> to enable/disable certain features.
236+
RuntimeFlags map[string]bool `json:"runtimeFlags,omitempty"`
237+
209238
// Secrets references a Secret with Pomerium bootstrap parameters.
210239
//
211240
// <p>
@@ -237,49 +266,23 @@ type PomeriumSpec struct {
237266
// +kubebuilder:validation:Format="namespace/name"
238267
Secrets string `json:"secrets"`
239268

269+
// SetResponseHeaders specifies a mapping of HTTP Header to be added globally to all managed routes and pomerium's authenticate service.
270+
// +optional
271+
// See <a href="https://www.pomerium.com/docs/reference/set-response-headers">Set Response Headers</a>
272+
SetResponseHeaders map[string]string `json:"setResponseHeaders,omitempty"`
273+
240274
// Storage defines persistent storage for sessions and other data.
241275
// See <a href="https://www.pomerium.com/docs/topics/data-storage">Storage</a> for details.
242276
// If no storage is specified, Pomerium would use a transient in-memory storage (not recommended for production).
243277
//
244278
// +kubebuilder:validation:Optional
245279
Storage *Storage `json:"storage,omitempty"`
246280

247-
// Cookie defines Pomerium session cookie options.
248-
// +optional
249-
Cookie *Cookie `json:"cookie,omitempty"`
250-
251-
// JWTClaimHeaders convert claims from the assertion token
252-
// into HTTP headers and adds them into JWT assertion header.
253-
// Please make sure to read
254-
// <a href="https://www.pomerium.com/docs/topics/getting-users-identity">
255-
// Getting User Identity</a> guide.
256-
//
257-
// +optional
258-
JWTClaimHeaders map[string]string `json:"jwtClaimHeaders,omitempty"`
259-
260-
// SetResponseHeaders specifies a mapping of HTTP Header to be added globally to all managed routes and pomerium's authenticate service.
261-
// +optional
262-
// See <a href="https://www.pomerium.com/docs/reference/set-response-headers">Set Response Headers</a>
263-
SetResponseHeaders map[string]string `json:"setResponseHeaders,omitempty"`
264-
265-
// ProgrammaticRedirectDomains specifies a list of domains that can be used for
266-
// <a href="https://www.pomerium.com/docs/capabilities/programmatic-access">programmatic redirects</a>.
267-
ProgrammaticRedirectDomains []string `json:"programmaticRedirectDomains,omitempty"`
268-
269281
// Timeout specifies the <a href="https://www.pomerium.com/docs/reference/global-timeouts">global timeouts</a> for all routes.
270282
Timeouts *Timeouts `json:"timeouts,omitempty"`
271283

272284
// UseProxyProtocol enables <a href="https://www.pomerium.com/docs/reference/use-proxy-protocol">Proxy Protocol</a> support.
273285
UseProxyProtocol *bool `json:"useProxyProtocol,omitempty"`
274-
275-
// AccessLogFields sets the <a href="https://www.pomerium.com/docs/reference/access-log-fields">access fields</a> to log.
276-
AccessLogFields *[]string `json:"accessLogFields,omitempty"`
277-
278-
// AuthorizeLogFields sets the <a href="https://www.pomerium.com/docs/reference/authorize-log-fields">authorize fields</a> to log.
279-
AuthorizeLogFields *[]string `json:"authorizeLogFields,omitempty"`
280-
281-
// PassIdentityHeaders sets the <a href="https://www.pomerium.com/docs/reference/pass-identity-headers">pass identity headers</a> option.
282-
PassIdentityHeaders *bool `json:"passIdentityHeaders,omitempty"`
283286
}
284287

285288
// Timeouts allows to configure global timeouts for all routes.

apis/ingress/v1/zz_generated.deepcopy.go

+43-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/ingress.pomerium.io_pomerium.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ spec:
234234
items:
235235
type: string
236236
type: array
237+
runtimeFlags:
238+
additionalProperties:
239+
type: boolean
240+
description: RuntimeFlags sets the <a href="https://www.pomerium.com/docs/reference/runtime-flags">runtime
241+
flags</a> to enable/disable certain features.
242+
type: object
237243
secrets:
238244
description: "Secrets references a Secret with Pomerium bootstrap
239245
parameters.\n\n\n<p>\n<ul>\n\t<li><a href=\"https://pomerium.com/docs/reference/shared-secret\"><code>shared_secret</code></a>\n\t\t-

deployment.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ spec:
242242
items:
243243
type: string
244244
type: array
245+
runtimeFlags:
246+
additionalProperties:
247+
type: boolean
248+
description: RuntimeFlags sets the <a href="https://www.pomerium.com/docs/reference/runtime-flags">runtime
249+
flags</a> to enable/disable certain features.
250+
type: object
245251
secrets:
246252
description: "Secrets references a Secret with Pomerium bootstrap
247253
parameters.\n\n\n<p>\n<ul>\n\t<li><a href=\"https://pomerium.com/docs/reference/shared-secret\"><code>shared_secret</code></a>\n\t\t-

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/iancoleman/strcase v0.3.0
1717
github.com/martinlindhe/base36 v1.1.1
1818
github.com/open-policy-agent/opa v0.66.0
19+
github.com/pomerium/csrf v1.7.0
1920
github.com/pomerium/pomerium v0.26.1-0.20240705192647-8f8c66e9fdef
2021
github.com/rs/zerolog v1.33.0
2122
github.com/sergi/go-diff v1.3.1
@@ -155,7 +156,6 @@ require (
155156
github.com/philhofer/fwd v1.0.0 // indirect
156157
github.com/pkg/errors v0.9.1 // indirect
157158
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
158-
github.com/pomerium/csrf v1.7.0 // indirect
159159
github.com/pomerium/datasource v0.18.2-0.20221108160055-c6134b5ed524 // indirect
160160
github.com/pomerium/webauthn v0.0.0-20240603205124-0428df511172 // indirect
161161
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect

pomerium/ctrl/bootstrap.go

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func Apply(ctx context.Context, dst *config.Options, src *model.Config) error {
2929
{"authenticate", applyAuthenticate},
3030
{"secrets", applySecrets},
3131
{"storage", applyStorage},
32+
{"runtime flags", applyRuntimeFlags},
3233
} {
3334
if err := apply.fn(ctx, dst, src); err != nil {
3435
return fmt.Errorf("%s: %w", apply.name, err)
@@ -66,6 +67,16 @@ func applyAuthenticate(_ context.Context, dst *config.Options, src *model.Config
6667
return nil
6768
}
6869

70+
func applyRuntimeFlags(_ context.Context, dst *config.Options, src *model.Config) error {
71+
dst.RuntimeFlags = config.DefaultRuntimeFlags()
72+
73+
for k, v := range src.Spec.RuntimeFlags {
74+
dst.RuntimeFlags[config.RuntimeFlag(k)] = v
75+
}
76+
77+
return nil
78+
}
79+
6980
func applyStorage(ctx context.Context, dst *config.Options, src *model.Config) error {
7081
if err := storageFiles.DeleteFiles(); err != nil {
7182
log.FromContext(ctx).V(1).Error(err, "failed to delete existing files")

0 commit comments

Comments
 (0)