Skip to content

Commit d749f8f

Browse files
author
Anthony Wang
committed
Rename pkey to pubKey
1 parent 3e9a69c commit d749f8f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

integrations/api_activitypub_person_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ func TestActivityPubPerson(t *testing.T) {
4444
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/outbox$", username), person.Outbox.GetID().String())
4545
assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/inbox$", username), person.Inbox.GetID().String())
4646

47-
pkey := person.PublicKey
48-
assert.NotNil(t, pkey)
47+
pubKey := person.PublicKey
48+
assert.NotNil(t, pubKey)
4949
publicKeyID := keyID + "#main-key"
50-
assert.Equal(t, pkey.ID.String(), publicKeyID)
50+
assert.Equal(t, pubKey.ID.String(), publicKeyID)
5151

52-
pubKeyPem := pkey.PublicKeyPem
52+
pubKeyPem := pubKey.PublicKeyPem
5353
assert.NotNil(t, pubKeyPem)
5454
assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----", pubKeyPem)
5555
})

routers/api/v1/activitypub/reqsignature.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ func getPublicKeyFromResponse(ctx context.Context, b []byte, keyID *url.URL) (p
3131
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %v", err)
3232
return
3333
}
34-
pkey := person.PublicKey
35-
if pkey.ID.String() != keyID.String() {
34+
pubKey := person.PublicKey
35+
if pubKey.ID.String() != keyID.String() {
3636
err = fmt.Errorf("cannot find publicKey with id: %s in %s", keyID, b)
3737
return
3838
}
39-
pubKeyPem := pkey.PublicKeyPem
39+
pubKeyPem := pubKey.PublicKeyPem
4040
block, _ := pem.Decode([]byte(pubKeyPem))
4141
if block == nil || block.Type != "PUBLIC KEY" {
4242
err = fmt.Errorf("could not decode publicKeyPem to PUBLIC KEY pem block type")
@@ -83,13 +83,13 @@ func verifyHTTPSignatures(ctx *gitea_context.APIContext) (authenticated bool, er
8383
if err != nil {
8484
return
8585
}
86-
pKey, err := getPublicKeyFromResponse(*ctx, b, idIRI)
86+
pubKey, err := getPublicKeyFromResponse(*ctx, b, idIRI)
8787
if err != nil {
8888
return
8989
}
9090
// 3. Verify the other actor's key
9191
algo := httpsig.Algorithm(setting.Federation.Algorithms[0])
92-
authenticated = v.Verify(pKey, algo) == nil
92+
authenticated = v.Verify(pubKey, algo) == nil
9393
return
9494
}
9595

0 commit comments

Comments
 (0)