oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1package sheets
2
3import (
4 "amadan.net/oficina/home/connect"
5 "github.com/go-chi/chi/v5"
6)
7
8func (a *App) mountAuth(r chi.Router) {
9 if a.homeRoutes != nil {
10 r.Get("/signin", a.homeRoutes.Signin)
11 r.Get("/signin/local", a.homeRoutes.LocalGuard(a.handleSignin))
12 r.Get("/auth/start", a.home.Start)
13 r.Post("/auth/assertion", a.home.Callback)
14 r.Get("/auth/finish", a.home.Finish)
15 r.Get(connect.LocalCompletePath, a.homeRoutes.LocalGuard(a.homeLocalComplete))
16 r.Get("/account/home", a.homeRoutes.Account)
17 r.Post("/account/home", a.homeRoutes.LinkStart)
18 r.Get("/account/home/confirm", a.home.ConfirmPage)
19 r.Post("/account/home/confirm", a.homeRoutes.ConfirmPost)
20 r.Get("/signed-out", a.homeRoutes.SignedOut)
21 } else {
22 r.Get("/signin", a.handleSignin)
23 r.Get("/signed-out", a.handleSignedOut)
24 }
25 if a.auth != nil {
26 // The handlers rastrillo/auth expects an app to mount, at the
27 // paths its own docs use. Verify answers GET with the confirm
28 // door (renderConfirm), which spends nothing, and POST with the
29 // redemption, so it is mounted for both methods in both modes:
30 // without the POST, the door's Sign in button gets a 405 and
31 // nobody signs in. The path is baked into every emailed link, so
32 // moving it later invalidates links already in people's inboxes.
33 // A verified address that is not admitted is answered by auth's
34 // Refused hook (App.refused), inside Callback and Verify.
35 if a.homeRoutes != nil {
36 r.Post("/signin", a.homeRoutes.LocalGuard(a.handleBegin))
37 r.Get("/auth/callback", a.homeRoutes.LocalGuard(a.auth.Callback))
38 r.Get("/auth/verify", a.homeRoutes.LocalGuard(a.auth.Verify))
39 r.Post("/auth/verify", a.homeRoutes.LocalGuard(a.auth.Verify))
40 r.Post("/signout", a.homeRoutes.Signout)
41 } else {
42 r.Post("/signin", a.handleBegin)
43 r.Get("/auth/callback", a.auth.Callback)
44 r.Get("/auth/verify", a.auth.Verify)
45 r.Post("/auth/verify", a.auth.Verify)
46 r.Post("/signout", a.signOutToPage)
47 }
48 }
49}
50