From ef050c428a0a893607314a4d5d8d441e445e630a Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 7 May 2025 09:06:48 -0700 Subject: refactor: move cookie to web package --- app/controllers/sessions/controller.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/controllers/sessions/controller.go') diff --git a/app/controllers/sessions/controller.go b/app/controllers/sessions/controller.go index 13cb2de..9bbc2b4 100644 --- a/app/controllers/sessions/controller.go +++ b/app/controllers/sessions/controller.go @@ -4,11 +4,11 @@ import ( "net/http" "time" - xcookie "github.com/xlgmokha/x/pkg/cookie" + "github.com/xlgmokha/x/pkg/cookie" "github.com/xlgmokha/x/pkg/log" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/middleware" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" - "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/cookie" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web" ) type Controller struct { @@ -35,11 +35,11 @@ func (c *Controller) New(w http.ResponseWriter, r *http.Request) { url, nonce := c.svc.GenerateRedirectURL() // This cookie must be sent as part of a redirect that originates from the OIDC Provider - http.SetCookie(w, cookie.New( + http.SetCookie(w, web.NewCookie( "oauth_state", nonce, - xcookie.WithSameSite(http.SameSiteLaxMode), - xcookie.WithExpiration(time.Now().Add(10*time.Minute)), + cookie.WithSameSite(http.SameSiteLaxMode), + cookie.WithExpiration(time.Now().Add(10*time.Minute)), )) http.Redirect(w, r, url, http.StatusFound) } @@ -139,11 +139,11 @@ func (c *Controller) Create(w http.ResponseWriter, r *http.Request) { return } - xcookie.Write(w, cookie.New("session", encoded, xcookie.WithExpiration(tokens.Expiry))) + cookie.Write(w, web.NewCookie("session", encoded, cookie.WithExpiration(tokens.Expiry))) http.Redirect(w, r, "/dashboard", http.StatusFound) } func (c *Controller) Destroy(w http.ResponseWriter, r *http.Request) { - cookie.Expire(w, "session") + web.ExpireCookie(w, "session") http.Redirect(w, r, "/", http.StatusFound) } -- cgit v1.2.3