mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-05 02:29:54 +00:00
Reverse proxy authentication
This commit is contained in:
parent
f1d4310ec1
commit
ceff8ad91b
@ -25,11 +25,11 @@ func CanProceed(rq *http.Request, route string) bool {
|
||||
|
||||
// FromRequest returns user from `rq`. If there is no user, an anon user is returned instead.
|
||||
func FromRequest(rq *http.Request) *User {
|
||||
cookie, err := rq.Cookie("mycorrhiza_token")
|
||||
if err != nil {
|
||||
username, ok := rq.Header["X-Webauth-User"]
|
||||
if !ok || len(username) < 1 {
|
||||
return EmptyUser()
|
||||
}
|
||||
return ByToken(cookie.Value)
|
||||
return ByName(username[0])
|
||||
}
|
||||
|
||||
// LogoutFromRequest logs the user in `rq` out and rewrites the cookie in `w`.
|
||||
|
Loading…
Reference in New Issue
Block a user