backend gets cookie identifying user

master v0.8.1
Bel LaPointe 2021-03-21 13:12:11 -05:00
parent c623792c2f
commit af240639cb
1 changed files with 15 additions and 0 deletions

View File

@ -170,6 +170,21 @@ func (s *Server) doAuthelia(foo http.HandlerFunc) http.HandlerFunc {
)
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
for k := range resp.Header {
if strings.HasPrefix(k, "Remote-") {
cookie := &http.Cookie{
Name: k,
Value: resp.Header.Get(k),
Path: "/",
Domain: r2.Host,
SameSite: http.SameSiteLaxMode,
Secure: true,
HttpOnly: true,
Expires: time.Now().Add(24 * time.Hour * 30),
}
http.SetCookie(w, cookie)
}
}
foo(w, r)
return
}