diff --git a/claims.go b/claims.go index f0228f0..1133fd4 100644 --- a/claims.go +++ b/claims.go @@ -35,18 +35,18 @@ func (c StandardClaims) Valid() error { // The claims below are optional, by default, so if they are set to the // default value in Go, let's not fail the verification for them. - if c.VerifyExpiresAt(now, false) == false { + if !c.VerifyExpiresAt(now, false) { delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0)) vErr.Inner = fmt.Errorf("token is expired by %v", delta) vErr.Errors |= ValidationErrorExpired } - if c.VerifyIssuedAt(now, false) == false { + if !c.VerifyIssuedAt(now, false) { vErr.Inner = fmt.Errorf("Token used before issued") vErr.Errors |= ValidationErrorIssuedAt } - if c.VerifyNotBefore(now, false) == false { + if !c.VerifyNotBefore(now, false) { vErr.Inner = fmt.Errorf("token is not valid yet") vErr.Errors |= ValidationErrorNotValidYet } diff --git a/cmd/jwt/app.go b/cmd/jwt/app.go index 491f5d2..b364927 100644 --- a/cmd/jwt/app.go +++ b/cmd/jwt/app.go @@ -98,7 +98,7 @@ func printJSON(j interface{}) error { var out []byte var err error - if *flagCompact == false { + if !*flagCompact { out, err = json.MarshalIndent(j, "", " ") } else { out, err = json.Marshal(j) diff --git a/ecdsa.go b/ecdsa.go index f977381..d310af1 100644 --- a/ecdsa.go +++ b/ecdsa.go @@ -88,11 +88,11 @@ func (m *SigningMethodECDSA) Verify(signingString, signature string, key interfa hasher.Write([]byte(signingString)) // Verify the signature - if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus == true { + if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus { return nil - } else { - return ErrECDSAVerification } + + return ErrECDSAVerification } // Implements the Sign method from SigningMethod diff --git a/map_claims.go b/map_claims.go index 291213c..e1d6f3f 100644 --- a/map_claims.go +++ b/map_claims.go @@ -27,7 +27,7 @@ func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool { v, _ := exp.Int64() return verifyExp(v, cmp, req) } - return req == false + return !req } // Compares the iat claim against cmp. @@ -40,7 +40,7 @@ func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool { v, _ := iat.Int64() return verifyIat(v, cmp, req) } - return req == false + return !req } // Compares the iss claim against cmp. @@ -60,7 +60,7 @@ func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool { v, _ := nbf.Int64() return verifyNbf(v, cmp, req) } - return req == false + return !req } // Validates time based claims "exp, iat, nbf". @@ -71,17 +71,17 @@ func (m MapClaims) Valid() error { vErr := new(ValidationError) now := TimeFunc().Unix() - if m.VerifyExpiresAt(now, false) == false { + if !m.VerifyExpiresAt(now, false) { vErr.Inner = errors.New("Token is expired") vErr.Errors |= ValidationErrorExpired } - if m.VerifyIssuedAt(now, false) == false { + if !m.VerifyIssuedAt(now, false) { vErr.Inner = errors.New("Token used before issued") vErr.Errors |= ValidationErrorIssuedAt } - if m.VerifyNotBefore(now, false) == false { + if !m.VerifyNotBefore(now, false) { vErr.Inner = errors.New("Token is not valid yet") vErr.Errors |= ValidationErrorNotValidYet }