summaryrefslogtreecommitdiff
path: root/app/controllers/sessions/controller.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-07 09:06:48 -0700
committermo khan <mo@mokhan.ca>2025-05-07 09:06:48 -0700
commitef050c428a0a893607314a4d5d8d441e445e630a (patch)
treee6c7e651f1fa75225053bb3c0f28c29ff15f4306 /app/controllers/sessions/controller.go
parent16641c74b7247f5b5c059f5726fbc724fe3858e4 (diff)
refactor: move cookie to web package
Diffstat (limited to 'app/controllers/sessions/controller.go')
-rw-r--r--app/controllers/sessions/controller.go14
1 files changed, 7 insertions, 7 deletions
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)
}