1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-11-24 19:14:55 +00:00

Reverse proxy authentication

This commit is contained in:
2024-06-16 14:14:54 +01:00
parent f1d4310ec1
commit ceff8ad91b

View File

@@ -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. // FromRequest returns user from `rq`. If there is no user, an anon user is returned instead.
func FromRequest(rq *http.Request) *User { func FromRequest(rq *http.Request) *User {
cookie, err := rq.Cookie("mycorrhiza_token") username, ok := rq.Header["X-Webauth-User"]
if err != nil { if !ok || len(username) < 1 {
return EmptyUser() return EmptyUser()
} }
return ByToken(cookie.Value) return ByName(username[0])
} }
// LogoutFromRequest logs the user in `rq` out and rewrites the cookie in `w`. // LogoutFromRequest logs the user in `rq` out and rewrites the cookie in `w`.