chore: update session and challenge repo -- using Redis for caching session and challenge verifying -- added api handler docs
This commit is contained in:
@@ -32,6 +32,12 @@ type UserRepo interface {
|
||||
Delete(ctx context.Context, id uuid.UUID) error
|
||||
}
|
||||
|
||||
type ChallengeRepo interface {
|
||||
Create(ctx context.Context, pubKey string, challenge *Challenge) error
|
||||
GetByPubKey(ctx context.Context, pubKey string) (*Challenge, error)
|
||||
Delete(ctx context.Context, pubKey string) error
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID uuid.UUID
|
||||
PubKey string
|
||||
@@ -51,7 +57,7 @@ type User struct {
|
||||
|
||||
// TODO: move to another file?
|
||||
type Challenge struct {
|
||||
Message uuid.UUID
|
||||
Message string
|
||||
TimeStamp time.Time
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
@@ -70,7 +76,7 @@ func (c *Challenge) Verify(address string, signedMsg string) (bool, error) {
|
||||
return false, fmt.Errorf("decode signature: %w", err)
|
||||
}
|
||||
|
||||
challengeBytes := []byte(c.Message.String())
|
||||
challengeBytes := []byte(c.Message)
|
||||
|
||||
return c.VerifySignedBytes(address, challengeBytes, signature)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user