@@ -56,8 +56,8 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
56
56
defer func () {
57
57
if ! isSucceed {
58
58
log .Trace ("auto-login cookie cleared: %s" , uname )
59
- ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL )
60
- ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL )
59
+ ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
60
+ ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
61
61
}
62
62
}()
63
63
@@ -77,7 +77,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
77
77
isSucceed = true
78
78
ctx .Session .Set ("uid" , u .ID )
79
79
ctx .Session .Set ("uname" , u .Name )
80
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
80
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
81
81
return true , nil
82
82
}
83
83
@@ -91,13 +91,13 @@ func checkAutoLogin(ctx *context.Context) bool {
91
91
92
92
redirectTo := ctx .Query ("redirect_to" )
93
93
if len (redirectTo ) > 0 {
94
- ctx .SetCookie ("redirect_to" , redirectTo , 0 , setting .AppSubURL )
94
+ ctx .SetCookie ("redirect_to" , redirectTo , 0 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
95
95
} else {
96
96
redirectTo , _ = url .QueryUnescape (ctx .GetCookie ("redirect_to" ))
97
97
}
98
98
99
99
if isSucceed {
100
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL )
100
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
101
101
ctx .RedirectToFirst (redirectTo , setting .AppSubURL + string (setting .LandingPageURL ))
102
102
return true
103
103
}
@@ -438,9 +438,9 @@ func handleSignIn(ctx *context.Context, u *models.User, remember bool) {
438
438
func handleSignInFull (ctx * context.Context , u * models.User , remember bool , obeyRedirect bool ) string {
439
439
if remember {
440
440
days := 86400 * setting .LogInRememberDays
441
- ctx .SetCookie (setting .CookieUserName , u .Name , days , setting .AppSubURL )
441
+ ctx .SetCookie (setting .CookieUserName , u .Name , days , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
442
442
ctx .SetSuperSecureCookie (base .EncodeMD5 (u .Rands + u .Passwd ),
443
- setting .CookieRememberName , u .Name , days , setting .AppSubURL )
443
+ setting .CookieRememberName , u .Name , days , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
444
444
}
445
445
446
446
ctx .Session .Delete ("openid_verified_uri" )
@@ -464,10 +464,10 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
464
464
}
465
465
}
466
466
467
- ctx .SetCookie ("lang" , u .Language , nil , setting .AppSubURL )
467
+ ctx .SetCookie ("lang" , u .Language , nil , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
468
468
469
469
// Clear whatever CSRF has right now, force to generate a new one
470
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
470
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
471
471
472
472
// Register last login
473
473
u .SetLastLogin ()
@@ -477,7 +477,7 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
477
477
}
478
478
479
479
if redirectTo , _ := url .QueryUnescape (ctx .GetCookie ("redirect_to" )); len (redirectTo ) > 0 && ! util .IsExternalURL (redirectTo ) {
480
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL )
480
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
481
481
if obeyRedirect {
482
482
ctx .RedirectToFirst (redirectTo )
483
483
}
@@ -558,7 +558,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
558
558
ctx .Session .Set ("uname" , u .Name )
559
559
560
560
// Clear whatever CSRF has right now, force to generate a new one
561
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
561
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
562
562
563
563
// Register last login
564
564
u .SetLastLogin ()
@@ -568,7 +568,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
568
568
}
569
569
570
570
if redirectTo , _ := url .QueryUnescape (ctx .GetCookie ("redirect_to" )); len (redirectTo ) > 0 {
571
- ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL )
571
+ ctx .SetCookie ("redirect_to" , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
572
572
ctx .RedirectToFirst (redirectTo )
573
573
return
574
574
}
@@ -844,10 +844,10 @@ func SignOut(ctx *context.Context) {
844
844
ctx .Session .Delete ("socialId" )
845
845
ctx .Session .Delete ("socialName" )
846
846
ctx .Session .Delete ("socialEmail" )
847
- ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL )
848
- ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL )
849
- ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL )
850
- ctx .SetCookie ("lang" , "" , - 1 , setting .AppSubURL ) // Setting the lang cookie will trigger the middleware to reset the language ot previous state.
847
+ ctx .SetCookie (setting .CookieUserName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
848
+ ctx .SetCookie (setting .CookieRememberName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
849
+ ctx .SetCookie (setting .CSRFCookieName , "" , - 1 , setting .AppSubURL , "" , setting . SessionConfig . Secure , true )
850
+ 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.
851
851
ctx .Redirect (setting .AppSubURL + "/" )
852
852
}
853
853
0 commit comments