Skip to content

Commit

Permalink
Merge pull request #5079 from oasisprotocol/peternose/feature/km-poli…
Browse files Browse the repository at this point in the history
…cy-status

go/worker/keymanager: Show current key manager policy in the node status
  • Loading branch information
peternose authored Nov 30, 2022
2 parents cd20826 + a4ed204 commit d649c80
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/5079.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/worker/keymanager: Show current key manager policy in the node status
6 changes: 6 additions & 0 deletions go/worker/keymanager/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/libp2p/go-libp2p/core"

"github.com/oasisprotocol/oasis-core/go/common"
"github.com/oasisprotocol/oasis-core/go/keymanager/api"
)

// StatusState is the concise status state of the key manager worker.
Expand Down Expand Up @@ -97,4 +98,9 @@ type Status struct {
AccessList []RuntimeAccessList `json:"access_list"`
// PrivatePeers is a list of peers that are always allowed to call protected methods.
PrivatePeers []core.PeerID `json:"private_peers"`

// Policy is the key manager policy.
Policy *api.SignedPolicySGX `json:"signed_policy"`
// PolicyChecksum is the checksum of the key manager policy.
PolicyChecksum []byte `json:"policy_checksum"`
}
2 changes: 2 additions & 0 deletions go/worker/keymanager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ func (w *Worker) GetStatus(ctx context.Context) (*api.Status, error) {
ClientRuntimes: rts,
AccessList: al,
PrivatePeers: ps,
Policy: w.policy,
PolicyChecksum: w.policyChecksum,
}, nil
}
7 changes: 6 additions & 1 deletion go/worker/keymanager/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Worker struct { // nolint: maligned
enclaveStatus *api.SignedInitResponse
backend api.Backend

policy *api.SignedPolicySGX
policyChecksum []byte

enabled bool
mayGenerate bool
}
Expand Down Expand Up @@ -338,11 +341,13 @@ func (w *Worker) updateStatus(status *api.Status, runtimeStatus *runtimeStatus)
return nil
})

// Cache the key manager enclave status.
// Cache the key manager enclave status and the currently active policy.
w.Lock()
defer w.Unlock()

w.enclaveStatus = &signedInitResp
w.policy = status.Policy
w.policyChecksum = signedInitResp.InitResponse.PolicyChecksum

return nil
}
Expand Down

0 comments on commit d649c80

Please sign in to comment.