Skip to content
Snippets Groups Projects
Commit aada551c authored by Josh Brooks's avatar Josh Brooks
Browse files

Have UD returned signed info

parent 45fb49c5
No related branches found
No related tags found
2 merge requests!58Draft: Projects/crust RELEASE,!55Add validateUsername endpoint to UD
......@@ -54,7 +54,7 @@ require (
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/zeebo/blake3 v0.1.1 // indirect
gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f // indirect
gitlab.com/elixxir/comms v0.0.4-0.20220826165747-4821117053d5 // indirect
gitlab.com/elixxir/comms v0.0.4-0.20220826182001-60e297d65b6c // indirect
gitlab.com/elixxir/ekv v0.1.7 // indirect
gitlab.com/xx_network/ring v0.0.3-0.20220222211904-da613960ad93 // indirect
go.uber.org/ratelimit v0.2.0 // indirect
......
......@@ -570,6 +570,10 @@ gitlab.com/elixxir/comms v0.0.4-0.20220819220424-f2328c8b26b1 h1:KZ8wKOenvQaYNKo
gitlab.com/elixxir/comms v0.0.4-0.20220819220424-f2328c8b26b1/go.mod h1:j6so9oYAj2YRjOOu11gFBldtxy4ez/oPkYfqM2J1q1k=
gitlab.com/elixxir/comms v0.0.4-0.20220826165747-4821117053d5 h1:iFNhvChvfRN9g29HvdngQ9R613H++WS7B/XgfJJRVzs=
gitlab.com/elixxir/comms v0.0.4-0.20220826165747-4821117053d5/go.mod h1:j6so9oYAj2YRjOOu11gFBldtxy4ez/oPkYfqM2J1q1k=
gitlab.com/elixxir/comms v0.0.4-0.20220826181555-87e3c7821fa0 h1:i71gTlUC6y83cKMIN9ttA4NK8mzawaWdOqVHmVjShtA=
gitlab.com/elixxir/comms v0.0.4-0.20220826181555-87e3c7821fa0/go.mod h1:j6so9oYAj2YRjOOu11gFBldtxy4ez/oPkYfqM2J1q1k=
gitlab.com/elixxir/comms v0.0.4-0.20220826182001-60e297d65b6c h1:yZwll9fm84J7AfULhekk3F/e/Ubhf1OOyJdvSPuUASU=
gitlab.com/elixxir/comms v0.0.4-0.20220826182001-60e297d65b6c/go.mod h1:j6so9oYAj2YRjOOu11gFBldtxy4ez/oPkYfqM2J1q1k=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp07WQmhA=
gitlab.com/elixxir/crypto v0.0.7-0.20220317172048-3de167bd9406/go.mod h1:tD6XjtQh87T2nKZL5I/pYPck5M2wLpkZ1Oz7H/LqO10=
......
......@@ -26,7 +26,7 @@ const (
func validateUsername(request *pb.UsernameValidationRequest,
store *storage.Storage, privKey *rsa.PrivateKey, rng io.Reader) (*pb.UsernameValidation, error) {
// Return an error if the request is invalid
if request == nil || request.Username == "" {
if request == nil || request.UserId == nil {
return &pb.UsernameValidation{}, errors.New("Unable to parse required " +
"fields in registration message")
}
......@@ -46,16 +46,9 @@ func validateUsername(request *pb.UsernameValidationRequest,
userID)
}
// Check that the username in storage matches the username in the request message
// before validating
if user.Username != request.Username {
return &pb.UsernameValidation{}, errors.Errorf(usernameNotAssociatedWithUser,
request.Username, userID)
}
// Create a signature verifying the user owns their username
verificationSignature, err := crust.SignVerification(rng, privKey,
request.Username, []byte(user.RsaPub))
user.Username, []byte(user.RsaPub))
if err != nil {
return nil, errors.Errorf("Failed to create verification signature: %v", err)
}
......
......@@ -54,8 +54,6 @@ func TestValidateUsername(t *testing.T) {
username := registerMsg.Frs.Fact.Fact
pubKeyPem := []byte(registerMsg.RSAPublicPem)
validationRequest := &pb.UsernameValidationRequest{
Username: username,
ReceptionPublicKeyPem: pubKeyPem,
UserId: registerMsg.UID,
}
......@@ -104,18 +102,4 @@ func TestValidateUsername_UsernameMismatch(t *testing.T) {
t.Errorf("Failed happy path: %v", err)
}
// Test Validate username ----------------------------------------------------------------------
pubKeyPem := []byte(registerMsg.RSAPublicPem)
validationRequest := &pb.UsernameValidationRequest{
Username: "admin",
ReceptionPublicKeyPem: pubKeyPem,
UserId: registerMsg.UID,
}
// Send a validation request using a username that does not belong to this user
_, err = validateUsername(validationRequest, store, rsaPrivKey, rand.Reader)
if err == nil { // This should return an error
t.Fatalf("Should not be able to validate username that is not ours")
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment