diff options
Diffstat (limited to 'app/controllers/sessions/controller.go')
| -rw-r--r-- | app/controllers/sessions/controller.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/controllers/sessions/controller.go b/app/controllers/sessions/controller.go index 7549dc7..6c61ec0 100644 --- a/app/controllers/sessions/controller.go +++ b/app/controllers/sessions/controller.go @@ -7,7 +7,6 @@ import ( "github.com/xlgmokha/x/pkg/log" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/oidc" - "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/cookie" "golang.org/x/oauth2" ) @@ -15,12 +14,15 @@ import ( type Controller struct { cfg *oidc.OpenID http *http.Client + + svc *Service } func New(cfg *oidc.OpenID, http *http.Client) *Controller { return &Controller{ cfg: cfg, http: http, + svc: NewService(cfg, http), } } @@ -31,8 +33,7 @@ func (c *Controller) MountTo(mux *http.ServeMux) { } func (c *Controller) New(w http.ResponseWriter, r *http.Request) { - nonce := pls.GenerateNonce(32) - url := c.cfg.Config.AuthCodeURL(nonce, oauth2.SetAuthURLParam("audience", c.cfg.Config.ClientID)) + url, nonce := c.svc.GenerateRedirectURL() http.SetCookie(w, cookie.New("oauth_state", nonce, time.Now().Add(10*time.Minute))) http.Redirect(w, r, url, http.StatusFound) } |
