blob: 9340ab61f85191d80f932a7972b51d0ba4025524 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)
}
|