diff --git a/internal/auth/auth.go b/internal/auth/auth.go index c1df7b9..531a060 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -86,8 +86,8 @@ func (s *Service) Login(pubkey, signature, eventJSON string) (string, error) { } } - // Compare with the provided pubkey - if allowedHexPubkey != pubkey { + // Compare with the provided pubkey (case-insensitive comparison) + if strings.ToLower(allowedHexPubkey) != strings.ToLower(pubkey) { s.logger.Warn("Login attempt from non-whitelisted pubkey", zap.String("attempt_pubkey", pubkey), zap.String("allowed_pubkey", allowedHexPubkey), @@ -166,8 +166,8 @@ func (s *Service) VerifyToken(tokenStr string) (string, error) { } } - // Compare with the token's pubkey - if allowedHexPubkey != token.Pubkey { + // Compare with the token's pubkey (case-insensitive comparison) + if strings.ToLower(allowedHexPubkey) != strings.ToLower(token.Pubkey) { s.logger.Warn("Token verification from non-whitelisted pubkey", zap.String("token_pubkey", token.Pubkey), zap.String("allowed_pubkey", allowedHexPubkey)) diff --git a/internal/utils/nip-19.go b/internal/utils/nip-19.go index 4436175..bc76a56 100644 --- a/internal/utils/nip-19.go +++ b/internal/utils/nip-19.go @@ -2,6 +2,8 @@ package utils import ( + "strings" + "github.com/nbd-wtf/go-nostr/nip19" ) @@ -40,6 +42,6 @@ func DecodeNpub(npub string) (string, error) { return "", err } - // Return the hex pubkey - return data.(string), nil + // Return the hex pubkey (ensure lowercase for consistent comparisons) + return strings.ToLower(data.(string)), nil } \ No newline at end of file