1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-10-30 03:36:16 +00:00

Reverse proxy authentication

This commit is contained in:
osmarks 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.
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`.