@@ -57,8 +57,8 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
57
57
defer func () {
58
58
if ! isSucceed {
59
59
log .Trace ("auto-login cookie cleared: %s" , uname )
60
- ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL )
61
- ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL )
60
+ ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
61
+ ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
62
62
}
63
63
}()
64
64
@@ -78,7 +78,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
78
78
isSucceed = true
79
79
ctx .Session .Set ("uid" , u .ID )
80
80
ctx .Session .Set ("uname" , u .Name )
81
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
81
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
82
82
return true , nil
83
83
}
84
84
@@ -92,13 +92,13 @@ func checkAutoLogin(ctx *context.Context) bool {
92
92
93
93
redirectTo := ctx .Query ("redirect_to" )
94
94
if len (redirectTo ) > 0 {
95
- ctx .SetCookie ("redirect_to" , redirectTo , 0 , setting .AppSubURL )
95
+ ctx .SetCookie ("redirect_to" , redirectTo , 0 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
96
96
} else {
97
97
redirectTo , _ = url .QueryUnescape (ctx .GetCookie ("redirect_to" ))
98
98
}
99
99
100
100
if isSucceed {
101
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL )
101
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
102
102
ctx .RedirectToFirst (redirectTo , setting .AppSubURL + string (setting .LandingPageURL ))
103
103
return true
104
104
}
@@ -443,9 +443,9 @@ func handleSignIn(ctx *context.Context, u *models.User, remember bool) {
443
443
func handleSignInFull (ctx * context.Context , u * models.User , remember bool , obeyRedirect bool ) string {
444
444
if remember {
445
445
days := 86400 * setting .LogInRememberDays
446
- ctx .SetCookie (setting .CookieUserName , u .Name , days , setting .AppSubURL )
446
+ ctx .SetCookie (setting .CookieUserName , u .Name , days , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
447
447
ctx .SetSuperSecureCookie (base .EncodeMD5 (u .Rands + u .Passwd ),
448
- setting .CookieRememberName , u .Name , days , setting .AppSubURL )
448
+ setting .CookieRememberName , u .Name , days , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
449
449
}
450
450
451
451
ctx .Session .Delete ("openid_verified_uri" )
@@ -469,10 +469,10 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
469
469
}
470
470
}
471
471
472
- ctx .SetCookie ("lang" , u .Language , nil , setting .AppSubURL )
472
+ ctx .SetCookie ("lang" , u .Language , nil , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
473
473
474
474
// Clear whatever CSRF has right now, force to generate a new one
475
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
475
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
476
476
477
477
// Register last login
478
478
u .SetLastLogin ()
@@ -482,7 +482,7 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
482
482
}
483
483
484
484
if redirectTo , _ := url .QueryUnescape (ctx .GetCookie ("redirect_to" )); len (redirectTo ) > 0 && ! util .IsExternalURL (redirectTo ) {
485
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL )
485
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
486
486
if obeyRedirect {
487
487
ctx .RedirectToFirst (redirectTo )
488
488
}
@@ -563,7 +563,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
563
563
ctx .Session .Set ("uname" , u .Name )
564
564
565
565
// Clear whatever CSRF has right now, force to generate a new one
566
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
566
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
567
567
568
568
// Register last login
569
569
u .SetLastLogin ()
@@ -573,7 +573,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
573
573
}
574
574
575
575
if redirectTo , _ := url .QueryUnescape (ctx .GetCookie ("redirect_to" )); len (redirectTo ) > 0 {
576
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL )
576
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
577
577
ctx .RedirectToFirst (redirectTo )
578
578
return
579
579
}
@@ -864,10 +864,10 @@ func SignOut(ctx *context.Context) {
864
864
ctx .Session .Delete ("socialId" )
865
865
ctx .Session .Delete ("socialName" )
866
866
ctx .Session .Delete ("socialEmail" )
867
- ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL )
868
- ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL )
869
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
870
- ctx .SetCookie ("lang" , "" , - 1 , setting .AppSubURL ) // Setting the lang cookie will trigger the middleware to reset the language ot previous state.
867
+ ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
868
+ ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
869
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
870
+ ctx .SetCookie ("lang" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true ) // Setting the lang cookie will trigger the middleware to reset the language ot previous state.
871
871
ctx .Redirect (setting .AppSubURL + "/" )
872
872
}
873
873
0 commit comments