lint: convetion warn for time and typo in double []byte

This commit is contained in:
Umputun
2018-05-21 19:30:39 -05:00
parent 21e9fcbb14
commit 1ccbc4175d
2 changed files with 4 additions and 5 deletions
+4 -4
View File
@@ -35,20 +35,20 @@ const xsrfHeaderKey = "X-XSRF-TOKEN"
// Set creates jwt cookie with xsrf cookie and put it to ResponseWriter
func (j *JWT) Set(w http.ResponseWriter, claims *CustomClaims) error {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte([]byte(j.secret)))
tokenString, err := token.SignedString([]byte(j.secret))
if err != nil {
return errors.Wrap(err, "can't sign jwt token")
}
expiration := int(time.Duration(365 * 24 * time.Hour).Seconds())
cookieExpiration := 365 * 24 * 3600 // 1year
jwtCookie := http.Cookie{Name: jwtCookieName, Value: tokenString, HttpOnly: true, Path: "/",
MaxAge: expiration, Secure: j.secureCookies}
MaxAge: cookieExpiration, Secure: j.secureCookies}
http.SetCookie(w, &jwtCookie)
jti := claims.Id
xsrfCookie := http.Cookie{Name: xsrfCookieName, Value: jti, HttpOnly: false, Path: "/",
MaxAge: expiration, Secure: j.secureCookies}
MaxAge: cookieExpiration, Secure: j.secureCookies}
http.SetCookie(w, &xsrfCookie)
return nil
-1
View File
@@ -176,7 +176,6 @@ func (p Provider) authHandler(w http.ResponseWriter, r *http.Request) {
Issuer: "remark42",
Id: p.randToken(),
ExpiresAt: time.Now().Add(7 * 24 * time.Hour).Unix(),
NotBefore: time.Now().Add(-1 * time.Minute).Unix(),
},
}