Skip to content

Commit 96b66e3

Browse files
leonklingelelunny
authored andcommitted
routers/user: ensure that decryption of cookie actually suceeds (#7363)
Previously, only the first return value of ctx.GetSuperSecureCookie was used to check whether decryption of the auth cookie succeeded. ctx.GetSuperSecureCookie also returns a second value, a boolean, indicating success or not. That value should be checked first to be on the safe side and not rely on internal logic of the encryption and decryption blackbox.
1 parent 8675032 commit 96b66e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

routers/user/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
7171
return false, nil
7272
}
7373

74-
if val, _ := ctx.GetSuperSecureCookie(
75-
base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); val != u.Name {
74+
if val, ok := ctx.GetSuperSecureCookie(
75+
base.EncodeMD5(u.Rands+u.Passwd), setting.CookieRememberName); !ok || val != u.Name {
7676
return false, nil
7777
}
7878

0 commit comments

Comments
 (0)