Skip to content

Commit 56a0650

Browse files
committed
addresses should be case insensitive - delegated auth
1 parent 5c42f96 commit 56a0650

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

path_login.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (b *backend) delegatedLogin(ctx context.Context, req *logical.Request, data
247247
return nil, err
248248
}
249249
trustee := claims["iss"].(string)
250-
if !contains(config.TrusteeList, trustee) {
250+
if !containsIgnoreCase(config.TrusteeList, trustee) {
251251
return nil, fmt.Errorf("this %s address is not trusted", trustee)
252252
}
253253
delegateJWT, ok := claims["delegate"].(string)
@@ -522,7 +522,7 @@ func (b *backend) verifyTrustee(ctx context.Context, rawToken string, trustees [
522522
if !ok {
523523
return nil, fmt.Errorf("JWT has no issuer - iss")
524524
}
525-
if !contains(trustees, ethereumAddress) {
525+
if !containsIgnoreCase(trustees, ethereumAddress) {
526526
return nil, fmt.Errorf("we don't trust this issuer: %s", ethereumAddress)
527527
}
528528
jti, ok := unverifiedJwt["jti"].(string)
@@ -546,7 +546,7 @@ func (b *backend) verifyTrustee(ctx context.Context, rawToken string, trustees [
546546
}
547547
address := crypto.PubkeyToAddress(*pubkey)
548548

549-
if ethereumAddress == address.Hex() {
549+
if strings.ToUpper(ethereumAddress) == strings.ToUpper(address.Hex()) {
550550
validateJwt, err := jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
551551
return pubkey, nil
552552
})
@@ -557,4 +557,4 @@ func (b *backend) verifyTrustee(ctx context.Context, rawToken string, trustees [
557557
return claims, claims.Valid()
558558
}
559559
return nil, fmt.Errorf("Error verifying token")
560-
}
560+
}

util.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/ethereum/go-ethereum/crypto"
78
)
@@ -13,9 +14,9 @@ func hashKeccak256(data string) []byte {
1314
return hash
1415
}
1516

16-
func contains(stringSlice []string, searchString string) bool {
17+
func containsIgnoreCase(stringSlice []string, searchString string) bool {
1718
for _, value := range stringSlice {
18-
if value == searchString {
19+
if strings.ToUpper(value) == strings.ToUpper(searchString) {
1920
return true
2021
}
2122
}

0 commit comments

Comments
 (0)