-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathweb.go
More file actions
48 lines (37 loc) · 1.15 KB
/
web.go
File metadata and controls
48 lines (37 loc) · 1.15 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package beyond
import (
"flag"
"fmt"
"net/http"
"github.com/presbrey/beyond/internal/authn"
"github.com/presbrey/beyond/internal/docker"
)
var (
homeURL = flag.String("home-url", "https://google.com", "redirect users here from root")
)
// NewMux mounts all configured web handlers
func NewMux() http.Handler {
mux := http.NewServeMux()
mux.HandleFunc(*healthPath, func(rw http.ResponseWriter, r *http.Request) {
fmt.Fprint(rw, *healthReply)
})
mux.HandleFunc(*host+"/federate", func(w http.ResponseWriter, r *http.Request) {
authn.Federate(w, r, *authn.CookieName, login)
})
mux.HandleFunc(*host+"/federate/verify", authn.FederateVerify)
mux.HandleFunc(*host+"/launch", handleLaunch)
mux.HandleFunc(*host+"/oidc", handleOIDC)
if authn.SAMLMiddleware() != nil {
mux.HandleFunc(*host+"/saml/", authn.SAMLMiddleware().ServeHTTP)
}
mux.Handle(*host+"/", http.RedirectHandler(*homeURL, http.StatusTemporaryRedirect))
for _, ds := range docker.GetServers() {
ds.RegisterHandlers(mux)
}
// Set docker package dependencies
docker.Debug = debug
docker.LogRoundtrip = logRoundtrip
docker.Handler = handler
mux.HandleFunc("/", handler)
return mux
}