Skip to content

Commit 6fda4b0

Browse files
committed
fix: bugs
Signed-off-by: Eric Lin <38420555+Ezzahhh@users.noreply.github.com>
1 parent 62af93c commit 6fda4b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Config struct {
2323
func CreateConfig() *Config {
2424
return &Config{
2525
AuthRequestHeaders: []string{"Cookie", "X-Forwarded-Proto", "X-Forwarded-Host"},
26-
AuthResponseHeaders: []string{"X-Vouch-User"},
26+
AuthResponseHeaders: []string{"X-Vouch-User", "X-Vouch-Token"},
2727
AuthCheckTimeout: 5 * time.Second,
2828
}
2929
}
@@ -105,13 +105,17 @@ func (e *VouchPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
105105

106106
// 4. CASE: Authorized (200 OK)
107107
if authResp.StatusCode >= 200 && authResp.StatusCode < 300 {
108+
// If Vouch refreshes the session, we must tell the browser to update the cookie.
109+
for _, cookie := range authResp.Cookies() {
110+
http.SetCookie(rw, cookie)
111+
}
108112
// Copy configured headers from Vouch -> Downstream App
109113
for _, headerName := range e.authRespHeaders {
110114
if val := authResp.Header.Get(headerName); val != "" {
111115
req.Header.Set(headerName, val)
112116
}
113117
}
114-
req.Header.Del("Cookie")
118+
// req.Header.Del("Cookie")
115119
e.next.ServeHTTP(rw, req)
116120
return
117121
}

0 commit comments

Comments
 (0)