1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Enable addtional linters (#34085)

enable mirror, usestdlibbars and perfsprint 
part of: https://github.com/go-gitea/gitea/issues/34083

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2025-04-01 12:14:01 +02:00
committed by GitHub
parent 56e42be36d
commit ee3c82f874
294 changed files with 848 additions and 805 deletions

View File

@@ -7,6 +7,7 @@ import (
"context"
"fmt"
"slices"
"strconv"
"strings"
auth "code.gitea.io/gitea/models/auth"
@@ -177,7 +178,7 @@ func NewAccessTokenResponse(ctx context.Context, grant *auth.OAuth2Grant, server
ExpiresAt: jwt.NewNumericDate(expirationDate.AsTime()),
Issuer: setting.AppURL,
Audience: []string{app.ClientID},
Subject: fmt.Sprint(grant.UserID),
Subject: strconv.FormatInt(grant.UserID, 10),
},
Nonce: grant.Nonce,
}

View File

@@ -31,7 +31,7 @@ type ErrInvalidAlgorithmType struct {
}
func (err ErrInvalidAlgorithmType) Error() string {
return fmt.Sprintf("JWT signing algorithm is not supported: %s", err.Algorithm)
return "JWT signing algorithm is not supported: " + err.Algorithm
}
// JWTSigningKey represents a algorithm/key pair to sign JWTs

View File

@@ -4,6 +4,7 @@
package oauth2_provider //nolint
import (
"errors"
"fmt"
"time"
@@ -44,12 +45,12 @@ func ParseToken(jwtToken string, signingKey JWTSigningKey) (*Token, error) {
return nil, err
}
if !parsedToken.Valid {
return nil, fmt.Errorf("invalid token")
return nil, errors.New("invalid token")
}
var token *Token
var ok bool
if token, ok = parsedToken.Claims.(*Token); !ok || !parsedToken.Valid {
return nil, fmt.Errorf("invalid token")
return nil, errors.New("invalid token")
}
return token, nil
}