mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 01:52:26 +08:00
remove new DHT record author check
We're going to just fix this a future commit. *This* change breaks publishing IPNS records using alternative IPNS keys (because the author signature (peer ID) differs from the record signature). We're going to fix it by validating the IPNS signature and ditching the author/signature fields. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -16,7 +16,7 @@ import (
|
|||||||
func TestValidation(t *testing.T) {
|
func TestValidation(t *testing.T) {
|
||||||
// Create a record validator
|
// Create a record validator
|
||||||
validator := make(record.Validator)
|
validator := make(record.Validator)
|
||||||
validator["ipns"] = &record.ValidChecker{ValidateIpnsRecord, true}
|
validator["ipns"] = &record.ValidChecker{Func: ValidateIpnsRecord, Sign: true}
|
||||||
|
|
||||||
// Generate a key for signing the records
|
// Generate a key for signing the records
|
||||||
r := u.NewSeededRand(15) // generate deterministic keypair
|
r := u.NewSeededRand(15) // generate deterministic keypair
|
||||||
@ -46,6 +46,7 @@ func TestValidation(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO(#4613)
|
||||||
// Create IPNS record path with a different private key
|
// Create IPNS record path with a different private key
|
||||||
_, ipnsWrongAuthor := genKeys(t, r)
|
_, ipnsWrongAuthor := genKeys(t, r)
|
||||||
wrongAuthorRec, err := record.MakePutRecord(priv, ipnsWrongAuthor, val, true)
|
wrongAuthorRec, err := record.MakePutRecord(priv, ipnsWrongAuthor, val, true)
|
||||||
@ -97,6 +98,7 @@ func TestValidation(t *testing.T) {
|
|||||||
if err != ErrInvalidAuthor {
|
if err != ErrInvalidAuthor {
|
||||||
t.Fatal("ValidateIpnsRecord should have returned ErrInvalidAuthor")
|
t.Fatal("ValidateIpnsRecord should have returned ErrInvalidAuthor")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Create expired entry
|
// Create expired entry
|
||||||
expiredEntry, err := CreateRoutingEntryData(priv, path.Path("foo"), 1, ts.Add(-1*time.Hour))
|
expiredEntry, err := CreateRoutingEntryData(priv, path.Path("foo"), 1, ts.Add(-1*time.Hour))
|
||||||
|
@ -31,10 +31,6 @@ var ErrExpiredRecord = errors.New("expired record")
|
|||||||
// unknown validity type.
|
// unknown validity type.
|
||||||
var ErrUnrecognizedValidity = errors.New("unrecognized validity type")
|
var ErrUnrecognizedValidity = errors.New("unrecognized validity type")
|
||||||
|
|
||||||
// ErrInvalidAuthor is returned when an IpnsRecord has an
|
|
||||||
// author that does not match the IPNS path
|
|
||||||
var ErrInvalidAuthor = errors.New("author does not match path")
|
|
||||||
|
|
||||||
// ErrInvalidPath should be returned when an ipns record path
|
// ErrInvalidPath should be returned when an ipns record path
|
||||||
// is not in a valid format
|
// is not in a valid format
|
||||||
var ErrInvalidPath = errors.New("record path invalid")
|
var ErrInvalidPath = errors.New("record path invalid")
|
||||||
@ -314,17 +310,24 @@ func ValidateIpnsRecord(r *record.ValidationRecord) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: The DHT will actually check the signature so we don't
|
// NOTE/FIXME(#4613): We're not checking the DHT signature/author here.
|
||||||
// need to do that here
|
// We're going to remove them in a followup commit and then check the
|
||||||
|
// *IPNS* signature. However, to do that, we need to ensure we *have*
|
||||||
// Author in key must match author in record
|
// the public key and:
|
||||||
pid, err := peer.IDFromString(r.Key)
|
//
|
||||||
if err != nil {
|
// 1. Don't want to fetch it from the network when handling PUTs.
|
||||||
return ErrInvalidAuthor
|
// 2. Do want to fetch it from the network when handling GETs.
|
||||||
}
|
//
|
||||||
if pid != r.Author {
|
// Therefore, we'll need to either:
|
||||||
return ErrInvalidAuthor
|
//
|
||||||
}
|
// 1. Pass some for of offline hint to the validator (e.g., using a context).
|
||||||
|
// 2. Ensure we pre-fetch the key when performing gets.
|
||||||
|
//
|
||||||
|
// This PR is already *way* too large so we're punting that fix to a new
|
||||||
|
// PR.
|
||||||
|
//
|
||||||
|
// This is not a regression, it just restores the current (bad)
|
||||||
|
// behavior.
|
||||||
|
|
||||||
// Check that record has not expired
|
// Check that record has not expired
|
||||||
switch entry.GetValidityType() {
|
switch entry.GetValidityType() {
|
||||||
|
Reference in New Issue
Block a user