Skip to content

Commit cdaa4af

Browse files
danielhochmancrewjam
authored andcommitted
add HTTPOnly bool to CookieSessionProvider (#248)
1 parent 9cb6acf commit cdaa4af

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

samlsp/new.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ func DefaultSessionProvider(opts Options) CookieSessionProvider {
8181
}
8282

8383
return CookieSessionProvider{
84-
Name: cookieName,
85-
Domain: cookieDomain,
86-
MaxAge: maxAge,
87-
Secure: cookieSecure,
88-
Codec: DefaultSessionCodec(opts),
84+
Name: cookieName,
85+
Domain: cookieDomain,
86+
MaxAge: maxAge,
87+
HTTPOnly: true,
88+
Secure: cookieSecure,
89+
Codec: DefaultSessionCodec(opts),
8990
}
9091
}
9192

samlsp/session_cookie.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ var _ SessionProvider = CookieSessionProvider{}
1515
// CookieSessionProvider is an implementation of SessionProvider that stores
1616
// session tokens in an HTTP cookie.
1717
type CookieSessionProvider struct {
18-
Name string
19-
Domain string
20-
Secure bool
21-
MaxAge time.Duration
22-
Codec SessionCodec
18+
Name string
19+
Domain string
20+
HTTPOnly bool
21+
Secure bool
22+
MaxAge time.Duration
23+
Codec SessionCodec
2324
}
2425

2526
// CreateSession is called when we have received a valid SAML assertion and
@@ -46,7 +47,7 @@ func (c CookieSessionProvider) CreateSession(w http.ResponseWriter, r *http.Requ
4647
Domain: c.Domain,
4748
Value: value,
4849
MaxAge: int(c.MaxAge.Seconds()),
49-
HttpOnly: true,
50+
HttpOnly: c.HTTPOnly,
5051
Secure: c.Secure || r.URL.Scheme == "https",
5152
Path: "/",
5253
})

0 commit comments

Comments
 (0)