Skip to content

Commit 4acf149

Browse files
authored
Merge branch 'main' into feat/support-foreign-upstreams
2 parents e7eab3e + 8dbe60f commit 4acf149

File tree

16 files changed

+728
-31
lines changed

16 files changed

+728
-31
lines changed

build/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ ARG PACKAGE_REPO=pkgs.nginx.com
1717

1818
############################################# Base images containing libs for FIPS #############################################
1919
FROM ghcr.io/nginx/dependencies/nginx-ubi:ubi8@sha256:8ee0f40f1ab500ecfe2e85c1703bd04c79405b9c1c2c0b7e8171aa181a40f7d2 AS ubi8-packages
20-
FROM ghcr.io/nginx/dependencies/nginx-ubi:ubi9@sha256:aa995580fb47e3ec63d824186cab175d61109edf6a77f5f1de4e3339154df46a AS ubi9-packages
20+
FROM ghcr.io/nginx/dependencies/nginx-ubi:ubi9@sha256:68964f6fa5ddd8e736139e9301cebb59e4c44fc1c4df71cb308599352bdc17da AS ubi9-packages
2121
FROM ghcr.io/nginx/alpine-fips:0.4.0-alpine3.19@sha256:0b400b81b5f403d69535a54839296ae35ced374eb1bb04db5b4282f380fef09a AS alpine-fips-3.19
2222
FROM ghcr.io/nginx/alpine-fips:0.4.0-alpine3.22@sha256:61ed75f252bde7da1e6db33d2709456e87478280dfae3d11084f94c361e9f329 AS alpine-fips-3.22
2323
FROM redhat/ubi9-minimal:9.6-1760515502@sha256:34880b64c07f28f64d95737f82f891516de9a3b43583f39970f7bf8e4cfa48b7 AS ubi-minimal
24-
FROM golang:1.25-alpine@sha256:aee43c3ccbf24fdffb7295693b6e33b21e01baec1b2a55acc351fde345e9ec34 AS golang-builder
24+
FROM golang:1.25-alpine@sha256:d3f0cf7723f3429e3f9ed846243970b20a2de7bae6a5b66fc5914e228d831bbb AS golang-builder
2525

2626
############################################# NGINX files #############################################
2727
FROM scratch AS nginx-files

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/nginx/kubernetes-ingress
22

3-
go 1.25.3
3+
go 1.25.4
44

55
require (
66
github.com/aws/aws-sdk-go-v2/config v1.31.17

internal/configs/config_params.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type ConfigParams struct {
6868
MainAppProtectDosLogFormat []string
6969
MainAppProtectDosLogFormatEscaping string
7070
MainAppProtectDosArbFqdn string
71+
OIDC OIDC
7172
ProxyBuffering bool
7273
ProxyBuffers string
7374
ProxyBufferSize string
@@ -192,6 +193,15 @@ type ZoneSync struct {
192193
ResolverIPV6 *bool
193194
}
194195

196+
// OIDC holds OIDC configuration parameters.
197+
type OIDC struct {
198+
PKCETimeout string
199+
IDTokenTimeout string
200+
AccessTimeout string
201+
RefreshTimeout string
202+
SIDSTimeout string
203+
}
204+
195205
// MGMTSecrets holds mgmt block secret names
196206
type MGMTSecrets struct {
197207
License string
@@ -258,6 +268,13 @@ func NewDefaultConfigParams(ctx context.Context, isPlus bool) *ConfigParams {
258268
LimitReqZoneSize: "10m",
259269
LimitReqLogLevel: "error",
260270
LimitReqRejectCode: 429,
271+
OIDC: OIDC{
272+
PKCETimeout: "90s",
273+
IDTokenTimeout: "1h",
274+
AccessTimeout: "1h",
275+
RefreshTimeout: "8h",
276+
SIDSTimeout: "8h",
277+
},
261278
}
262279
}
263280

internal/configs/configmaps.go

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has
459459
configOk = false
460460
}
461461

462+
err = parseConfigMapOIDC(l, cfgm, cfgParams, eventLog)
463+
if err != nil {
464+
configOk = false
465+
}
466+
462467
if upstreamZoneSize, exists := cfgm.Data["upstream-zone-size"]; exists {
463468
cfgParams.UpstreamZoneSize = upstreamZoneSize
464469
}
@@ -694,6 +699,61 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has
694699
return cfgParams, configOk
695700
}
696701

