support CAS identity provider

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2021-02-05 15:20:37 +08:00
parent 2d73e777f4
commit 5f0727cf34
27 changed files with 1853 additions and 3 deletions

30
vendor/gopkg.in/cas.v2/middleware.go generated vendored Normal file
View File

@@ -0,0 +1,30 @@
package cas
import (
"net/http"
"github.com/golang/glog"
)
// Handler returns a standard http.HandlerFunc, which will check the authenticated status (redirect user go login if needed)
// If the user pass the authenticated check, it will call the h's ServeHTTP method
func (c *Client) Handler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if glog.V(2) {
glog.Infof("cas: handling %v request for %v", r.Method, r.URL)
}
setClient(r, c)
if !IsAuthenticated(r) {
RedirectToLogin(w, r)
return
}
if r.URL.Path == "/logout" {
RedirectToLogout(w, r)
return
}
h.ServeHTTP(w, r)
})
}