chore(lint): nix yoda conditions

This commit is contained in:
AJ ONeal 2023-04-04 17:12:52 -06:00
parent 0f2f6734b0
commit 0c2f482c9e
Signed by: coolaj86
GPG Key ID: 585419CA6DB0AA23
2 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ func NewTokenVerifier(opts VerificationParams) func(http.Handler) http.Handler {
token := r.Header.Get("Authorization") token := r.Header.Get("Authorization")
if "" == token { if token == "" {
if opts.Optional { if opts.Optional {
next.ServeHTTP(w, r) next.ServeHTTP(w, r)
return return
@ -60,7 +60,7 @@ func NewTokenVerifier(opts VerificationParams) func(http.Handler) http.Handler {
} }
parts := strings.Split(token, " ") parts := strings.Split(token, " ")
if 2 != len(parts) { if len(parts) != 2 {
http.Error( http.Error(
w, w,
"Bad Format: expected Authorization header to be in the format of 'Bearer <Token>'", "Bad Format: expected Authorization header to be in the format of 'Bearer <Token>'",

View File

@ -92,10 +92,10 @@ func VerifyJWS(jws *JWS, issuers IssuerList, r *http.Request) (*JWS, error) {
_, jwkOK := jws.Header["jwk"] _, jwkOK := jws.Header["jwk"]
if !jwkOK { if !jwkOK {
if !kidOK || 0 == len(kid) { if !kidOK || len(kid) == 0 {
//errs = append(errs, "must have either header.kid or header.jwk") //errs = append(errs, "must have either header.kid or header.jwk")
return nil, fmt.Errorf("bad request: missing 'kid' identifier") return nil, fmt.Errorf("bad request: missing 'kid' identifier")
} else if !issOK || 0 == len(iss) { } else if !issOK || len(iss) == 0 {
//errs = append(errs, "payload.iss must exist to complement header.kid") //errs = append(errs, "payload.iss must exist to complement header.kid")
return nil, fmt.Errorf("bad request: payload.iss must exist to complement header.kid") return nil, fmt.Errorf("bad request: payload.iss must exist to complement header.kid")
} else { } else {
@ -117,7 +117,7 @@ func VerifyJWS(jws *JWS, issuers IssuerList, r *http.Request) (*JWS, error) {
} }
errs := keypairs.VerifyClaims(pub, &jws.JWS) errs := keypairs.VerifyClaims(pub, &jws.JWS)
if 0 != len(errs) { if len(errs) != 0 {
strs := []string{} strs := []string{}
for _, err := range errs { for _, err := range errs {
jws.Errors = append(jws.Errors, err) jws.Errors = append(jws.Errors, err)