Skip to content

Commit

Permalink
fix(prove): Store the original KeyID on config.profile
Browse files Browse the repository at this point in the history
  • Loading branch information
dustmop committed Apr 20, 2021
1 parent 553a8aa commit 88214a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
type ProfilePod struct {
ID string `json:"id"`
PrivKey string `json:"privkey,omitempty"`
KeyID string `json:"keyid"`
Peername string `json:"peername"`
// Created timestamp
Created time.Time `json:"created"`
Expand Down Expand Up @@ -210,6 +211,7 @@ func (p ProfilePod) Validate() error {
func (p *ProfilePod) Copy() *ProfilePod {
res := &ProfilePod{
ID: p.ID,
KeyID: p.KeyID,
PrivKey: p.PrivKey,
Peername: p.Peername,
Created: p.Created,
Expand Down
2 changes: 2 additions & 0 deletions lib/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func (registryImpl) ProveProfileKey(scope scope, p *RegistryProfileParams) error
// Convert the profile to a configuration, assign the registry provided profileID
cfg := configFromProfile(scope, p.Profile)
if profileID, ok := res["profileID"]; ok {
// Store the old profile as the keyID since it came from the original keypair
cfg.Profile.KeyID = cfg.Profile.ID
cfg.Profile.ID = profileID
if pid := profile.IDB58DecodeOrEmpty(profileID); pid != "" {
// Assign to profile struct as well
Expand Down
3 changes: 3 additions & 0 deletions profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ func (p *Profile) Decode(sp *config.ProfilePod) error {
}
}

keyID := IDB58DecodeOrEmpty(sp.KeyID)

pro := Profile{
ID: id,
KeyID: key.ID(keyID),
Type: t,
Peername: sp.Peername,
Created: sp.Created,
Expand Down

0 comments on commit 88214a4

Please sign in to comment.