Skip to content

Commit

Permalink
Set Secure flag only if Secure is set on flyteadmin config
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario committed Oct 31, 2024
1 parent 0a308c4 commit 5641bd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions flyteadmin/auth/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/gorilla/securecookie"

"github.com/flyteorg/flyte/flyteadmin/auth/interfaces"
"github.com/flyteorg/flyte/flyteadmin/pkg/config"
"github.com/flyteorg/flyte/flytestdlib/errors"
"github.com/flyteorg/flyte/flytestdlib/logger"
)
Expand Down Expand Up @@ -69,7 +70,7 @@ func NewSecureCookie(cookieName, value string, hashKey, blockKey []byte, domain
Domain: domain,
SameSite: sameSiteMode,
HttpOnly: true,
Secure: true,
Secure: config.GetConfig().Security.Secure,
}, nil
}

Expand Down Expand Up @@ -128,7 +129,7 @@ func NewCsrfCookie() http.Cookie {
Value: csrfStateToken,
SameSite: http.SameSiteLaxMode,
HttpOnly: true,
Secure: true,
Secure: config.GetConfig().Security.Secure,
}
}

Expand Down
3 changes: 2 additions & 1 deletion flyteadmin/auth/cookie_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"golang.org/x/oauth2"

"github.com/flyteorg/flyte/flyteadmin/auth/config"
serverConfig "github.com/flyteorg/flyte/flyteadmin/pkg/config"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service"
"github.com/flyteorg/flyte/flytestdlib/errors"
"github.com/flyteorg/flyte/flytestdlib/logger"
Expand Down Expand Up @@ -218,7 +219,7 @@ func (c *CookieManager) getLogoutCookie(name string) *http.Cookie {
Domain: c.domain,
MaxAge: 0,
HttpOnly: true,
Secure: true,
Secure: serverConfig.GetConfig().Security.Secure,
Expires: time.Now().Add(-1 * time.Hour),
}
}
Expand Down

0 comments on commit 5641bd5

Please sign in to comment.