mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-30 19:08:37 +00:00 
			
		
		
		
	Rename pkey to pubKey
This commit is contained in:
		| @@ -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/outbox$", username), person.Outbox.GetID().String()) | ||||||
| 		assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/inbox$", username), person.Inbox.GetID().String()) | 		assert.Regexp(t, fmt.Sprintf("activitypub/user/%s/inbox$", username), person.Inbox.GetID().String()) | ||||||
|  |  | ||||||
| 		pkey := person.PublicKey | 		pubKey := person.PublicKey | ||||||
| 		assert.NotNil(t, pkey) | 		assert.NotNil(t, pubKey) | ||||||
| 		publicKeyID := keyID + "#main-key" | 		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.NotNil(t, pubKeyPem) | ||||||
| 		assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----", pubKeyPem) | 		assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----", pubKeyPem) | ||||||
| 	}) | 	}) | ||||||
|   | |||||||
| @@ -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) | 		err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %v", err) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	pkey := person.PublicKey | 	pubKey := person.PublicKey | ||||||
| 	if pkey.ID.String() != keyID.String() { | 	if pubKey.ID.String() != keyID.String() { | ||||||
| 		err = fmt.Errorf("cannot find publicKey with id: %s in %s", keyID, b) | 		err = fmt.Errorf("cannot find publicKey with id: %s in %s", keyID, b) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	pubKeyPem := pkey.PublicKeyPem | 	pubKeyPem := pubKey.PublicKeyPem | ||||||
| 	block, _ := pem.Decode([]byte(pubKeyPem)) | 	block, _ := pem.Decode([]byte(pubKeyPem)) | ||||||
| 	if block == nil || block.Type != "PUBLIC KEY" { | 	if block == nil || block.Type != "PUBLIC KEY" { | ||||||
| 		err = fmt.Errorf("could not decode publicKeyPem to PUBLIC KEY pem block type") | 		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 { | 	if err != nil { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	pKey, err := getPublicKeyFromResponse(*ctx, b, idIRI) | 	pubKey, err := getPublicKeyFromResponse(*ctx, b, idIRI) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	// 3. Verify the other actor's key | 	// 3. Verify the other actor's key | ||||||
| 	algo := httpsig.Algorithm(setting.Federation.Algorithms[0]) | 	algo := httpsig.Algorithm(setting.Federation.Algorithms[0]) | ||||||
| 	authenticated = v.Verify(pKey, algo) == nil | 	authenticated = v.Verify(pubKey, algo) == nil | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user