702+
// parseConfigMapOIDC parses OIDC timeout configuration from ConfigMap.
703+
func parseConfigMapOIDC(l *slog.Logger, cfgm *v1.ConfigMap, cfgParams *ConfigParams, eventLog record.EventRecorder) error {
704+
if oidcPKCETimeout, exists := cfgm.Data["oidc-pkce-timeout"]; exists {
705+
pkceTimeout, err := ParseTime(oidcPKCETimeout)
706+
if err != nil {
707+
errorText := fmt.Sprintf("ConfigMap %s/%s: invalid value for 'oidc-pkce-timeout': %q, must be a valid nginx time (e.g. '90s', '5m', '1h')", cfgm.Namespace, cfgm.Name, oidcPKCETimeout)
708+
nl.Warn(l, errorText)
709+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
710+
return err
711+
}
712+
cfgParams.OIDC.PKCETimeout = pkceTimeout
713+
}
714+
if oidcIDTokensTimeout, exists := cfgm.Data["oidc-id-tokens-timeout"]; exists {
715+
idTokensTimeout, err := ParseTime(oidcIDTokensTimeout)
716+
if err != nil {
717+
errorText := fmt.Sprintf("ConfigMap %s/%s: invalid value for 'oidc-id-tokens-timeout': %q, must be a valid nginx time (e.g. '1h', '30m', '2h')", cfgm.Namespace, cfgm.Name, oidcIDTokensTimeout)
718+
nl.Warn(l, errorText)
719+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
720+
return err
721+
}
722+
cfgParams.OIDC.IDTokenTimeout = idTokensTimeout
723+
}
724+
if oidcAccessTokensTimeout, exists := cfgm.Data["oidc-access-tokens-timeout"]; exists {
725+
accessTokensTimeout, err := ParseTime(oidcAccessTokensTimeout)
726+
if err != nil {
727+
errorText := fmt.Sprintf("ConfigMap %s/%s: invalid value for 'oidc-access-tokens-timeout': %q, must be a valid nginx time (e.g. '1h', '30m', '2h')", cfgm.Namespace, cfgm.Name, oidcAccessTokensTimeout)
728+
nl.Warn(l, errorText)
729+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
730+
return err
731+
}
732+
cfgParams.OIDC.AccessTimeout = accessTokensTimeout
733+
}
734+
if oidcRefreshTokensTimeout, exists := cfgm.Data["oidc-refresh-tokens-timeout"]; exists {
735+
refreshTokensTimeout, err := ParseTime(oidcRefreshTokensTimeout)
736+
if err != nil {
737+
errorText := fmt.Sprintf("ConfigMap %s/%s: invalid value for 'oidc-refresh-tokens-timeout': %q, must be a valid nginx time (e.g. '8h', '12h', '24h')", cfgm.Namespace, cfgm.Name, oidcRefreshTokensTimeout)
738+
nl.Warn(l, errorText)
739+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
740+
return err
741+
}
742+
cfgParams.OIDC.RefreshTimeout = refreshTokensTimeout
743+
}
744+
if oidcSIDSTimeout, exists := cfgm.Data["oidc-sids-timeout"]; exists {
745+
sidsTimeout, err := ParseTime(oidcSIDSTimeout)
746+
if err != nil {
747+
errorText := fmt.Sprintf("ConfigMap %s/%s: invalid value for 'oidc-sids-timeout': %q, must be a valid nginx time (e.g. '8h', '12h', '24h')", cfgm.Namespace, cfgm.Name, oidcSIDSTimeout)
748+
nl.Warn(l, errorText)
749+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
750+
return err
751+
}
752+
cfgParams.OIDC.SIDSTimeout = sidsTimeout
753+
}
754+
return nil
755+
}
756+
697757
//nolint:gocyclo
698758
func parseConfigMapZoneSync(l *slog.Logger, cfgm *v1.ConfigMap, cfgParams *ConfigParams, eventLog record.EventRecorder, nginxPlus bool) (*ZoneSync, error) {
699759
if zoneSync, exists, err := GetMapKeyAsBool(cfgm.Data, "zone-sync", cfgm); exists {
@@ -1121,11 +1181,18 @@ func GenerateNginxMainConfig(staticCfgParams *StaticConfigParams, config *Config
11211181
InternalRouteServer: staticCfgParams.EnableInternalRoutes,
11221182
InternalRouteServerName: staticCfgParams.InternalRouteServerName,
11231183
LatencyMetrics: staticCfgParams.EnableLatencyMetrics,
1124-
OIDC: staticCfgParams.EnableOIDC,
1125-
ZoneSyncConfig: zoneSyncConfig,
1126-
DynamicSSLReloadEnabled: staticCfgParams.DynamicSSLReload,
1127-
StaticSSLPath: staticCfgParams.StaticSSLPath,
1128-
NginxVersion: staticCfgParams.NginxVersion,
1184+
OIDC: version1.OIDCConfig{
1185+
Enable: staticCfgParams.EnableOIDC,
1186+
PKCETimeout: config.OIDC.PKCETimeout,
1187+
IDTokenTimeout: config.OIDC.IDTokenTimeout,
1188+
AccessTimeout: config.OIDC.AccessTimeout,
1189+
RefreshTimeout: config.OIDC.RefreshTimeout,
1190+
SIDSTimeout: config.OIDC.SIDSTimeout,
1191+
},
1192+
ZoneSyncConfig: zoneSyncConfig,
1193+
DynamicSSLReloadEnabled: staticCfgParams.DynamicSSLReload,
1194+
StaticSSLPath: staticCfgParams.StaticSSLPath,
1195+
NginxVersion: staticCfgParams.NginxVersion,
11291196
}
11301197
return nginxCfg
11311198
}

0 commit comments

Comments
 (0)