@@ -13,6 +13,7 @@ import (
1313 "k8s.io/client-go/rest"
1414 "k8s.io/klog"
1515
16+ "github.com/openshift/console/cmd/bridge/config/session"
1617 "github.com/openshift/console/pkg/auth"
1718 "github.com/openshift/console/pkg/flags"
1819 "github.com/openshift/console/pkg/proxy"
@@ -72,12 +73,12 @@ func (c *AuthOptions) AddFlags(fs *flag.FlagSet) {
7273}
7374
7475func (c * AuthOptions ) ApplyConfig (config * serverconfig.Auth ) {
75- setIfUnset (& c .AuthType , config .AuthType )
76- setIfUnset (& c .ClientID , config .ClientID )
77- setIfUnset (& c .IssuerURL , config .OIDCIssuer )
78- setIfUnset (& c .ClientSecretFilePath , config .ClientSecretFile )
79- setIfUnset (& c .CAFilePath , config .OAuthEndpointCAFile )
80- setIfUnset (& c .LogoutRedirect , config .LogoutRedirect )
76+ serverconfig . SetIfUnset (& c .AuthType , config .AuthType )
77+ serverconfig . SetIfUnset (& c .ClientID , config .ClientID )
78+ serverconfig . SetIfUnset (& c .IssuerURL , config .OIDCIssuer )
79+ serverconfig . SetIfUnset (& c .ClientSecretFilePath , config .ClientSecretFile )
80+ serverconfig . SetIfUnset (& c .CAFilePath , config .OAuthEndpointCAFile )
81+ serverconfig . SetIfUnset (& c .LogoutRedirect , config .LogoutRedirect )
8182
8283 if c .InactivityTimeoutSeconds == 0 {
8384 c .InactivityTimeoutSeconds = config .InactivityTimeoutSeconds
@@ -88,7 +89,7 @@ func (c *AuthOptions) ApplyConfig(config *serverconfig.Auth) {
8889 }
8990}
9091
91- func (c * AuthOptions ) Complete (k8sAuthType string ) (* CompletedOptions , error ) {
92+ func (c * AuthOptions ) Complete () (* CompletedOptions , error ) {
9293 // default values before running validation
9394 if len (c .AuthType ) == 0 {
9495 c .AuthType = "openshift"
@@ -99,7 +100,7 @@ func (c *AuthOptions) Complete(k8sAuthType string) (*CompletedOptions, error) {
99100 c .InactivityTimeoutSeconds = 0
100101 }
101102
102- if errs := c .Validate (k8sAuthType ); len (errs ) > 0 {
103+ if errs := c .Validate (); len (errs ) > 0 {
103104 return nil , utilerrors .NewAggregate (errs )
104105 }
105106
@@ -141,7 +142,7 @@ func (c *AuthOptions) Complete(k8sAuthType string) (*CompletedOptions, error) {
141142 }, nil
142143}
143144
144- func (c * AuthOptions ) Validate (k8sAuthType string ) []error {
145+ func (c * AuthOptions ) Validate () []error {
145146 var errs []error
146147
147148 switch c .AuthType {
@@ -179,7 +180,7 @@ func (c *AuthOptions) Validate(k8sAuthType string) []error {
179180 }
180181 }
181182
182- switch k8sAuthType {
183+ switch c . AuthType {
183184 case "oidc" , "openshift" :
184185 default :
185186 if c .InactivityTimeoutSeconds > 0 {
@@ -194,6 +195,7 @@ func (c *completedOptions) ApplyTo(
194195 srv * server.Server ,
195196 k8sEndpoint * url.URL ,
196197 caCertFilePath string ,
198+ sessionConfig * session.CompletedOptions ,
197199) error {
198200 srv .InactivityTimeout = c .InactivityTimeoutSeconds
199201 srv .LogoutRedirect = c .LogoutRedirectURL
@@ -204,6 +206,7 @@ func (c *completedOptions) ApplyTo(
204206 k8sEndpoint ,
205207 caCertFilePath ,
206208 srv .InternalProxiedK8SClientConfig ,
209+ sessionConfig ,
207210 )
208211
209212 return err
@@ -214,6 +217,7 @@ func (c *completedOptions) getAuthenticator(
214217 k8sEndpoint * url.URL ,
215218 caCertFilePath string ,
216219 k8sClientConfig * rest.Config ,
220+ sessionConfig * session.CompletedOptions ,
217221) (* auth.Authenticator , error ) {
218222
219223 if c .AuthType == "disabled" {
@@ -268,9 +272,11 @@ func (c *completedOptions) getAuthenticator(
268272 ErrorURL : authLoginErrorEndpoint ,
269273 SuccessURL : authLoginSuccessEndpoint ,
270274
271- CookiePath : cookiePath ,
272- RefererPath : refererPath ,
273- SecureCookies : useSecureCookies ,
275+ CookiePath : cookiePath ,
276+ RefererPath : refererPath ,
277+ SecureCookies : useSecureCookies ,
278+ CookieEncryptionKey : sessionConfig .CookieEncryptionKey ,
279+ CookieAuthenticationKey : sessionConfig .CookieAuthenticationKey ,
274280
275281 K8sConfig : k8sClientConfig ,
276282 }
@@ -282,9 +288,3 @@ func (c *completedOptions) getAuthenticator(
282288
283289 return authenticator , nil
284290}
285-
286- func setIfUnset (flagVal * string , val string ) {
287- if len (* flagVal ) == 0 {
288- * flagVal = val
289- }
290- }
0 commit comments