diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-14 14:25:48 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-14 14:25:48 -0600 |
| commit | eb04ea074b64c9e36d0d81e0a0a23832362e97fb (patch) | |
| tree | 675e366a4ee95a2d4053ac5cf1492570b3279cb4 /app/controllers/sessions/controller.go | |
| parent | 88f2dd1cab10f4869077506be01d7680647fb2b2 (diff) | |
feat: start to build a session controller to interact with an oidc provider
Diffstat (limited to 'app/controllers/sessions/controller.go')
| -rw-r--r-- | app/controllers/sessions/controller.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/controllers/sessions/controller.go b/app/controllers/sessions/controller.go new file mode 100644 index 0000000..9340ab6 --- /dev/null +++ b/app/controllers/sessions/controller.go @@ -0,0 +1,26 @@ +package sessions + +import ( + "net/http" + + "golang.org/x/oauth2" +) + +type Controller struct { + cfg *oauth2.Config +} + +func New(cfg *oauth2.Config) *Controller { + return &Controller{cfg: cfg} +} + +func (c *Controller) MountTo(mux *http.ServeMux) { + mux.HandleFunc("GET /session/new", c.New) +} + +func (c *Controller) New(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusFound) + + url := c.cfg.AuthCodeURL("csrf-token", oauth2.SetAuthURLParam("audience", "sparklelab.example.com")) + http.Redirect(w, r, url, http.StatusFound) +} |
