Last AUTH fix I hope

This commit is contained in:
Enki 2025-05-14 10:28:09 -07:00
parent 2851d8bfe6
commit cdad91c110
2 changed files with 8 additions and 6 deletions

View File

@ -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))

View File

@ -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
}