comments for codacy

This commit is contained in:
Pascal Fischer
2023-03-30 17:32:44 +02:00
parent 1343a3f00e
commit 454240ca05
4 changed files with 25 additions and 9 deletions

View File

@@ -9,11 +9,16 @@ import (
type key string
const (
TokenUserProperty key = "user"
AccountIDSuffix key = "wt_account_id"
DomainIDSuffix key = "wt_account_domain"
// TokenUserProperty key for the user property in the request context
TokenUserProperty key = "user"
// AccountIDSuffix suffix for the account id claim
AccountIDSuffix key = "wt_account_id"
// DomainIDSuffix suffix for the domain id claim
DomainIDSuffix key = "wt_account_domain"
// DomainCategorySuffix suffix for the domain category claim
DomainCategorySuffix key = "wt_account_domain_category"
UserIDClaim key = "sub"
// UserIDClaim claim for the user id
UserIDClaim key = "sub"
)
// Extract function type

View File

@@ -58,10 +58,12 @@ type JSONWebKey struct {
X5c []string `json:"x5c"`
}
// JWTValidator struct to handle token validation and parsing
type JWTValidator struct {
options Options
}
// NewJWTValidator constructor
func NewJWTValidator(issuer string, audience string, keysLocation string) (*JWTValidator, error) {
keys, err := getPemKeys(keysLocation)
if err != nil {
@@ -102,6 +104,7 @@ func NewJWTValidator(issuer string, audience string, keysLocation string) (*JWTV
}, nil
}
// ValidateAndParse validates the token and returns the parsed token
func (m *JWTValidator) ValidateAndParse(token string) (*jwt.Token, error) {
// If the token is empty...
if token == "" {