diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-01-30 19:08:14 -0600 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2020-01-30 19:16:19 -0600 |
commit | 819adbbb708076bcf9d3ee6443c704303aad5a80 (patch) | |
tree | 53081f249aade5edc17f6a9a72f449414d881fdd /main.go | |
parent | 6ba23c4e3de16181857d5703198d2e817928f1ba (diff) |
refactor auth middleware
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -12,6 +12,7 @@ import ( func main() { opts := config.NewOpts() ch := web.NewCertHandler(opts.CaCrt, opts.CaKey) + authenticator := auth.GetAuthenticator(opts, false) /* protected routes */ @@ -19,8 +20,8 @@ func main() { http.HandleFunc("/3/refresh-token", auth.RefreshAuthMiddleware(opts.Auth)) */ - http.Handle("/3/cert", auth.RestrictedMiddleware(opts, ch)) - http.HandleFunc("/3/auth", auth.AuthenticatorMiddleware(opts)) + http.HandleFunc("/3/auth", web.AuthMiddleware(authenticator.CheckCredentials, opts)) + http.Handle("/3/cert", web.RestrictedMiddleware(authenticator.NeedsCredentials, ch.CertResponder, opts)) /* static files */ @@ -36,7 +37,7 @@ func main() { pstr := ":" + opts.Port log.Println("Listening in port", opts.Port) - if opts.tls == true { + if opts.Tls == true { log.Fatal(http.ListenAndServeTLS(pstr, opts.TlsCrt, opts.TlsKey, nil)) } else { log.Fatal(http.ListenAndServe(pstr, nil)) |