Skip to content

Commit

Permalink
rename IsServerHttps to IsServerHTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed Dec 7, 2023
1 parent b1f9873 commit 495c6c8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions business/authentication/openid_auth_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (c OpenIdAuthController) redirectToAuthServerHandler(w http.ResponseWriter,
nonceCookie := http.Cookie{
Expires: expirationTime,
HttpOnly: true,
Secure: conf.IsServerHttps(),
Secure: conf.IsServerHTTPS(),
Name: OpenIdNonceCookieName,
Path: conf.Server.WebRoot,
SameSite: http.SameSiteLaxMode,
Expand Down Expand Up @@ -495,7 +495,7 @@ func (p *openidFlowHelper) callbackCleanup(w http.ResponseWriter) *openidFlowHel
Name: OpenIdNonceCookieName,
Expires: time.Unix(0, 0),
HttpOnly: true,
Secure: conf.IsServerHttps(),
Secure: conf.IsServerHTTPS(),
Path: conf.Server.WebRoot,
SameSite: http.SameSiteStrictMode,
Value: "",
Expand Down
6 changes: 3 additions & 3 deletions business/authentication/session_persistor.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (p CookieSessionPersistor) CreateSession(_ *http.Request, w http.ResponseWr
Value: chunk,
Expires: expiresOn,
HttpOnly: true,
Secure: conf.IsServerHttps(),
Secure: conf.IsServerHTTPS(),
Path: conf.Server.WebRoot,
SameSite: http.SameSiteStrictMode,
}
Expand All @@ -153,7 +153,7 @@ func (p CookieSessionPersistor) CreateSession(_ *http.Request, w http.ResponseWr
Value: strconv.Itoa(len(sessionDataChunks)),
Expires: expiresOn,
HttpOnly: true,
Secure: conf.IsServerHttps(),
Secure: conf.IsServerHTTPS(),
Path: conf.Server.WebRoot,
SameSite: http.SameSiteStrictMode,
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func (p CookieSessionPersistor) TerminateSession(r *http.Request, w http.Respons
Value: "",
Expires: time.Unix(0, 0),
HttpOnly: true,
Secure: conf.IsServerHttps(),
Secure: conf.IsServerHTTPS(),
MaxAge: -1,
Path: conf.Server.WebRoot,
SameSite: http.SameSiteStrictMode,
Expand Down
8 changes: 4 additions & 4 deletions business/authentication/session_persistor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestSecureFlag(t *testing.T) {

cookie := response.Cookies()[0]
assert.True(t, cookie.HttpOnly)
assert.True(t, true, cfg.IsServerHttps())
assert.True(t, true, cfg.IsServerHTTPS())
assert.True(t, cookie.Secure)
}

Expand Down Expand Up @@ -78,8 +78,8 @@ func TestCreateSessionNoChunks(t *testing.T) {

cookie := response.Cookies()[0]
assert.True(t, cookie.HttpOnly)
assert.Equal(t, false, cfg.IsServerHttps())
assert.Equal(t, cfg.IsServerHttps(), cookie.Secure)
assert.Equal(t, false, cfg.IsServerHTTPS())
assert.Equal(t, cfg.IsServerHTTPS(), cookie.Secure)
assert.Equal(t, AESSessionCookieName, cookie.Name)
assert.Equal(t, "/kiali-app", cookie.Path)
assert.Equal(t, http.SameSiteStrictMode, cookie.SameSite)
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestCreateSessionWithChunks(t *testing.T) {

for _, cookie := range response.Cookies() {
assert.True(t, cookie.HttpOnly)
assert.Equal(t, cfg.IsServerHttps(), cookie.Secure)
assert.Equal(t, cfg.IsServerHTTPS(), cookie.Secure)
assert.Equal(t, "/kiali-app", cookie.Path)
assert.Equal(t, http.SameSiteStrictMode, cookie.SameSite)
assert.Equal(t, expiresTime, cookie.Expires)
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ func (conf *Config) AllNamespacesAccessible() bool {
return conf.Deployment.ClusterWideAccess
}

// IsServerHttps returns true if the server endpoint should use HTTPS. If false, only plaintext HTTP is supported.
func (conf *Config) IsServerHttps() bool {
// IsServerHTTPS returns true if the server endpoint should use HTTPS. If false, only plaintext HTTP is supported.
func (conf *Config) IsServerHTTPS() bool {
return conf.Identity.CertFile != "" && conf.Identity.PrivateKeyFile != ""
}

Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *Server) Start() {

go func() {
var err error
if s.conf.IsServerHttps() {
if s.conf.IsServerHTTPS() {
log.Infof("Server endpoint will require https")
log.Infof("Server will support protocols: %v", s.httpServer.TLSConfig.NextProtos)
s.router.Use(secureHttpsMiddleware)
Expand Down
4 changes: 2 additions & 2 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestAnonymousMode(t *testing.T) {
apiURLWithAuthentication := serverURL + "/api/authenticate"
apiURL := serverURL + "/api"

assert.False(t, conf.IsServerHttps())
assert.False(t, conf.IsServerHTTPS())

config.Set(conf)

Expand Down Expand Up @@ -215,7 +215,7 @@ func TestSecureComm(t *testing.T) {
apiURL := serverURL + "/api"
metricsURL := fmt.Sprintf("http://%v:%v/", testHostname, testMetricsPort)

assert.True(t, conf.IsServerHttps())
assert.True(t, conf.IsServerHTTPS())

config.Set(conf)

Expand Down

0 comments on commit 495c6c8

Please sign in to comment.