@@ -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
698758func 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