mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-22 08:03:30 +01:00
revert codacy
This commit is contained in:
parent
f273fe9f51
commit
ce775d59ae
@ -19,7 +19,7 @@ const (
|
||||
UserIDClaim = "sub"
|
||||
)
|
||||
|
||||
// Extract function type
|
||||
// ExtractClaims Extract function type
|
||||
type ExtractClaims func(r *http.Request) AuthorizationClaims
|
||||
|
||||
// ClaimsExtractor struct that holds the extract function
|
||||
@ -65,7 +65,7 @@ func NewClaimsExtractor(options ...ClaimsExtractorOption) *ClaimsExtractor {
|
||||
ce.FromRequestContext = ce.fromRequestContext
|
||||
}
|
||||
if ce.userIDClaim == "" {
|
||||
ce.userIDClaim = string(UserIDClaim)
|
||||
ce.userIDClaim = UserIDClaim
|
||||
}
|
||||
return ce
|
||||
}
|
||||
|
@ -12,16 +12,16 @@ import (
|
||||
func newTestRequestWithJWT(t *testing.T, claims AuthorizationClaims, audiance string) *http.Request {
|
||||
claimMaps := jwt.MapClaims{}
|
||||
if claims.UserId != "" {
|
||||
claimMaps[string(UserIDClaim)] = claims.UserId
|
||||
claimMaps[UserIDClaim] = claims.UserId
|
||||
}
|
||||
if claims.AccountId != "" {
|
||||
claimMaps[audiance+string(AccountIDSuffix)] = claims.AccountId
|
||||
claimMaps[audiance+AccountIDSuffix] = claims.AccountId
|
||||
}
|
||||
if claims.Domain != "" {
|
||||
claimMaps[audiance+string(DomainIDSuffix)] = claims.Domain
|
||||
claimMaps[audiance+DomainIDSuffix] = claims.Domain
|
||||
}
|
||||
if claims.DomainCategory != "" {
|
||||
claimMaps[audiance+string(DomainCategorySuffix)] = claims.DomainCategory
|
||||
claimMaps[audiance+DomainCategorySuffix] = claims.DomainCategory
|
||||
}
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claimMaps)
|
||||
r, err := http.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||
@ -124,7 +124,7 @@ func TestExtractClaimsSetOptions(t *testing.T) {
|
||||
t.Error("audience should be empty")
|
||||
return
|
||||
}
|
||||
if c.extractor.userIDClaim != string(UserIDClaim) {
|
||||
if c.extractor.userIDClaim != UserIDClaim {
|
||||
t.Errorf("user id claim should be default, expected %s, got %s", UserIDClaim, c.extractor.userIDClaim)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user