Generate a random key ID on registration

This commit is contained in:
cheddar 2025-02-17 21:03:31 -05:00
parent 949d1fc2ad
commit 09417b5147
No known key found for this signature in database
5 changed files with 47 additions and 10 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/common-fate/httpsig/alg_ed25519"
"github.com/common-fate/httpsig/verifier"
"github.com/google/uuid"
"crispbyte.dev/sig-auth/keydirectory"
)
@ -41,7 +42,12 @@ func (dir InMemoryDirectory) GetKey(ctx context.Context, keyId string, _ string)
}
func (dir InMemoryDirectory) RegisterKey(key crypto.PublicKey, alg string, userId string) (string, error) {
keyId := userId
uuid, err := uuid.NewRandom()
keyId := uuid.String()
if err != nil {
return "", err
}
dir.records[keyId] = keydirectory.KeyEntry{
Alg: alg,