File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ sessions:
2222 - issuer : https://renkulab.io/auth/realms/Renku
2323 audience : renku
2424 authorizedParty : renku-cli
25+ unsafeCookieTemplate : false
2526revproxy :
2627 renkuBaseUrl : " https://renkulab.io"
2728 externalGitlabUrl :
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ type SessionConfig struct {
1111 // NOTE: UnsafeNoCookieHandler should only be used for testing, in production this has to be false/unset
1212 // without this there is no CSRF protection on the oauth callback endpoint
1313 UnsafeNoCookieHandler bool
14+ // NOTE: Unsafe cookie template should only be used for testing. It is NOT SAFE for production.
15+ UnsafeCookieTemplate bool
1416}
1517
1618type AuthorizationVerifier struct {
@@ -29,5 +31,8 @@ func (c *SessionConfig) Validate(e RunningEnvironment) error {
2931 if e != Development && c .UnsafeNoCookieHandler {
3032 return fmt .Errorf ("a cookie handler needs to be configured in production" )
3133 }
34+ if e != Development && c .UnsafeCookieTemplate {
35+ return fmt .Errorf ("a safe cookie template needs to be configured in production" )
36+ }
3237 return nil
3338}
Original file line number Diff line number Diff line change @@ -312,6 +312,24 @@ func WithConfig(c config.SessionConfig) SessionStoreOption {
312312 }
313313 sessions .cookieHandler = securecookie .New (cookieHashKey , cookieEncKey )
314314 }
315+ if c .UnsafeCookieTemplate {
316+ unsafeCookieTmpl := func () http.Cookie {
317+ defaultTmpl := sessions .cookieTemplate ()
318+ return http.Cookie {
319+ Name : defaultTmpl .Name ,
320+ Path : defaultTmpl .Path ,
321+ Domain : defaultTmpl .Domain ,
322+ Expires : defaultTmpl .Expires ,
323+ MaxAge : defaultTmpl .MaxAge ,
324+ // NOTE: Secure needs to be true so that the SameSite = None works
325+ // Enables calling a deployed backend from a local ui client version running on localhost
326+ Secure : true ,
327+ HttpOnly : false ,
328+ SameSite : http .SameSiteNoneMode ,
329+ }
330+ }
331+ sessions .cookieTemplate = unsafeCookieTmpl
332+ }
315333
316334 sessions .sessionMaker = NewSessionMaker (WithIdleSessionTTLSeconds (c .IdleSessionTTLSeconds ), WithMaxSessionTTLSeconds (c .MaxSessionTTLSeconds ))
317335
You can’t perform that action at this time.
0 commit comments