From d749f8ff4f429d3fdbd7915dd587f6cfe7f41e2e Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Mon, 13 Jun 2022 20:51:49 -0500 Subject: [PATCH] Rename pkey to pubKey --- integrations/api_activitypub_person_test.go | 8 ++++---- routers/api/v1/activitypub/reqsignature.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/integrations/api_activitypub_person_test.go b/integrations/api_activitypub_person_test.go index 830c9cc888..70f1134fa5 100644 --- a/integrations/api_activitypub_person_test.go +++ b/integrations/api_activitypub_person_test.go @@ -44,12 +44,12 @@ func TestActivityPubPerson(t *testing.T) { assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/outbox$", username), person.Outbox.GetID().String()) assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/inbox$", username), person.Inbox.GetID().String()) - pkey := person.PublicKey - assert.NotNil(t, pkey) + pubKey := person.PublicKey + assert.NotNil(t, pubKey) publicKeyID := keyID + "#main-key" - assert.Equal(t, pkey.ID.String(), publicKeyID) + assert.Equal(t, pubKey.ID.String(), publicKeyID) - pubKeyPem := pkey.PublicKeyPem + pubKeyPem := pubKey.PublicKeyPem assert.NotNil(t, pubKeyPem) assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----", pubKeyPem) }) diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go index 5a15a5d5aa..906be714da 100644 --- a/routers/api/v1/activitypub/reqsignature.go +++ b/routers/api/v1/activitypub/reqsignature.go @@ -31,12 +31,12 @@ func getPublicKeyFromResponse(ctx context.Context, b []byte, keyID *url.URL) (p err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %v", err) return } - pkey := person.PublicKey - if pkey.ID.String() != keyID.String() { + pubKey := person.PublicKey + if pubKey.ID.String() != keyID.String() { err = fmt.Errorf("cannot find publicKey with id: %s in %s", keyID, b) return } - pubKeyPem := pkey.PublicKeyPem + pubKeyPem := pubKey.PublicKeyPem block, _ := pem.Decode([]byte(pubKeyPem)) if block == nil || block.Type != "PUBLIC KEY" { 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 if err != nil { return } - pKey, err := getPublicKeyFromResponse(*ctx, b, idIRI) + pubKey, err := getPublicKeyFromResponse(*ctx, b, idIRI) if err != nil { return } // 3. Verify the other actor's key algo := httpsig.Algorithm(setting.Federation.Algorithms[0]) - authenticated = v.Verify(pKey, algo) == nil + authenticated = v.Verify(pubKey, algo) == nil return }