From 1ccbc4175dad080872fc910f952c3e5d12e0f548 Mon Sep 17 00:00:00 2001 From: Umputun Date: Mon, 21 May 2018 19:30:39 -0500 Subject: [PATCH] lint: convetion warn for time and typo in double []byte --- app/rest/auth/jwt.go | 8 ++++---- app/rest/auth/provider.go | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/rest/auth/jwt.go b/app/rest/auth/jwt.go index d8231d22..97ea05f4 100644 --- a/app/rest/auth/jwt.go +++ b/app/rest/auth/jwt.go @@ -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 diff --git a/app/rest/auth/provider.go b/app/rest/auth/provider.go index 8fb34ea7..9f20cd10 100644 --- a/app/rest/auth/provider.go +++ b/app/rest/auth/provider.go @@ -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(), }, }