added prefix scan and fixed logout issue

This commit is contained in:
ston1th 2019-07-06 11:31:12 +02:00
commit 8143e484cd
12 changed files with 99 additions and 77 deletions

View file

@ -25,6 +25,8 @@ const (
totpClaim = "totp"
rememberClaim = "remember"
refererClaim = "referer"
empty = "(empty)"
)
func newContext(w http.ResponseWriter, r *http.Request, s *HTTPServer) *Context {
@ -211,6 +213,14 @@ func (c *Context) Var(name string) (ret string) {
return
}
func (c *Context) Forwarded() (ret string) {
ret = c.Request.Header.Get("X-Forwarded-For")
if ret == "" {
ret = empty
}
return
}
// CheckXsrf validates the xsrf token
func (c *Context) CheckXsrf() (ok bool) {
ok = checkXsrf(c.Form("token"), c.Token.RawSig()[:keySize])