Skip to content

Agent Mesh

api: every instant on the wire is a Timestamp

Antonio Ojeab7893b271003
diff --git a/AGENTS.md b/AGENTS.md
index 8d8db18e..9a531302 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,7 +6,7 @@ You are an expert software engineering assistant helping to develop, maintain, a
* **Decoupled Architecture:** The `sam-control-plane`, `sam-router` and `sam-node` components are strictly independent. They must not share internal state or tightly couple their logic.
* **API Communication:** All data communication between `sam-control-plane`, `sam-router` and `sam-node` must happen exclusively via the common API defined in `api/sam.proto`.
* **One schema, two encodings:** every request and response on any SAM surface is a message in `api/sam.proto`. The *mesh protocol* — anything a mesh component speaks (node, router, `sam-box`, the agent connector, the SDKs under `sdk/`): enrollment, refresh, keys, leases, auth streams, policy sync — is binary protobuf (`application/x-protobuf`). The *operator plane* — what humans, the web console and admin CLIs call (`/admin/*`, `/users/*`, `POST /policies`) — is protojson of the same messages, with `UseProtoNames` and unknown fields rejected. Never define a wire shape as a Go struct with `json` tags, an anonymous struct or `map[string]any`, and never serialize an `internal/storage` (or any other internal) type onto either surface. Clients in `cmd/`, `internal/console` and `sdk/` import `api/` or its generated bindings only.
-* **Instants are `google.protobuf.Timestamp`, named `*_time`** (`expire_time`, `receive_time`), never `int64` seconds or milliseconds. `Timestamp` has fixed units, an explicit unset, renders as RFC 3339 in protojson (an `int64` renders as a quoted decimal string), and has a first-class conversion in Go, JavaScript, Python and Dart. The `int64` instants still in `api/sam.proto` predate this rule; converting them is a coordinated protocol change, not something to do one field at a time. What a member persists between runs is also a message here (`MemberCredential`), so a state directory written by one implementation loads in another.
+* **Instants are `google.protobuf.Timestamp`, named `*_time`** (`expire_time`, `sign_time`, `event_time`), never `int64` seconds or milliseconds. `Timestamp` has fixed units, an explicit unset, renders as RFC 3339 in protojson (an `int64` renders as a quoted decimal string), and has a first-class conversion in Go, JavaScript, Python and Dart. A receiver treats an unset instant as invalid, never as the epoch. The one exception is a proof-of-possession value: it is the number that appears in the signed text (`sam:<endpoint>:<peer_id>:<n>`), so it stays an `int64` named `challenge_unix_ms`, the unit in the name. What a member persists between runs is also a message here (`MemberCredential`), so a state directory written by one implementation loads in another.
* **Datalog text is the policy contract:** the control plane renders the mesh policy as Datalog rules (`PolicyConfigGetResponse.datalog_rules`); every member, in any language, adds that text to its authorizer and none derives rules from roles and bindings itself. Datalog must stay in the form every Biscuit implementation parses: a predicate carries at least one term (presence-only facts are `name(true)`, see `api.MarkerFact`).
* **Secrets never travel as flag values:** binaries read credentials from a file (`--*-path`) or the environment, never from a command-line argument that would sit in `ps` output and shell history. Banners and logs name the source of an operator-supplied secret instead of echoing it.
* **Sandbox Dataplane:** `sam-box` (one per sandbox) is the single egress policy enforcement point. It holds no libp2p host, no enrollment and no mesh identity, and reaches the mesh exclusively as a client of the local `sam-node` sidecar socket. `nano-init` (PID 1 inside the guest, its own Go module) owns the guest side; its datapath is the `tun2connect` library. The sandbox boundary is a Unix socket speaking named HTTP tunnels: CONNECT (TCP) and connect-udp (UDP) out, `CONNECT <port>` back in. The authoritative design is `site/content/docs/preview/agent-architecture.md`; do not contradict it.
diff --git a/api/sam.pb.go b/api/sam.pb.go
index 9b44a6c3..291e6373 100644
--- a/api/sam.pb.go
+++ b/api/sam.pb.go
@@ -314,10 +314,13 @@ func (x *AuthResponse) GetBiscuit() []byte {
}
type MeshEvent struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Type MeshEvent_Type `protobuf:"varint,1,opt,name=type,proto3,enum=sam.v1.MeshEvent_Type" json:"type,omitempty"`
- PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
- Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Type MeshEvent_Type `protobuf:"varint,1,opt,name=type,proto3,enum=sam.v1.MeshEvent_Type" json:"type,omitempty"`
+ PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
+ // When the control plane recorded the event. Receivers ignore an event
+ // further than a few minutes from their clock and, for bans, one older
+ // than the last they applied for the peer.
+ EventTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=event_time,json=eventTime,proto3" json:"event_time,omitempty"`
NewPublicKey []byte `protobuf:"bytes,4,opt,name=new_public_key,json=newPublicKey,proto3" json:"new_public_key,omitempty"`
Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"`
unknownFields protoimpl.UnknownFields
@@ -368,11 +371,11 @@ func (x *MeshEvent) GetPeerId() string {
return ""
}
-func (x *MeshEvent) GetTimestamp() int64 {
+func (x *MeshEvent) GetEventTime() *timestamppb.Timestamp {
if x != nil {
- return x.Timestamp
+ return x.EventTime
}
- return 0
+ return nil
}
func (x *MeshEvent) GetNewPublicKey() []byte {
@@ -400,13 +403,15 @@ type EnrollRequest struct {
// enrollment flow's gates, minted as signed label() facts in the
// biscuit. Empty means no claims.
Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
- // Proof of possession of public_key's private half: timestamp is unix
- // milliseconds and challenge_signature signs the UTF-8 bytes of
- // "sam:register:<peer_id>:<timestamp>". Required, and peer_id must be
- // derived from public_key. The JWT proves who is asking; this proves
- // they hold the key they are asking to bind, so an identity cannot
- // register (and overwrite) another node's peer_id.
- Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ // Proof of possession of public_key's private half: challenge_unix_ms is
+ // the caller's clock in unix milliseconds and challenge_signature signs
+ // the UTF-8 bytes of "sam:register:<peer_id>:<challenge_unix_ms>". It is
+ // an int64 because it is the number in the signed text, not an instant
+ // for display. Required, and peer_id must be derived from public_key.
+ // The JWT proves who is asking; this proves they hold the key they are
+ // asking to bind, so an identity cannot register (and overwrite) another
+ // node's peer_id.
+ ChallengeUnixMs int64 `protobuf:"varint,6,opt,name=challenge_unix_ms,json=challengeUnixMs,proto3" json:"challenge_unix_ms,omitempty"`
ChallengeSignature []byte `protobuf:"bytes,7,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -477,9 +482,9 @@ func (x *EnrollRequest) GetLabels() map[string]string {
return nil
}
-func (x *EnrollRequest) GetTimestamp() int64 {
+func (x *EnrollRequest) GetChallengeUnixMs() int64 {
if x != nil {
- return x.Timestamp
+ return x.ChallengeUnixMs
}
return 0
}
@@ -497,7 +502,7 @@ type EnrollResponse struct {
ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"`
ControlPlanePublicKey []byte `protobuf:"bytes,3,opt,name=control_plane_public_key,json=controlPlanePublicKey,proto3" json:"control_plane_public_key,omitempty"`
RouterAddresses []string `protobuf:"bytes,4,rep,name=router_addresses,json=routerAddresses,proto3" json:"router_addresses,omitempty"`
- Expiration int64 `protobuf:"varint,5,opt,name=expiration,proto3" json:"expiration,omitempty"`
+ ExpireTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -560,11 +565,11 @@ func (x *EnrollResponse) GetRouterAddresses() []string {
return nil
}
-func (x *EnrollResponse) GetExpiration() int64 {
+func (x *EnrollResponse) GetExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.Expiration
+ return x.ExpireTime
}
- return 0
+ return nil
}
type BootstrapEnrollRequest struct {
@@ -576,13 +581,13 @@ type BootstrapEnrollRequest struct {
// Operator-declared labels; the admin approving the enrollment attests
// them (see EnrollRequest.labels).
Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
- // Proof of possession of public_key's private half: timestamp is unix
- // milliseconds and challenge_signature signs the UTF-8 bytes of
- // "sam:enroll:<peer_id>:<timestamp>". Required, and peer_id must be
- // derived from public_key: this is what entitles a repeated POST /enroll
- // to re-fetch an existing enrollment's biscuit, so a bootstrap token
- // alone must never satisfy it.
- Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ // Proof of possession of public_key's private half: challenge_unix_ms is
+ // the caller's clock in unix milliseconds and challenge_signature signs
+ // the UTF-8 bytes of "sam:enroll:<peer_id>:<challenge_unix_ms>". Required,
+ // and peer_id must be derived from public_key: this is what entitles a
+ // repeated POST /enroll to re-fetch an existing enrollment's biscuit, so
+ // a bootstrap token alone must never satisfy it.
+ ChallengeUnixMs int64 `protobuf:"varint,6,opt,name=challenge_unix_ms,json=challengeUnixMs,proto3" json:"challenge_unix_ms,omitempty"`
ChallengeSignature []byte `protobuf:"bytes,7,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -653,9 +658,9 @@ func (x *BootstrapEnrollRequest) GetLabels() map[string]string {
return nil
}
-func (x *BootstrapEnrollRequest) GetTimestamp() int64 {
+func (x *BootstrapEnrollRequest) GetChallengeUnixMs() int64 {
if x != nil {
- return x.Timestamp
+ return x.ChallengeUnixMs
}
return 0
}
@@ -681,7 +686,7 @@ type BootstrapEnrollResponse struct {
ErrorMessage string `protobuf:"bytes,4,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"`
ControlPlanePublicKey []byte `protobuf:"bytes,5,opt,name=control_plane_public_key,json=controlPlanePublicKey,proto3" json:"control_plane_public_key,omitempty"` // Populated only if APPROVED
RouterAddresses []string `protobuf:"bytes,6,rep,name=router_addresses,json=routerAddresses,proto3" json:"router_addresses,omitempty"` // Populated only if APPROVED
- Expiration int64 `protobuf:"varint,7,opt,name=expiration,proto3" json:"expiration,omitempty"` // Populated only if APPROVED
+ ExpireTime *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"` // Populated only if APPROVED
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -758,11 +763,11 @@ func (x *BootstrapEnrollResponse) GetRouterAddresses() []string {
return nil
}
-func (x *BootstrapEnrollResponse) GetExpiration() int64 {
+func (x *BootstrapEnrollResponse) GetExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.Expiration
+ return x.ExpireTime
}
- return 0
+ return nil
}
type ServiceInfo struct {
@@ -1051,9 +1056,9 @@ type ServiceAnnounce struct {
// take precedence over runtime-derived values.
Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
// Runtime load hints; zero values mean unknown.
- ActiveRequests uint32 `protobuf:"varint,6,opt,name=active_requests,json=activeRequests,proto3" json:"active_requests,omitempty"`
- LatencyEwmaMs float64 `protobuf:"fixed64,7,opt,name=latency_ewma_ms,json=latencyEwmaMs,proto3" json:"latency_ewma_ms,omitempty"`
- Timestamp int64 `protobuf:"varint,8,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ ActiveRequests uint32 `protobuf:"varint,6,opt,name=active_requests,json=activeRequests,proto3" json:"active_requests,omitempty"`
+ LatencyEwmaMs float64 `protobuf:"fixed64,7,opt,name=latency_ewma_ms,json=latencyEwmaMs,proto3" json:"latency_ewma_ms,omitempty"`
+ AnnounceTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=announce_time,json=announceTime,proto3" json:"announce_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1137,11 +1142,11 @@ func (x *ServiceAnnounce) GetLatencyEwmaMs() float64 {
return 0
}
-func (x *ServiceAnnounce) GetTimestamp() int64 {
+func (x *ServiceAnnounce) GetAnnounceTime() *timestamppb.Timestamp {
if x != nil {
- return x.Timestamp
+ return x.AnnounceTime
}
- return 0
+ return nil
}
type ControlPlaneInfoResponse struct {
@@ -1233,12 +1238,12 @@ type RouterLeaseRequest struct {
Biscuit []byte `protobuf:"bytes,3,opt,name=biscuit,proto3" json:"biscuit,omitempty"`
ConnectedPeers []string `protobuf:"bytes,4,rep,name=connected_peers,json=connectedPeers,proto3" json:"connected_peers,omitempty"`
DhtSize int32 `protobuf:"varint,5,opt,name=dht_size,json=dhtSize,proto3" json:"dht_size,omitempty"`
- // Proof of possession of the router's enrolled key: timestamp is unix
- // milliseconds and challenge_signature signs the UTF-8 bytes of
- // "sam:routers-lease:<peer_id>:<timestamp>" with the key the router
- // enrolled with. Required. The biscuit alone is not proof: routers hand
- // theirs to every peer they authenticate.
- Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ // Proof of possession of the router's enrolled key: challenge_unix_ms is
+ // the caller's clock in unix milliseconds and challenge_signature signs
+ // the UTF-8 bytes of "sam:routers-lease:<peer_id>:<challenge_unix_ms>"
+ // with the key the router enrolled with. Required. The biscuit alone is
+ // not proof: routers hand theirs to every peer they authenticate.
+ ChallengeUnixMs int64 `protobuf:"varint,6,opt,name=challenge_unix_ms,json=challengeUnixMs,proto3" json:"challenge_unix_ms,omitempty"`
ChallengeSignature []byte `protobuf:"bytes,7,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -1309,9 +1314,9 @@ func (x *RouterLeaseRequest) GetDhtSize() int32 {
return 0
}
-func (x *RouterLeaseRequest) GetTimestamp() int64 {
+func (x *RouterLeaseRequest) GetChallengeUnixMs() int64 {
if x != nil {
- return x.Timestamp
+ return x.ChallengeUnixMs
}
return 0
}
@@ -1327,7 +1332,7 @@ type RouterLeaseResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
- ExpiresAt int64 `protobuf:"varint,3,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
+ ExpireTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1376,11 +1381,11 @@ func (x *RouterLeaseResponse) GetError() string {
return ""
}
-func (x *RouterLeaseResponse) GetExpiresAt() int64 {
+func (x *RouterLeaseResponse) GetExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.ExpiresAt
+ return x.ExpireTime
}
- return 0
+ return nil
}
type PolicyRole struct {
@@ -1721,9 +1726,9 @@ func (x *PolicyConfigUpdateResponse) GetError() string {
type KeysResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
PublicKeys [][]byte `protobuf:"bytes,1,rep,name=public_keys,json=publicKeys,proto3" json:"public_keys,omitempty"`
- // Unix milliseconds at which the set was signed; receivers reject responses
- // outside a short freshness window so a captured set cannot be replayed.
- Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ // When the set was signed; receivers reject responses outside a short
+ // freshness window so a captured set cannot be replayed.
+ SignTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=sign_time,json=signTime,proto3" json:"sign_time,omitempty"`
// One ed25519 signature per entry of public_keys, by that key, over the
// deterministic encoding of this message with signatures cleared. A
// receiver trusting any key still valid on the control plane can verify
@@ -1770,11 +1775,11 @@ func (x *KeysResponse) GetPublicKeys() [][]byte {
return nil
}
-func (x *KeysResponse) GetTimestamp() int64 {
+func (x *KeysResponse) GetSignTime() *timestamppb.Timestamp {
if x != nil {
- return x.Timestamp
+ return x.SignTime
}
- return 0
+ return nil
}
func (x *KeysResponse) GetSignatures() [][]byte {
@@ -1787,12 +1792,13 @@ func (x *KeysResponse) GetSignatures() [][]byte {
type TokenRefreshRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Signature with the node key over the UTF-8 bytes of
- // "sam:refresh:<peer_id>:<timestamp>", where peer_id is the one bound in
- // the presented biscuit. Peer- and endpoint-bound so a captured signature
- // verifies nowhere else.
+ // "sam:refresh:<peer_id>:<challenge_unix_ms>", where peer_id is the one
+ // bound in the presented biscuit. Peer- and endpoint-bound so a captured
+ // signature verifies nowhere else.
ChallengeSignature []byte `protobuf:"bytes,1,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`
- // Unix milliseconds. Must be within the control plane's freshness window.
- Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ // The caller's clock in unix milliseconds, the number in the signed text.
+ // Must be within the control plane's freshness window.
+ ChallengeUnixMs int64 `protobuf:"varint,2,opt,name=challenge_unix_ms,json=challengeUnixMs,proto3" json:"challenge_unix_ms,omitempty"`
// The caller's peer ID. Optional: the control plane normally reads it
// from the verified biscuit. It is consulted only when the biscuit's
// signing key has been retired, so the biscuit cannot be verified: the
@@ -1842,9 +1848,9 @@ func (x *TokenRefreshRequest) GetChallengeSignature() []byte {
return nil
}
-func (x *TokenRefreshRequest) GetTimestamp() int64 {
+func (x *TokenRefreshRequest) GetChallengeUnixMs() int64 {
if x != nil {
- return x.Timestamp
+ return x.ChallengeUnixMs
}
return 0
}
@@ -1859,7 +1865,7 @@ func (x *TokenRefreshRequest) GetPeerId() string {
type TokenRefreshResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
BiscuitToken []byte `protobuf:"bytes,1,opt,name=biscuit_token,json=biscuitToken,proto3" json:"biscuit_token,omitempty"`
- ExpiresAt int64 `protobuf:"varint,2,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
+ ExpireTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"`
ErrorMessage string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -1902,11 +1908,11 @@ func (x *TokenRefreshResponse) GetBiscuitToken() []byte {
return nil
}
-func (x *TokenRefreshResponse) GetExpiresAt() int64 {
+func (x *TokenRefreshResponse) GetExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.ExpiresAt
+ return x.ExpireTime
}
- return 0
+ return nil
}
func (x *TokenRefreshResponse) GetErrorMessage() string {
@@ -2618,7 +2624,7 @@ type AgentRefreshResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
- ExpiresAt int64 `protobuf:"varint,3,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
+ ExpireTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -2667,11 +2673,11 @@ func (x *AgentRefreshResponse) GetError() string {
return ""
}
-func (x *AgentRefreshResponse) GetExpiresAt() int64 {
+func (x *AgentRefreshResponse) GetExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.ExpiresAt
+ return x.ExpireTime
}
- return 0
+ return nil
}
// AgentStatusRequest reports on one agent, or on all of them when agent_id is
@@ -2721,13 +2727,13 @@ func (x *AgentStatusRequest) GetAgentId() string {
}
type AgentStatus struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`
- Attached bool `protobuf:"varint,2,opt,name=attached,proto3" json:"attached,omitempty"`
- Ingress []*AgentIngress `protobuf:"bytes,3,rep,name=ingress,proto3" json:"ingress,omitempty"`
- CredentialExpiresAt int64 `protobuf:"varint,4,opt,name=credential_expires_at,json=credentialExpiresAt,proto3" json:"credential_expires_at,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ state protoimpl.MessageState `protogen:"open.v1"`
+ AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`
+ Attached bool `protobuf:"varint,2,opt,name=attached,proto3" json:"attached,omitempty"`
+ Ingress []*AgentIngress `protobuf:"bytes,3,rep,name=ingress,proto3" json:"ingress,omitempty"`
+ CredentialExpireTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=credential_expire_time,json=credentialExpireTime,proto3" json:"credential_expire_time,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *AgentStatus) Reset() {
@@ -2781,11 +2787,11 @@ func (x *AgentStatus) GetIngress() []*AgentIngress {
return nil
}
-func (x *AgentStatus) GetCredentialExpiresAt() int64 {
+func (x *AgentStatus) GetCredentialExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.CredentialExpiresAt
+ return x.CredentialExpireTime
}
- return 0
+ return nil
}
type AgentStatusResponse struct {
@@ -2844,10 +2850,10 @@ type IdentityEvidenceResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
PeerId string `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
Biscuit []byte `protobuf:"bytes,2,opt,name=biscuit,proto3" json:"biscuit,omitempty"`
- BiscuitExpiresAt int64 `protobuf:"varint,3,opt,name=biscuit_expires_at,json=biscuitExpiresAt,proto3" json:"biscuit_expires_at,omitempty"`
+ BiscuitExpireTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=biscuit_expire_time,json=biscuitExpireTime,proto3" json:"biscuit_expire_time,omitempty"`
ControlPlaneUrl string `protobuf:"bytes,4,opt,name=control_plane_url,json=controlPlaneUrl,proto3" json:"control_plane_url,omitempty"`
TrustedControlPlaneKeys [][]byte `protobuf:"bytes,5,rep,name=trusted_control_plane_keys,json=trustedControlPlaneKeys,proto3" json:"trusted_control_plane_keys,omitempty"` // Ed25519 SPKI DER
- CheckedAt int64 `protobuf:"varint,6,opt,name=checked_at,json=checkedAt,proto3" json:"checked_at,omitempty"`
+ CheckTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=check_time,json=checkTime,proto3" json:"check_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -2896,11 +2902,11 @@ func (x *IdentityEvidenceResponse) GetBiscuit() []byte {
return nil
}
-func (x *IdentityEvidenceResponse) GetBiscuitExpiresAt() int64 {
+func (x *IdentityEvidenceResponse) GetBiscuitExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.BiscuitExpiresAt
+ return x.BiscuitExpireTime
}
- return 0
+ return nil
}
func (x *IdentityEvidenceResponse) GetControlPlaneUrl() string {
@@ -2917,11 +2923,11 @@ func (x *IdentityEvidenceResponse) GetTrustedControlPlaneKeys() [][]byte {
return nil
}
-func (x *IdentityEvidenceResponse) GetCheckedAt() int64 {
+func (x *IdentityEvidenceResponse) GetCheckTime() *timestamppb.Timestamp {
if x != nil {
- return x.CheckedAt
+ return x.CheckTime
}
- return 0
+ return nil
}
type PeerEvidenceResponse struct {
@@ -2931,9 +2937,9 @@ type PeerEvidenceResponse struct {
VerifyingKey []byte `protobuf:"bytes,3,opt,name=verifying_key,json=verifyingKey,proto3" json:"verifying_key,omitempty"` // Ed25519 SPKI DER, member of the trusted set
Roles []string `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"`
Labels map[string]string `protobuf:"bytes,5,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
- Expiration int64 `protobuf:"varint,6,opt,name=expiration,proto3" json:"expiration,omitempty"`
+ ExpireTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"`
RevocationIds []string `protobuf:"bytes,7,rep,name=revocation_ids,json=revocationIds,proto3" json:"revocation_ids,omitempty"` // hex
- CheckedAt int64 `protobuf:"varint,8,opt,name=checked_at,json=checkedAt,proto3" json:"checked_at,omitempty"`
+ CheckTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=check_time,json=checkTime,proto3" json:"check_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -3003,11 +3009,11 @@ func (x *PeerEvidenceResponse) GetLabels() map[string]string {
return nil
}
-func (x *PeerEvidenceResponse) GetExpiration() int64 {
+func (x *PeerEvidenceResponse) GetExpireTime() *timestamppb.Timestamp {
if x != nil {
- return x.Expiration
+ return x.ExpireTime
}
- return 0
+ return nil
}
func (x *PeerEvidenceResponse) GetRevocationIds() []string {
@@ -3017,11 +3023,11 @@ func (x *PeerEvidenceResponse) GetRevocationIds() []string {
return nil
}
-func (x *PeerEvidenceResponse) GetCheckedAt() int64 {
+func (x *PeerEvidenceResponse) GetCheckTime() *timestamppb.Timestamp {
if x != nil {
- return x.CheckedAt
+ return x.CheckTime
}
- return 0
+ return nil
}
type MemberCredential struct {
@@ -3262,60 +3268,59 @@ const file_api_sam_proto_rawDesc = "" +
"\fAuthResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" +
"\x05error\x18\x02 \x01(\tR\x05error\x12\x18\n" +
- "\abiscuit\x18\x03 \x01(\fR\abiscuit\"\xeb\x01\n" +
+ "\abiscuit\x18\x03 \x01(\fR\abiscuit\"\x88\x02\n" +
"\tMeshEvent\x12*\n" +
"\x04type\x18\x01 \x01(\x0e2\x16.sam.v1.MeshEvent.TypeR\x04type\x12\x17\n" +
- "\apeer_id\x18\x02 \x01(\tR\x06peerId\x12\x1c\n" +
- "\ttimestamp\x18\x03 \x01(\x03R\ttimestamp\x12$\n" +
+ "\apeer_id\x18\x02 \x01(\tR\x06peerId\x129\n" +
+ "\n" +
+ "event_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\teventTime\x12$\n" +
"\x0enew_public_key\x18\x04 \x01(\fR\fnewPublicKey\x12\x1c\n" +
"\tsignature\x18\x05 \x01(\fR\tsignature\"7\n" +
"\x04Type\x12\n" +
"\n" +
"\x06BANNED\x10\x00\x12\x10\n" +
"\fKEY_ROTATION\x10\x01\x12\x11\n" +
- "\rPOLICY_UPDATE\x10\x02\"\xc5\x02\n" +
+ "\rPOLICY_UPDATE\x10\x02\"\xd3\x02\n" +
"\rEnrollRequest\x12\x10\n" +
"\x03jwt\x18\x01 \x01(\tR\x03jwt\x12\x17\n" +
"\apeer_id\x18\x02 \x01(\tR\x06peerId\x12\x1d\n" +
"\n" +
"public_key\x18\x03 \x01(\fR\tpublicKey\x12%\n" +
"\x0erequested_role\x18\x04 \x01(\tR\rrequestedRole\x129\n" +
- "\x06labels\x18\x05 \x03(\v2!.sam.v1.EnrollRequest.LabelsEntryR\x06labels\x12\x1c\n" +
- "\ttimestamp\x18\x06 \x01(\x03R\ttimestamp\x12/\n" +
+ "\x06labels\x18\x05 \x03(\v2!.sam.v1.EnrollRequest.LabelsEntryR\x06labels\x12*\n" +
+ "\x11challenge_unix_ms\x18\x06 \x01(\x03R\x0fchallengeUnixMs\x12/\n" +
"\x13challenge_signature\x18\a \x01(\fR\x12challengeSignature\x1a9\n" +
"\vLabelsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
- "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xde\x01\n" +
+ "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xfb\x01\n" +
"\x0eEnrollResponse\x12#\n" +
"\rbiscuit_token\x18\x01 \x01(\fR\fbiscuitToken\x12#\n" +
"\rerror_message\x18\x02 \x01(\tR\ferrorMessage\x127\n" +
"\x18control_plane_public_key\x18\x03 \x01(\fR\x15controlPlanePublicKey\x12)\n" +
- "\x10router_addresses\x18\x04 \x03(\tR\x0frouterAddresses\x12\x1e\n" +
- "\n" +
- "expiration\x18\x05 \x01(\x03R\n" +
- "expiration\"\xee\x02\n" +
+ "\x10router_addresses\x18\x04 \x03(\tR\x0frouterAddresses\x12;\n" +
+ "\vexpire_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
+ "expireTime\"\xfc\x02\n" +
"\x16BootstrapEnrollRequest\x12'\n" +
"\x0fbootstrap_token\x18\x01 \x01(\tR\x0ebootstrapToken\x12\x17\n" +
"\apeer_id\x18\x02 \x01(\tR\x06peerId\x12\x1d\n" +
"\n" +
"public_key\x18\x03 \x01(\fR\tpublicKey\x12%\n" +
"\x0erequested_role\x18\x04 \x01(\tR\rrequestedRole\x12B\n" +
- "\x06labels\x18\x05 \x03(\v2*.sam.v1.BootstrapEnrollRequest.LabelsEntryR\x06labels\x12\x1c\n" +
- "\ttimestamp\x18\x06 \x01(\x03R\ttimestamp\x12/\n" +
+ "\x06labels\x18\x05 \x03(\v2*.sam.v1.BootstrapEnrollRequest.LabelsEntryR\x06labels\x12*\n" +
+ "\x11challenge_unix_ms\x18\x06 \x01(\x03R\x0fchallengeUnixMs\x12/\n" +
"\x13challenge_signature\x18\a \x01(\fR\x12challengeSignature\x1a9\n" +
"\vLabelsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
- "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xcd\x02\n" +
+ "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xea\x02\n" +
"\x17BootstrapEnrollResponse\x120\n" +
"\x06status\x18\x01 \x01(\x0e2\x18.sam.v1.EnrollmentStatusR\x06status\x12#\n" +
"\rbiscuit_token\x18\x02 \x01(\fR\fbiscuitToken\x122\n" +
"\x15poll_interval_seconds\x18\x03 \x01(\x05R\x13pollIntervalSeconds\x12#\n" +
"\rerror_message\x18\x04 \x01(\tR\ferrorMessage\x127\n" +
"\x18control_plane_public_key\x18\x05 \x01(\fR\x15controlPlanePublicKey\x12)\n" +
- "\x10router_addresses\x18\x06 \x03(\tR\x0frouterAddresses\x12\x1e\n" +
- "\n" +
- "expiration\x18\a \x01(\x03R\n" +
- "expiration\"l\n" +
+ "\x10router_addresses\x18\x06 \x03(\tR\x0frouterAddresses\x12;\n" +
+ "\vexpire_time\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\n" +
+ "expireTime\"l\n" +
"\vServiceInfo\x12'\n" +
"\x04type\x18\x01 \x01(\x0e2\x13.sam.v1.ServiceTypeR\x04type\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12 \n" +
@@ -3336,7 +3341,7 @@ const file_api_sam_proto_rawDesc = "" +
"\apeer_id\x18\x01 \x01(\tR\x06peerId\x12&\n" +
"\x0flocal_proxy_url\x18\x02 \x01(\tR\rlocalProxyUrl\x12\x19\n" +
"\bsrv_name\x18\x03 \x01(\tR\asrvName\x12'\n" +
- "\x0fsrv_description\x18\x04 \x01(\tR\x0esrvDescription\"\xf1\x02\n" +
+ "\x0fsrv_description\x18\x04 \x01(\tR\x0esrvDescription\"\x94\x03\n" +
"\x0fServiceAnnounce\x12\x17\n" +
"\apeer_id\x18\x01 \x01(\tR\x06peerId\x12'\n" +
"\x04type\x18\x02 \x01(\x0e2\x13.sam.v1.ServiceTypeR\x04type\x12!\n" +
@@ -3344,8 +3349,8 @@ const file_api_sam_proto_rawDesc = "" +
"\x04keys\x18\x04 \x03(\tR\x04keys\x12;\n" +
"\x06labels\x18\x05 \x03(\v2#.sam.v1.ServiceAnnounce.LabelsEntryR\x06labels\x12'\n" +
"\x0factive_requests\x18\x06 \x01(\rR\x0eactiveRequests\x12&\n" +
- "\x0flatency_ewma_ms\x18\a \x01(\x01R\rlatencyEwmaMs\x12\x1c\n" +
- "\ttimestamp\x18\b \x01(\x03R\ttimestamp\x1a9\n" +
+ "\x0flatency_ewma_ms\x18\a \x01(\x01R\rlatencyEwmaMs\x12?\n" +
+ "\rannounce_time\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\fannounceTime\x1a9\n" +
"\vLabelsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xc7\x01\n" +
@@ -3355,20 +3360,20 @@ const file_api_sam_proto_rawDesc = "" +
"\tclient_id\x18\x02 \x01(\tR\bclientId\x12\x1a\n" +
"\baudience\x18\x03 \x01(\tR\baudience\x12)\n" +
"\x10router_addresses\x18\x04 \x03(\tR\x0frouterAddresses\x12&\n" +
- "\x0fbanned_peer_ids\x18\x05 \x03(\tR\rbannedPeerIds\"\xf8\x01\n" +
+ "\x0fbanned_peer_ids\x18\x05 \x03(\tR\rbannedPeerIds\"\x86\x02\n" +
"\x12RouterLeaseRequest\x12\x17\n" +
"\apeer_id\x18\x01 \x01(\tR\x06peerId\x12\x1c\n" +
"\taddresses\x18\x02 \x03(\tR\taddresses\x12\x18\n" +
"\abiscuit\x18\x03 \x01(\fR\abiscuit\x12'\n" +
"\x0fconnected_peers\x18\x04 \x03(\tR\x0econnectedPeers\x12\x19\n" +
- "\bdht_size\x18\x05 \x01(\x05R\adhtSize\x12\x1c\n" +
- "\ttimestamp\x18\x06 \x01(\x03R\ttimestamp\x12/\n" +
- "\x13challenge_signature\x18\a \x01(\fR\x12challengeSignature\"d\n" +
+ "\bdht_size\x18\x05 \x01(\x05R\adhtSize\x12*\n" +
+ "\x11challenge_unix_ms\x18\x06 \x01(\x03R\x0fchallengeUnixMs\x12/\n" +
+ "\x13challenge_signature\x18\a \x01(\fR\x12challengeSignature\"\x82\x01\n" +
"\x13RouterLeaseResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" +
- "\x05error\x18\x02 \x01(\tR\x05error\x12\x1d\n" +
- "\n" +
- "expires_at\x18\x03 \x01(\x03R\texpiresAt\"\xe9\x01\n" +
+ "\x05error\x18\x02 \x01(\tR\x05error\x12;\n" +
+ "\vexpire_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
+ "expireTime\"\xe9\x01\n" +
"\n" +
"PolicyRole\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12'\n" +
@@ -3388,22 +3393,22 @@ const file_api_sam_proto_rawDesc = "" +
"\rdatalog_rules\x18\x03 \x03(\tR\fdatalogRulesJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03R\x05rolesR\bbindings\"L\n" +
"\x1aPolicyConfigUpdateResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" +
- "\x05error\x18\x02 \x01(\tR\x05error\"m\n" +
+ "\x05error\x18\x02 \x01(\tR\x05error\"\x88\x01\n" +
"\fKeysResponse\x12\x1f\n" +
"\vpublic_keys\x18\x01 \x03(\fR\n" +
- "publicKeys\x12\x1c\n" +
- "\ttimestamp\x18\x02 \x01(\x03R\ttimestamp\x12\x1e\n" +
+ "publicKeys\x127\n" +
+ "\tsign_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\bsignTime\x12\x1e\n" +
"\n" +
"signatures\x18\x03 \x03(\fR\n" +
- "signatures\"}\n" +
+ "signatures\"\x8b\x01\n" +
"\x13TokenRefreshRequest\x12/\n" +
- "\x13challenge_signature\x18\x01 \x01(\fR\x12challengeSignature\x12\x1c\n" +
- "\ttimestamp\x18\x02 \x01(\x03R\ttimestamp\x12\x17\n" +
- "\apeer_id\x18\x03 \x01(\tR\x06peerId\"\x7f\n" +
+ "\x13challenge_signature\x18\x01 \x01(\fR\x12challengeSignature\x12*\n" +
+ "\x11challenge_unix_ms\x18\x02 \x01(\x03R\x0fchallengeUnixMs\x12\x17\n" +
+ "\apeer_id\x18\x03 \x01(\tR\x06peerId\"\x9d\x01\n" +
"\x14TokenRefreshResponse\x12#\n" +
- "\rbiscuit_token\x18\x01 \x01(\fR\fbiscuitToken\x12\x1d\n" +
- "\n" +
- "expires_at\x18\x02 \x01(\x03R\texpiresAt\x12#\n" +
+ "\rbiscuit_token\x18\x01 \x01(\fR\fbiscuitToken\x12;\n" +
+ "\vexpire_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
+ "expireTime\x12#\n" +
"\rerror_message\x18\x03 \x01(\tR\ferrorMessage\"D\n" +
"\x11NodeCatalogReport\x12/\n" +
"\bservices\x18\x01 \x03(\v2\x13.sam.v1.ServiceInfoR\bservices\"-\n" +
@@ -3448,42 +3453,41 @@ const file_api_sam_proto_rawDesc = "" +
"\x05error\x18\x02 \x01(\tR\x05error\"Y\n" +
"\x13AgentRefreshRequest\x12\x19\n" +
"\bagent_id\x18\x01 \x01(\tR\aagentId\x12'\n" +
- "\x0fcredential_path\x18\x02 \x01(\tR\x0ecredentialPath\"e\n" +
+ "\x0fcredential_path\x18\x02 \x01(\tR\x0ecredentialPath\"\x83\x01\n" +
"\x14AgentRefreshResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" +
- "\x05error\x18\x02 \x01(\tR\x05error\x12\x1d\n" +
- "\n" +
- "expires_at\x18\x03 \x01(\x03R\texpiresAt\"/\n" +
+ "\x05error\x18\x02 \x01(\tR\x05error\x12;\n" +
+ "\vexpire_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
+ "expireTime\"/\n" +
"\x12AgentStatusRequest\x12\x19\n" +
- "\bagent_id\x18\x01 \x01(\tR\aagentId\"\xa8\x01\n" +
+ "\bagent_id\x18\x01 \x01(\tR\aagentId\"\xc6\x01\n" +
"\vAgentStatus\x12\x19\n" +
"\bagent_id\x18\x01 \x01(\tR\aagentId\x12\x1a\n" +
"\battached\x18\x02 \x01(\bR\battached\x12.\n" +
- "\aingress\x18\x03 \x03(\v2\x14.sam.v1.AgentIngressR\aingress\x122\n" +
- "\x15credential_expires_at\x18\x04 \x01(\x03R\x13credentialExpiresAt\"X\n" +
+ "\aingress\x18\x03 \x03(\v2\x14.sam.v1.AgentIngressR\aingress\x12P\n" +
+ "\x16credential_expire_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\x14credentialExpireTime\"X\n" +
"\x13AgentStatusResponse\x12+\n" +
"\x06agents\x18\x01 \x03(\v2\x13.sam.v1.AgentStatusR\x06agents\x12\x14\n" +
- "\x05error\x18\x02 \x01(\tR\x05error\"\x83\x02\n" +
+ "\x05error\x18\x02 \x01(\tR\x05error\"\xbd\x02\n" +
"\x18IdentityEvidenceResponse\x12\x17\n" +
"\apeer_id\x18\x01 \x01(\tR\x06peerId\x12\x18\n" +
- "\abiscuit\x18\x02 \x01(\fR\abiscuit\x12,\n" +
- "\x12biscuit_expires_at\x18\x03 \x01(\x03R\x10biscuitExpiresAt\x12*\n" +
+ "\abiscuit\x18\x02 \x01(\fR\abiscuit\x12J\n" +
+ "\x13biscuit_expire_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x11biscuitExpireTime\x12*\n" +
"\x11control_plane_url\x18\x04 \x01(\tR\x0fcontrolPlaneUrl\x12;\n" +
- "\x1atrusted_control_plane_keys\x18\x05 \x03(\fR\x17trustedControlPlaneKeys\x12\x1d\n" +
+ "\x1atrusted_control_plane_keys\x18\x05 \x03(\fR\x17trustedControlPlaneKeys\x129\n" +
"\n" +
- "checked_at\x18\x06 \x01(\x03R\tcheckedAt\"\xe7\x02\n" +
+ "check_time\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tcheckTime\"\xa0\x03\n" +
"\x14PeerEvidenceResponse\x12\x17\n" +
"\apeer_id\x18\x01 \x01(\tR\x06peerId\x12\x18\n" +
"\abiscuit\x18\x02 \x01(\fR\abiscuit\x12#\n" +
"\rverifying_key\x18\x03 \x01(\fR\fverifyingKey\x12\x14\n" +
"\x05roles\x18\x04 \x03(\tR\x05roles\x12@\n" +
- "\x06labels\x18\x05 \x03(\v2(.sam.v1.PeerEvidenceResponse.LabelsEntryR\x06labels\x12\x1e\n" +
- "\n" +
- "expiration\x18\x06 \x01(\x03R\n" +
- "expiration\x12%\n" +
- "\x0erevocation_ids\x18\a \x03(\tR\rrevocationIds\x12\x1d\n" +
+ "\x06labels\x18\x05 \x03(\v2(.sam.v1.PeerEvidenceResponse.LabelsEntryR\x06labels\x12;\n" +
+ "\vexpire_time\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
+ "expireTime\x12%\n" +
+ "\x0erevocation_ids\x18\a \x03(\tR\rrevocationIds\x129\n" +
"\n" +
- "checked_at\x18\b \x01(\x03R\tcheckedAt\x1a9\n" +
+ "check_time\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\tcheckTime\x1a9\n" +
"\vLabelsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xe2\x02\n" +
@@ -3588,35 +3592,48 @@ var file_api_sam_proto_goTypes = []any{
}
var file_api_sam_proto_depIdxs = []int32{
2, // 0: sam.v1.MeshEvent.type:type_name -> sam.v1.MeshEvent.Type
- 48, // 1: sam.v1.EnrollRequest.labels:type_name -> sam.v1.EnrollRequest.LabelsEntry
- 49, // 2: sam.v1.BootstrapEnrollRequest.labels:type_name -> sam.v1.BootstrapEnrollRequest.LabelsEntry
- 0, // 3: sam.v1.BootstrapEnrollResponse.status:type_name -> sam.v1.EnrollmentStatus
- 1, // 4: sam.v1.ServiceInfo.type:type_name -> sam.v1.ServiceType
- 50, // 5: sam.v1.CommandBackend.env:type_name -> sam.v1.CommandBackend.EnvEntry
- 10, // 6: sam.v1.RegisterServiceRequest.service:type_name -> sam.v1.ServiceInfo
- 11, // 7: sam.v1.RegisterServiceRequest.command:type_name -> sam.v1.CommandBackend
- 1, // 8: sam.v1.ServiceAnnounce.type:type_name -> sam.v1.ServiceType
- 51, // 9: sam.v1.ServiceAnnounce.labels:type_name -> sam.v1.ServiceAnnounce.LabelsEntry
- 18, // 10: sam.v1.PolicyConfig.roles:type_name -> sam.v1.PolicyRole
- 19, // 11: sam.v1.PolicyConfig.bindings:type_name -> sam.v1.PolicyBinding
- 10, // 12: sam.v1.NodeCatalogReport.services:type_name -> sam.v1.ServiceInfo
- 30, // 13: sam.v1.AgentEgress.secrets:type_name -> sam.v1.AgentSecret
- 1, // 14: sam.v1.AgentIngress.type:type_name -> sam.v1.ServiceType
- 31, // 15: sam.v1.AgentBundle.egress:type_name -> sam.v1.AgentEgress
- 32, // 16: sam.v1.AgentBundle.ingress:type_name -> sam.v1.AgentIngress
- 33, // 17: sam.v1.AgentAttachRequest.bundle:type_name -> sam.v1.AgentBundle
- 32, // 18: sam.v1.AgentStatus.ingress:type_name -> sam.v1.AgentIngress
- 41, // 19: sam.v1.AgentStatusResponse.agents:type_name -> sam.v1.AgentStatus
- 52, // 20: sam.v1.PeerEvidenceResponse.labels:type_name -> sam.v1.PeerEvidenceResponse.LabelsEntry
- 53, // 21: sam.v1.MemberCredential.expire_time:type_name -> google.protobuf.Timestamp
- 46, // 22: sam.v1.MemberCredential.trusted_keys:type_name -> sam.v1.TrustedSigningKey
- 47, // 23: sam.v1.MemberCredential.oidc_session:type_name -> sam.v1.OIDCSession
- 53, // 24: sam.v1.TrustedSigningKey.receive_time:type_name -> google.protobuf.Timestamp
- 25, // [25:25] is the sub-list for method output_type
- 25, // [25:25] is the sub-list for method input_type
- 25, // [25:25] is the sub-list for extension type_name
- 25, // [25:25] is the sub-list for extension extendee
- 0, // [0:25] is the sub-list for field type_name
+ 53, // 1: sam.v1.MeshEvent.event_time:type_name -> google.protobuf.Timestamp
+ 48, // 2: sam.v1.EnrollRequest.labels:type_name -> sam.v1.EnrollRequest.LabelsEntry
+ 53, // 3: sam.v1.EnrollResponse.expire_time:type_name -> google.protobuf.Timestamp
+ 49, // 4: sam.v1.BootstrapEnrollRequest.labels:type_name -> sam.v1.BootstrapEnrollRequest.LabelsEntry
+ 0, // 5: sam.v1.BootstrapEnrollResponse.status:type_name -> sam.v1.EnrollmentStatus
+ 53, // 6: sam.v1.BootstrapEnrollResponse.expire_time:type_name -> google.protobuf.Timestamp
+ 1, // 7: sam.v1.ServiceInfo.type:type_name -> sam.v1.ServiceType
+ 50, // 8: sam.v1.CommandBackend.env:type_name -> sam.v1.CommandBackend.EnvEntry
+ 10, // 9: sam.v1.RegisterServiceRequest.service:type_name -> sam.v1.ServiceInfo
+ 11, // 10: sam.v1.RegisterServiceRequest.command:type_name -> sam.v1.CommandBackend
+ 1, // 11: sam.v1.ServiceAnnounce.type:type_name -> sam.v1.ServiceType
+ 51, // 12: sam.v1.ServiceAnnounce.labels:type_name -> sam.v1.ServiceAnnounce.LabelsEntry
+ 53, // 13: sam.v1.ServiceAnnounce.announce_time:type_name -> google.protobuf.Timestamp
+ 53, // 14: sam.v1.RouterLeaseResponse.expire_time:type_name -> google.protobuf.Timestamp
+ 18, // 15: sam.v1.PolicyConfig.roles:type_name -> sam.v1.PolicyRole
+ 19, // 16: sam.v1.PolicyConfig.bindings:type_name -> sam.v1.PolicyBinding
+ 53, // 17: sam.v1.KeysResponse.sign_time:type_name -> google.protobuf.Timestamp
+ 53, // 18: sam.v1.TokenRefreshResponse.expire_time:type_name -> google.protobuf.Timestamp
+ 10, // 19: sam.v1.NodeCatalogReport.services:type_name -> sam.v1.ServiceInfo
+ 30, // 20: sam.v1.AgentEgress.secrets:type_name -> sam.v1.AgentSecret
+ 1, // 21: sam.v1.AgentIngress.type:type_name -> sam.v1.ServiceType
+ 31, // 22: sam.v1.AgentBundle.egress:type_name -> sam.v1.AgentEgress
+ 32, // 23: sam.v1.AgentBundle.ingress:type_name -> sam.v1.AgentIngress
+ 33, // 24: sam.v1.AgentAttachRequest.bundle:type_name -> sam.v1.AgentBundle
+ 53, // 25: sam.v1.AgentRefreshResponse.expire_time:type_name -> google.protobuf.Timestamp
+ 32, // 26: sam.v1.AgentStatus.ingress:type_name -> sam.v1.AgentIngress
+ 53, // 27: sam.v1.AgentStatus.credential_expire_time:type_name -> google.protobuf.Timestamp
+ 41, // 28: sam.v1.AgentStatusResponse.agents:type_name -> sam.v1.AgentStatus
+ 53, // 29: sam.v1.IdentityEvidenceResponse.biscuit_expire_time:type_name -> google.protobuf.Timestamp
+ 53, // 30: sam.v1.IdentityEvidenceResponse.check_time:type_name -> google.protobuf.Timestamp
+ 52, // 31: sam.v1.PeerEvidenceResponse.labels:type_name -> sam.v1.PeerEvidenceResponse.LabelsEntry
+ 53, // 32: sam.v1.PeerEvidenceResponse.expire_time:type_name -> google.protobuf.Timestamp
+ 53, // 33: sam.v1.PeerEvidenceResponse.check_time:type_name -> google.protobuf.Timestamp
+ 53, // 34: sam.v1.MemberCredential.expire_time:type_name -> google.protobuf.Timestamp
+ 46, // 35: sam.v1.MemberCredential.trusted_keys:type_name -> sam.v1.TrustedSigningKey
+ 47, // 36: sam.v1.MemberCredential.oidc_session:type_name -> sam.v1.OIDCSession
+ 53, // 37: sam.v1.TrustedSigningKey.receive_time:type_name -> google.protobuf.Timestamp
+ 38, // [38:38] is the sub-list for method output_type
+ 38, // [38:38] is the sub-list for method input_type
+ 38, // [38:38] is the sub-list for extension type_name
+ 38, // [38:38] is the sub-list for extension extendee
+ 0, // [0:38] is the sub-list for field type_name
}
func init() { file_api_sam_proto_init() }
diff --git a/api/sam.proto b/api/sam.proto
index 91e2fe0a..04f9eed7 100644
--- a/api/sam.proto
+++ b/api/sam.proto
@@ -47,7 +47,10 @@ message MeshEvent {
}
Type type = 1;
string peer_id = 2;
- int64 timestamp = 3;
+ // When the control plane recorded the event. Receivers ignore an event
+ // further than a few minutes from their clock and, for bans, one older
+ // than the last they applied for the peer.
+ google.protobuf.Timestamp event_time = 3;
bytes new_public_key = 4;
bytes signature = 5;
}
@@ -62,13 +65,15 @@ message EnrollRequest {
// enrollment flow's gates, minted as signed label() facts in the
// biscuit. Empty means no claims.
map<string, string> labels = 5;
- // Proof of possession of public_key's private half: timestamp is unix
- // milliseconds and challenge_signature signs the UTF-8 bytes of
- // "sam:register:<peer_id>:<timestamp>". Required, and peer_id must be
- // derived from public_key. The JWT proves who is asking; this proves
- // they hold the key they are asking to bind, so an identity cannot
- // register (and overwrite) another node's peer_id.
- int64 timestamp = 6;
+ // Proof of possession of public_key's private half: challenge_unix_ms is
+ // the caller's clock in unix milliseconds and challenge_signature signs
+ // the UTF-8 bytes of "sam:register:<peer_id>:<challenge_unix_ms>". It is
+ // an int64 because it is the number in the signed text, not an instant
+ // for display. Required, and peer_id must be derived from public_key.
+ // The JWT proves who is asking; this proves they hold the key they are
+ // asking to bind, so an identity cannot register (and overwrite) another
+ // node's peer_id.
+ int64 challenge_unix_ms = 6;
bytes challenge_signature = 7;
}
@@ -77,7 +82,7 @@ message EnrollResponse {
string error_message = 2;
bytes control_plane_public_key = 3;
repeated string router_addresses = 4;
- int64 expiration = 5;
+ google.protobuf.Timestamp expire_time = 5;
}
enum EnrollmentStatus {
@@ -95,13 +100,13 @@ message BootstrapEnrollRequest {
// Operator-declared labels; the admin approving the enrollment attests
// them (see EnrollRequest.labels).
map<string, string> labels = 5;
- // Proof of possession of public_key's private half: timestamp is unix
- // milliseconds and challenge_signature signs the UTF-8 bytes of
- // "sam:enroll:<peer_id>:<timestamp>". Required, and peer_id must be
- // derived from public_key: this is what entitles a repeated POST /enroll
- // to re-fetch an existing enrollment's biscuit, so a bootstrap token
- // alone must never satisfy it.
- int64 timestamp = 6;
+ // Proof of possession of public_key's private half: challenge_unix_ms is
+ // the caller's clock in unix milliseconds and challenge_signature signs
+ // the UTF-8 bytes of "sam:enroll:<peer_id>:<challenge_unix_ms>". Required,
+ // and peer_id must be derived from public_key: this is what entitles a
+ // repeated POST /enroll to re-fetch an existing enrollment's biscuit, so
+ // a bootstrap token alone must never satisfy it.
+ int64 challenge_unix_ms = 6;
bytes challenge_signature = 7;
}
@@ -118,7 +123,7 @@ message BootstrapEnrollResponse {
string error_message = 4;
bytes control_plane_public_key = 5; // Populated only if APPROVED
repeated string router_addresses = 6; // Populated only if APPROVED
- int64 expiration = 7; // Populated only if APPROVED
+ google.protobuf.Timestamp expire_time = 7; // Populated only if APPROVED
}
@@ -173,7 +178,7 @@ message ServiceAnnounce {
// Runtime load hints; zero values mean unknown.
uint32 active_requests = 6;
double latency_ewma_ms = 7;
- int64 timestamp = 8;
+ google.protobuf.Timestamp announce_time = 8;
}
message ControlPlaneInfoResponse {
@@ -196,19 +201,19 @@ message RouterLeaseRequest {
bytes biscuit = 3;
repeated string connected_peers = 4;
int32 dht_size = 5;
- // Proof of possession of the router's enrolled key: timestamp is unix
- // milliseconds and challenge_signature signs the UTF-8 bytes of
- // "sam:routers-lease:<peer_id>:<timestamp>" with the key the router
- // enrolled with. Required. The biscuit alone is not proof: routers hand
- // theirs to every peer they authenticate.
- int64 timestamp = 6;
+ // Proof of possession of the router's enrolled key: challenge_unix_ms is
+ // the caller's clock in unix milliseconds and challenge_signature signs
+ // the UTF-8 bytes of "sam:routers-lease:<peer_id>:<challenge_unix_ms>"
+ // with the key the router enrolled with. Required. The biscuit alone is
+ // not proof: routers hand theirs to every peer they authenticate.
+ int64 challenge_unix_ms = 6;
bytes challenge_signature = 7;
}
message RouterLeaseResponse {
bool success = 1;
string error = 2;
- int64 expires_at = 3;
+ google.protobuf.Timestamp expire_time = 3;
}
message PolicyRole {
@@ -262,9 +267,9 @@ message PolicyConfigUpdateResponse {
message KeysResponse {
repeated bytes public_keys = 1;
- // Unix milliseconds at which the set was signed; receivers reject responses
- // outside a short freshness window so a captured set cannot be replayed.
- int64 timestamp = 2;
+ // When the set was signed; receivers reject responses outside a short
+ // freshness window so a captured set cannot be replayed.
+ google.protobuf.Timestamp sign_time = 2;
// One ed25519 signature per entry of public_keys, by that key, over the
// deterministic encoding of this message with signatures cleared. A
// receiver trusting any key still valid on the control plane can verify
@@ -274,12 +279,13 @@ message KeysResponse {
message TokenRefreshRequest {
// Signature with the node key over the UTF-8 bytes of
- // "sam:refresh:<peer_id>:<timestamp>", where peer_id is the one bound in
- // the presented biscuit. Peer- and endpoint-bound so a captured signature
- // verifies nowhere else.
+ // "sam:refresh:<peer_id>:<challenge_unix_ms>", where peer_id is the one
+ // bound in the presented biscuit. Peer- and endpoint-bound so a captured
+ // signature verifies nowhere else.
bytes challenge_signature = 1;
- // Unix milliseconds. Must be within the control plane's freshness window.
- int64 timestamp = 2;
+ // The caller's clock in unix milliseconds, the number in the signed text.
+ // Must be within the control plane's freshness window.
+ int64 challenge_unix_ms = 2;
// The caller's peer ID. Optional: the control plane normally reads it
// from the verified biscuit. It is consulted only when the biscuit's
// signing key has been retired, so the biscuit cannot be verified: the
@@ -292,7 +298,7 @@ message TokenRefreshRequest {
message TokenRefreshResponse {
bytes biscuit_token = 1;
- int64 expires_at = 2;
+ google.protobuf.Timestamp expire_time = 2;
string error_message = 3;
}
@@ -412,7 +418,7 @@ message AgentRefreshRequest {
message AgentRefreshResponse {
bool success = 1;
string error = 2;
- int64 expires_at = 3;
+ google.protobuf.Timestamp expire_time = 3;
}
// AgentStatusRequest reports on one agent, or on all of them when agent_id is
@@ -425,7 +431,7 @@ message AgentStatus {
string agent_id = 1;
bool attached = 2;
repeated AgentIngress ingress = 3;
- int64 credential_expires_at = 4;
+ google.protobuf.Timestamp credential_expire_time = 4;
}
message AgentStatusResponse {
@@ -441,15 +447,15 @@ message AgentStatusResponse {
// GET /sam/identity and GET /sam/peer/{peer_id}/evidence. Only reachable
// over the filesystem-protected Unix socket or verified mTLS. A 200 asserts
// the node verified the biscuit, its PeerID binding, and revocation state at
-// checked_at; independent verifiers recompute from the raw biscuit and keys.
+// check_time; independent verifiers recompute from the raw biscuit and keys.
message IdentityEvidenceResponse {
string peer_id = 1;
bytes biscuit = 2;
- int64 biscuit_expires_at = 3;
+ google.protobuf.Timestamp biscuit_expire_time = 3;
string control_plane_url = 4;
repeated bytes trusted_control_plane_keys = 5; // Ed25519 SPKI DER
- int64 checked_at = 6;
+ google.protobuf.Timestamp check_time = 6;
}
message PeerEvidenceResponse {
@@ -458,9 +464,9 @@ message PeerEvidenceResponse {
bytes verifying_key = 3; // Ed25519 SPKI DER, member of the trusted set
repeated string roles = 4;
map<string, string> labels = 5;
- int64 expiration = 6;
+ google.protobuf.Timestamp expire_time = 6;
repeated string revocation_ids = 7; // hex
- int64 checked_at = 8;
+ google.protobuf.Timestamp check_time = 8;
}
// ============================================================================
diff --git a/api/trust.go b/api/trust.go
index ac72787f..f7884539 100644
--- a/api/trust.go
+++ b/api/trust.go
@@ -24,6 +24,7 @@ import (
"time"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// ErrInsecureControlPlaneURL marks a plaintext control-plane URL to a host
@@ -67,21 +68,21 @@ func isLoopbackHost(host string) bool {
const KeysResponseFreshness = 5 * time.Minute
// KeysResponsePayload is the bytes each signature in a KeysResponse covers:
-// the key set and the timestamp, deterministically encoded, signatures
+// the key set and the signing time, deterministically encoded, signatures
// cleared.
func KeysResponsePayload(resp *KeysResponse) ([]byte, error) {
- unsigned := &KeysResponse{PublicKeys: resp.PublicKeys, Timestamp: resp.Timestamp}
+ unsigned := &KeysResponse{PublicKeys: resp.PublicKeys, SignTime: resp.SignTime}
return proto.MarshalOptions{Deterministic: true}.Marshal(unsigned)
}
-// SignKeysResponse sets Timestamp and one signature per key pair, so a
+// SignKeysResponse sets SignTime and one signature per key pair, so a
// receiver that trusts any key still valid on the control plane can verify
// the set. Private keys must be in the same order as resp.PublicKeys.
func SignKeysResponse(resp *KeysResponse, privateKeys []ed25519.PrivateKey, now time.Time) error {
if len(privateKeys) != len(resp.PublicKeys) {
return fmt.Errorf("keys response has %d public keys but %d signing keys", len(resp.PublicKeys), len(privateKeys))
}
- resp.Timestamp = now.UnixMilli()
+ resp.SignTime = timestamppb.New(now)
payload, err := KeysResponsePayload(resp)
if err != nil {
return err
@@ -109,9 +110,12 @@ func VerifyKeysResponse(resp *KeysResponse, trusted []ed25519.PublicKey, now tim
if len(resp.Signatures) != len(resp.PublicKeys) {
return nil, fmt.Errorf("keys response carries %d signatures for %d keys", len(resp.Signatures), len(resp.PublicKeys))
}
- issued := time.UnixMilli(resp.Timestamp)
+ if resp.SignTime == nil {
+ return nil, errors.New("keys response carries no sign_time")
+ }
+ issued := resp.SignTime.AsTime()
if now.Sub(issued) > KeysResponseFreshness || issued.Sub(now) > KeysResponseFreshness {
- return nil, fmt.Errorf("keys response timestamp %s is outside the freshness window", issued.UTC().Format(time.RFC3339))
+ return nil, fmt.Errorf("keys response sign_time %s is outside the freshness window", issued.UTC().Format(time.RFC3339))
}
payload, err := KeysResponsePayload(resp)
if err != nil {
diff --git a/api/validation.go b/api/validation.go
index 01e6f117..27864bde 100644
--- a/api/validation.go
+++ b/api/validation.go
@@ -59,8 +59,8 @@ func ValidateServiceAnnounce(a *ServiceAnnounce) error {
return fmt.Errorf("invalid label %q", k)
}
}
- if a.GetTimestamp() <= 0 {
- return fmt.Errorf("missing timestamp")
+ if a.GetAnnounceTime() == nil {
+ return fmt.Errorf("missing announce_time")
}
return nil
}
diff --git a/internal/controlplane/approval_labels_test.go b/internal/controlplane/approval_labels_test.go
index 5e0c0459..0c18a6ff 100644
--- a/internal/controlplane/approval_labels_test.go
+++ b/internal/controlplane/approval_labels_test.go
@@ -107,7 +107,7 @@ func TestApprovalRefusesLabelsTheRoleDoesNotGrant(t *testing.T) {
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
Labels: labels,
- Timestamp: enrollTS,
+ ChallengeUnixMs: enrollTS,
ChallengeSignature: enrollSig,
})
if err != nil {
diff --git a/internal/controlplane/biscuit_ttl_test.go b/internal/controlplane/biscuit_ttl_test.go
index 96e3b5ac..8ac606d7 100644
--- a/internal/controlplane/biscuit_ttl_test.go
+++ b/internal/controlplane/biscuit_ttl_test.go
@@ -93,7 +93,7 @@ func registerNode(t *testing.T, cpURL, jwtToken string) (crypto.PrivKey, peer.ID
PeerId: peerID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
if err != nil {
@@ -174,7 +174,7 @@ func postRefresh(t *testing.T, cpURL string, priv crypto.PrivKey, currentBiscuit
t.Fatal(err)
}
reqData, err := proto.Marshal(&api.TokenRefreshRequest{
- Timestamp: timestamp,
+ ChallengeUnixMs: timestamp,
ChallengeSignature: sig,
PeerId: peerID,
})
@@ -249,7 +249,7 @@ func TestBiscuitExpiryIsCappedByItsVoucher(t *testing.T) {
cpPubKey := ed25519.PublicKey(resp.ControlPlanePublicKey)
assertNear(t, "biscuit expiration()", biscuitExpiration(t, resp.BiscuitToken, cpPubKey, srv.config.BiscuitTimeout), oidcExpiry)
- assertNear(t, "EnrollResponse.Expiration", time.Unix(resp.Expiration, 0), oidcExpiry)
+ assertNear(t, "EnrollResponse.expire_time", resp.GetExpireTime().AsTime(), oidcExpiry)
})
t.Run("register uses the configured TTL when it expires first", func(t *testing.T) {
@@ -260,7 +260,7 @@ func TestBiscuitExpiryIsCappedByItsVoucher(t *testing.T) {
cpPubKey := ed25519.PublicKey(resp.ControlPlanePublicKey)
assertNear(t, "biscuit expiration()", biscuitExpiration(t, resp.BiscuitToken, cpPubKey, srv.config.BiscuitTimeout), want)
- assertNear(t, "EnrollResponse.Expiration", time.Unix(resp.Expiration, 0), want)
+ assertNear(t, "EnrollResponse.expire_time", resp.GetExpireTime().AsTime(), want)
})
t.Run("refresh clamps to the end of the OIDC session", func(t *testing.T) {
@@ -281,7 +281,7 @@ func TestBiscuitExpiryIsCappedByItsVoucher(t *testing.T) {
refreshed := refreshNode(t, cpURL, priv, resp.BiscuitToken)
assertNear(t, "refreshed biscuit expiration()", biscuitExpiration(t, refreshed.BiscuitToken, cpPubKey, srv.config.BiscuitTimeout), sessionEnd)
- assertNear(t, "TokenRefreshResponse.ExpiresAt", time.Unix(refreshed.ExpiresAt, 0), sessionEnd)
+ assertNear(t, "TokenRefreshResponse.expire_time", refreshed.GetExpireTime().AsTime(), sessionEnd)
})
t.Run("refresh uses the configured TTL when the session never expires", func(t *testing.T) {
diff --git a/internal/controlplane/identity_lifecycle_test.go b/internal/controlplane/identity_lifecycle_test.go
index 6ecb1eec..fc31d03b 100644
--- a/internal/controlplane/identity_lifecycle_test.go
+++ b/internal/controlplane/identity_lifecycle_test.go
@@ -102,7 +102,7 @@ func (h *lifecycleHarness) register(sub string) (crypto.PrivKey, peer.ID) {
ts, sig := registerPoP(h.t, priv, id.String())
data, err := proto.Marshal(&api.EnrollRequest{
Jwt: h.mintToken(map[string]interface{}{"sub": sub}), PeerId: id.String(), PublicKey: pub,
- RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig,
+ RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig,
})
if err != nil {
h.t.Fatal(err)
@@ -133,7 +133,7 @@ func (h *lifecycleHarness) enroll(token string) (api.EnrollmentStatus, int, stri
ts, sig := enrollPoP(h.t, priv, id.String())
data, err := proto.Marshal(&api.BootstrapEnrollRequest{
BootstrapToken: token, PeerId: id.String(), PublicKey: pub, RequestedRole: api.RoleNode,
- Timestamp: ts, ChallengeSignature: sig,
+ ChallengeUnixMs: ts, ChallengeSignature: sig,
})
if err != nil {
h.t.Fatal(err)
@@ -510,7 +510,7 @@ func TestUnverifiedEmailAndIssuerCollision(t *testing.T) {
claims["sub"] = id.String() // distinct subjects, so only the email can bind
data, err := proto.Marshal(&api.EnrollRequest{
Jwt: h.mintToken(claims), PeerId: id.String(), PublicKey: pub,
- RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig,
+ RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig,
})
if err != nil {
t.Fatal(err)
diff --git a/internal/controlplane/label_grants_test.go b/internal/controlplane/label_grants_test.go
index 94741699..13d79ace 100644
--- a/internal/controlplane/label_grants_test.go
+++ b/internal/controlplane/label_grants_test.go
@@ -84,7 +84,7 @@ func TestRegisterRefusesLabelsTheRoleDoesNotGrant(t *testing.T) {
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
Labels: labels,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
if err != nil {
diff --git a/internal/controlplane/mesh.go b/internal/controlplane/mesh.go
index 152e9f1f..a964cd49 100644
--- a/internal/controlplane/mesh.go
+++ b/internal/controlplane/mesh.go
@@ -29,6 +29,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
"github.com/google/sam/api"
"github.com/google/sam/internal/storage"
@@ -272,7 +273,7 @@ func (p *P2PMeshAdapter) PublishEvent(ctx context.Context, eventType api.MeshEve
event := &api.MeshEvent{
Type: eventType,
PeerId: canonical,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
NewPublicKey: payload,
}
diff --git a/internal/controlplane/peer_id_canonicalization_test.go b/internal/controlplane/peer_id_canonicalization_test.go
index 8575fe9d..64e9e79f 100644
--- a/internal/controlplane/peer_id_canonicalization_test.go
+++ b/internal/controlplane/peer_id_canonicalization_test.go
@@ -147,7 +147,7 @@ func TestBannedNodeCannotRegisterUnderAnAlias(t *testing.T) {
PeerId: peerID,
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
if err != nil {
diff --git a/internal/controlplane/policies_admission_test.go b/internal/controlplane/policies_admission_test.go
index 9b146044..2b64678c 100644
--- a/internal/controlplane/policies_admission_test.go
+++ b/internal/controlplane/policies_admission_test.go
@@ -71,7 +71,7 @@ func TestPoliciesRequiresAnAdmissibleNode(t *testing.T) {
PeerId: nodePeer.String(),
PublicKey: nodePubKeyBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
reqData, err := proto.Marshal(enrollReq)
diff --git a/internal/controlplane/server.go b/internal/controlplane/server.go
index 60bf8f60..bbda0e60 100644
--- a/internal/controlplane/server.go
+++ b/internal/controlplane/server.go
@@ -49,6 +49,7 @@ import (
"golang.org/x/time/rate"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
var logger = golog.Logger("sam-control-plane")
@@ -555,7 +556,7 @@ func (s *Server) HandleRegister(w http.ResponseWriter, r *http.Request) {
http.Error(w, "peer_id is not derived from public_key", http.StatusBadRequest)
return
}
- if err := verifyFreshChallenge(enrolleeKey, api.RegisterChallenge(canonical, req.Timestamp), req.Timestamp, req.ChallengeSignature); err != nil {
+ if err := verifyFreshChallenge(enrolleeKey, api.RegisterChallenge(canonical, req.ChallengeUnixMs), req.ChallengeUnixMs, req.ChallengeSignature); err != nil {
logger.Warnw("Register challenge verification failed", "peer_id", canonical, "error", err)
http.Error(w, "Invalid registration challenge: "+err.Error(), http.StatusUnauthorized)
return
@@ -710,7 +711,7 @@ func (s *Server) HandleRegister(w http.ResponseWriter, r *http.Request) {
BiscuitToken: biscuitData,
ControlPlanePublicKey: pubKey,
RouterAddresses: routerAddrs, // routers nodes multiaddresses
- Expiration: biscuitExpiry.Unix(),
+ ExpireTime: timestamppb.New(biscuitExpiry),
}
respData, err := proto.Marshal(resp)
@@ -840,7 +841,7 @@ func (s *Server) HandleRefresh(w http.ResponseWriter, r *http.Request) {
return
}
- if err := verifyFreshChallenge(pubKey, api.RefreshChallenge(canonical, req.Timestamp), req.Timestamp, req.ChallengeSignature); err != nil {
+ if err := verifyFreshChallenge(pubKey, api.RefreshChallenge(canonical, req.ChallengeUnixMs), req.ChallengeUnixMs, req.ChallengeSignature); err != nil {
logger.Warnw("Refresh challenge verification failed", "peer_id", canonical, "error", err)
unauthorized("Challenge verification failed: " + err.Error())
return
@@ -953,7 +954,7 @@ func (s *Server) HandleRefresh(w http.ResponseWriter, r *http.Request) {
// Write response
resp := &api.TokenRefreshResponse{
BiscuitToken: biscuitBytes,
- ExpiresAt: biscuitExpiry.Unix(),
+ ExpireTime: timestamppb.New(biscuitExpiry),
}
respData, err := proto.Marshal(resp)
@@ -1097,7 +1098,7 @@ func (s *Server) HandleRouterLease(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
- if err := verifyFreshChallenge(routerKey, api.RouterLeaseChallenge(canonical, req.Timestamp), req.Timestamp, req.ChallengeSignature); err != nil {
+ if err := verifyFreshChallenge(routerKey, api.RouterLeaseChallenge(canonical, req.ChallengeUnixMs), req.ChallengeUnixMs, req.ChallengeSignature); err != nil {
logger.Warnw("Router lease challenge verification failed", "peer_id", canonical, "error", err)
http.Error(w, "Invalid lease challenge: "+err.Error(), http.StatusUnauthorized)
return
@@ -1136,8 +1137,8 @@ func (s *Server) HandleRouterLease(w http.ResponseWriter, r *http.Request) {
}
resp := &api.RouterLeaseResponse{
- Success: true,
- ExpiresAt: expiresAt.Unix(),
+ Success: true,
+ ExpireTime: timestamppb.New(expiresAt),
}
respData, err := proto.Marshal(resp)
@@ -1450,7 +1451,7 @@ func (s *Server) HandleEnroll(w http.ResponseWriter, r *http.Request) {
s.writeEnrollError(w, api.EnrollmentStatus_ENROLLMENT_STATUS_REJECTED, "peer_id is not derived from public_key")
return
}
- if err := verifyFreshChallenge(enrolleeKey, api.EnrollChallenge(canonical, req.Timestamp), req.Timestamp, req.ChallengeSignature); err != nil {
+ if err := verifyFreshChallenge(enrolleeKey, api.EnrollChallenge(canonical, req.ChallengeUnixMs), req.ChallengeUnixMs, req.ChallengeSignature); err != nil {
logger.Warnw("Enroll challenge verification failed", "peer_id", canonical, "error", err)
s.writeEnrollError(w, api.EnrollmentStatus_ENROLLMENT_STATUS_REJECTED, "Invalid enrollment challenge: "+err.Error())
return
@@ -2446,9 +2447,9 @@ func (s *Server) buildApprovedBootstrapEnrollResponse(ctx context.Context, biscu
routerAddrs = append(routerAddrs, r.Addresses...)
}
- expiration := time.Now().Add(s.config.BiscuitTTL).Unix()
+ expiration := time.Now().Add(s.config.BiscuitTTL)
if resolvedAt != nil {
- expiration = resolvedAt.Add(s.config.BiscuitTTL).Unix()
+ expiration = resolvedAt.Add(s.config.BiscuitTTL)
}
return &api.BootstrapEnrollResponse{
@@ -2456,7 +2457,7 @@ func (s *Server) buildApprovedBootstrapEnrollResponse(ctx context.Context, biscu
BiscuitToken: biscuitToken,
ControlPlanePublicKey: pubKey,
RouterAddresses: routerAddrs,
- Expiration: expiration,
+ ExpireTime: timestamppb.New(expiration),
}, nil
}
diff --git a/internal/controlplane/server_test.go b/internal/controlplane/server_test.go
index f66ab779..8c4633ae 100644
--- a/internal/controlplane/server_test.go
+++ b/internal/controlplane/server_test.go
@@ -332,7 +332,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: nodePeer.String(),
PublicKey: nodePubKeyBytes,
RequestedRole: api.RoleNode,
- Timestamp: nodeTS,
+ ChallengeUnixMs: nodeTS,
ChallengeSignature: nodeSig,
}
reqData, _ := proto.Marshal(enrollNodeReq)
@@ -379,7 +379,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: routerPeer.String(),
PublicKey: routerPubKeyBytes,
RequestedRole: api.RoleRouter,
- Timestamp: routerTS,
+ ChallengeUnixMs: routerTS,
ChallengeSignature: routerSig,
}
reqData, _ = proto.Marshal(enrollRouterReq)
@@ -409,7 +409,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: routerPeer.String(),
Addresses: routerAddresses,
Biscuit: enrollRouterResp.BiscuitToken,
- Timestamp: leaseTS,
+ ChallengeUnixMs: leaseTS,
ChallengeSignature: leaseSig,
}
reqData, _ = proto.Marshal(leaseReq)
@@ -460,7 +460,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: routerPeer.String(),
Addresses: []string{badAddr},
Biscuit: enrollRouterResp.BiscuitToken,
- Timestamp: badTS,
+ ChallengeUnixMs: badTS,
ChallengeSignature: badSig,
}
reqData, _ = proto.Marshal(badLease)
@@ -480,7 +480,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: nodePeer.String(),
Addresses: []string{"/ip4/127.0.0.1/tcp/6001/p2p/" + nodePeer.String()},
Biscuit: enrollNodeResp.BiscuitToken, // Node biscuit doesn't have router role
- Timestamp: rogueTS,
+ ChallengeUnixMs: rogueTS,
ChallengeSignature: rogueSig,
}
reqData, _ = proto.Marshal(rogueLeaseReq)
@@ -509,7 +509,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: routerPeer.String(),
Addresses: []string{"/ip4/203.0.113.66/tcp/4001/p2p/" + routerPeer.String()},
Biscuit: enrollRouterResp.BiscuitToken,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
}(),
@@ -523,7 +523,7 @@ func TestNodeAndRouterRegistrationFlow(t *testing.T) {
PeerId: routerPeer.String(),
Addresses: []string{},
Biscuit: enrollRouterResp.BiscuitToken,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
}(),
@@ -919,7 +919,7 @@ func TestEnrollmentWorkflow(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleRouter,
- Timestamp: enrollTS,
+ ChallengeUnixMs: enrollTS,
ChallengeSignature: enrollSig,
}
enrollReqData, _ := proto.Marshal(enrollReq)
@@ -1050,7 +1050,7 @@ func TestEnrollmentWorkflow(t *testing.T) {
PeerId: pID2.String(),
PublicKey: pubBytes2,
RequestedRole: api.RoleRouter,
- Timestamp: enrollTS2,
+ ChallengeUnixMs: enrollTS2,
ChallengeSignature: enrollSig2,
}
enrollReqData2, _ := proto.Marshal(enrollReq2)
@@ -1178,7 +1178,7 @@ func TestRegisterRequiresProofOfPossession(t *testing.T) {
ts, sig := registerPoP(t, victimPriv, victimID.String())
if status, body := post(&api.EnrollRequest{
Jwt: mintToken(map[string]interface{}{"sub": "victim"}), PeerId: victimID.String(), PublicKey: victimPub,
- RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig,
+ RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig,
}); status != http.StatusOK {
t.Fatalf("victim registration: got %d (%s), want 200", status, body)
}
@@ -1202,14 +1202,14 @@ func TestRegisterRequiresProofOfPossession(t *testing.T) {
"victim peer_id and public key, challenge signed by the attacker": {
req: func() *api.EnrollRequest {
ts, sig := registerPoP(t, attackerPriv, victimID.String())
- return &api.EnrollRequest{Jwt: attackerJWT, PeerId: victimID.String(), PublicKey: victimPub, RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig}
+ return &api.EnrollRequest{Jwt: attackerJWT, PeerId: victimID.String(), PublicKey: victimPub, RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig}
}(),
want: http.StatusUnauthorized,
},
"own key, challenge for another endpoint": {
req: func() *api.EnrollRequest {
ts, sig := enrollPoP(t, attackerPriv, attackerID.String())
- return &api.EnrollRequest{Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig}
+ return &api.EnrollRequest{Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig}
}(),
want: http.StatusUnauthorized,
},
@@ -1220,7 +1220,7 @@ func TestRegisterRequiresProofOfPossession(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- return &api.EnrollRequest{Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig}
+ return &api.EnrollRequest{Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub, RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig}
}(),
want: http.StatusUnauthorized,
},
@@ -1252,7 +1252,7 @@ func TestRegisterRequiresProofOfPossession(t *testing.T) {
ts, sig = registerPoP(t, attackerPriv, attackerID.String())
if status, body := post(&api.EnrollRequest{
Jwt: attackerJWT, PeerId: attackerID.String(), PublicKey: attackerPub,
- RequestedRole: api.RoleNode, Timestamp: ts, ChallengeSignature: sig,
+ RequestedRole: api.RoleNode, ChallengeUnixMs: ts, ChallengeSignature: sig,
}); status != http.StatusOK {
t.Fatalf("honest registration: got %d (%s), want 200", status, body)
}
@@ -1305,7 +1305,7 @@ func TestBootstrapEnrollmentRequiresProofOfPossession(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleRouter,
- Timestamp: enrollTS,
+ ChallengeUnixMs: enrollTS,
ChallengeSignature: enrollSig,
})
resp, err = client.Post(baseURL+"/enroll", "application/x-protobuf", bytes.NewReader(enrollData))
@@ -1390,7 +1390,7 @@ func TestBootstrapEnrollmentRequiresProofOfPossession(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleRouter,
- Timestamp: crossTS,
+ ChallengeUnixMs: crossTS,
ChallengeSignature: crossSig,
},
"peer_id not derived from public_key": {
@@ -1398,7 +1398,7 @@ func TestBootstrapEnrollmentRequiresProofOfPossession(t *testing.T) {
PeerId: pID.String(),
PublicKey: otherPubBytes,
RequestedRole: api.RoleRouter,
- Timestamp: crossTS,
+ ChallengeUnixMs: crossTS,
ChallengeSignature: crossSig,
},
"missing challenge": {
@@ -1425,7 +1425,7 @@ func TestBootstrapEnrollmentRequiresProofOfPossession(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleRouter,
- Timestamp: retryTS,
+ ChallengeUnixMs: retryTS,
ChallengeSignature: retrySig,
})
r := postEnroll("enrollee retry", retryData)
@@ -1455,7 +1455,7 @@ func TestBootstrapEnrollmentRequiresProofOfPossession(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleRouter,
- Timestamp: crossEndpointTS,
+ ChallengeUnixMs: crossEndpointTS,
ChallengeSignature: statusSig, // valid /enroll/status signature, wrong endpoint
})
if r := postEnroll("cross-endpoint replay", replayData); r.Status != api.EnrollmentStatus_ENROLLMENT_STATUS_REJECTED || len(r.BiscuitToken) != 0 {
@@ -1563,7 +1563,7 @@ func TestRouterLeaseRevocation(t *testing.T) {
PeerId: routerPeer.String(),
Addresses: []string{"/ip4/127.0.0.1/tcp/4001/p2p/" + routerPeer.String()},
Biscuit: routerBiscuit,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
resp, err := client.Post(baseURL+"/routers/lease", "application/x-protobuf", bytes.NewReader(leaseData))
@@ -1667,7 +1667,7 @@ func TestRouterLeaseUnderRotatedKey(t *testing.T) {
PeerId: routerPeer.String(),
Addresses: []string{"/ip4/127.0.0.1/tcp/4001/p2p/" + routerPeer.String()},
Biscuit: routerBiscuit,
- Timestamp: leaseTS,
+ ChallengeUnixMs: leaseTS,
ChallengeSignature: leaseSig,
})
if err != nil {
@@ -1750,7 +1750,7 @@ func signedRefreshRequest(t *testing.T, priv crypto.PrivKey, timestamp int64) []
}
data, err := proto.Marshal(&api.TokenRefreshRequest{
ChallengeSignature: sig,
- Timestamp: timestamp,
+ ChallengeUnixMs: timestamp,
})
if err != nil {
t.Fatalf("Marshal: %v", err)
@@ -1906,7 +1906,7 @@ func TestTokenRefreshAndRevocation(t *testing.T) {
PeerId: nodePeer.String(),
PublicKey: nodePubKeyBytes,
RequestedRole: api.RoleNode,
- Timestamp: nodeTS,
+ ChallengeUnixMs: nodeTS,
ChallengeSignature: nodeSig,
}
reqData, _ := proto.Marshal(enrollNodeReq)
@@ -1939,7 +1939,7 @@ func TestTokenRefreshAndRevocation(t *testing.T) {
refreshReq := &api.TokenRefreshRequest{
ChallengeSignature: challengeSig,
- Timestamp: timestamp,
+ ChallengeUnixMs: timestamp,
}
refreshData, _ := proto.Marshal(refreshReq)
@@ -2045,7 +2045,7 @@ func TestNodeProactiveTokenRefresh(t *testing.T) {
PeerId: nodePeer.String(),
PublicKey: nodePubKeyBytes,
RequestedRole: api.RoleNode,
- Timestamp: nodeTS,
+ ChallengeUnixMs: nodeTS,
ChallengeSignature: nodeSig,
}
reqData, _ := proto.Marshal(enrollNodeReq)
@@ -2088,7 +2088,7 @@ func TestNodeProactiveTokenRefresh(t *testing.T) {
if err := nStore.SaveIdentity(biscuitToken); err != nil {
t.Fatalf("failed to save initial identity: %v", err)
}
- if err := nStore.SaveIdentityExpiration(enrollNodeResp.Expiration); err != nil {
+ if err := nStore.SaveIdentityExpiration(enrollNodeResp.GetExpireTime().AsTime().Unix()); err != nil {
t.Fatalf("failed to save initial expiration: %v", err)
}
@@ -2123,8 +2123,8 @@ func TestNodeProactiveTokenRefresh(t *testing.T) {
if bytes.Equal(refreshedToken, biscuitToken) {
t.Error("biscuit token did not change after refresh")
}
- if refreshedExpiration <= enrollNodeResp.Expiration {
- t.Errorf("expected refreshed expiration %d to be after initial expiration %d", refreshedExpiration, enrollNodeResp.Expiration)
+ if refreshedExpiration <= enrollNodeResp.GetExpireTime().AsTime().Unix() {
+ t.Errorf("expected refreshed expiration %d to be after initial expiration %d", refreshedExpiration, enrollNodeResp.GetExpireTime().AsTime().Unix())
}
}
@@ -2500,7 +2500,7 @@ func TestAuthDenialPaths(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
return reqData
@@ -2651,7 +2651,7 @@ func TestOIDCSessionTTLIsConfigurable(t *testing.T) {
PeerId: nodePeer.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: regTS,
+ ChallengeUnixMs: regTS,
ChallengeSignature: regSig,
})
resp, err := client.Post(baseURL+"/register", "application/x-protobuf", bytes.NewReader(reqData))
@@ -2677,7 +2677,7 @@ func TestOIDCSessionTTLIsConfigurable(t *testing.T) {
if skew := nodeRecord.ExpiresAt.Sub(enrolledAt.Add(sessionTTL)); skew < -2*time.Second || skew > 2*time.Second {
t.Errorf("session ExpiresAt is %v, want ~%v", nodeRecord.ExpiresAt, enrolledAt.Add(sessionTTL))
}
- if reported := time.Unix(enrollResp.Expiration, 0); reported.After(nodeRecord.ExpiresAt.Add(2 * time.Second)) {
+ if reported := enrollResp.GetExpireTime().AsTime(); reported.After(nodeRecord.ExpiresAt.Add(2 * time.Second)) {
t.Errorf("biscuit expiration %v outlives the session %v", reported, nodeRecord.ExpiresAt)
}
@@ -2692,7 +2692,7 @@ func TestOIDCSessionTTLIsConfigurable(t *testing.T) {
}
refreshData, _ := proto.Marshal(&api.TokenRefreshRequest{
ChallengeSignature: challengeSig,
- Timestamp: timestamp,
+ ChallengeUnixMs: timestamp,
})
req, _ := http.NewRequest("POST", baseURL+"/refresh", bytes.NewReader(refreshData))
req.Header.Set("Authorization", "Bearer "+base64.StdEncoding.EncodeToString(enrollResp.BiscuitToken))
@@ -2746,7 +2746,7 @@ func TestBanSurvivesKeypairRegeneration(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
resp, err := client.Post(baseURL+"/register", "application/x-protobuf", bytes.NewReader(reqData))
@@ -2926,7 +2926,7 @@ func TestBootstrapTokenOwnerPropagatesToNode(t *testing.T) {
PeerId: pID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ownerTS,
+ ChallengeUnixMs: ownerTS,
ChallengeSignature: ownerSig,
})
resp, err = client.Post(baseURL+"/enroll", "application/x-protobuf", bytes.NewBuffer(enrollData))
@@ -3255,7 +3255,7 @@ func bootstrapEnroll(t *testing.T, baseURL, token string, priv crypto.PrivKey, p
PublicKey: pubBytes,
RequestedRole: role,
Labels: labels,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
if err != nil {
@@ -3820,7 +3820,7 @@ func TestAutonomousRecovery(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- reqData, err := proto.Marshal(&api.TokenRefreshRequest{Timestamp: ts, ChallengeSignature: sig, PeerId: f.pID.String()})
+ reqData, err := proto.Marshal(&api.TokenRefreshRequest{ChallengeUnixMs: ts, ChallengeSignature: sig, PeerId: f.pID.String()})
if err != nil {
t.Fatal(err)
}
diff --git a/internal/node/discovery/announcer.go b/internal/node/discovery/announcer.go
index 8eb427ce..c993001e 100644
--- a/internal/node/discovery/announcer.go
+++ b/internal/node/discovery/announcer.go
@@ -24,6 +24,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/peer"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// Discovery is the node-facing handle: it announces local services
@@ -135,7 +136,7 @@ func (d *Discovery) announceOnce(ctx context.Context, anns []Announcement) {
Labels: ann.Labels,
ActiveRequests: ann.Load.ActiveRequests,
LatencyEwmaMs: ann.Load.LatencyEWMAMs,
- Timestamp: time.Now().Unix(),
+ AnnounceTime: timestamppb.Now(),
}
if err := api.ValidateServiceAnnounce(msg); err != nil {
logger.Warnf("[Discovery] skipping invalid announcement for %q: %v", ann.Name, err)
diff --git a/internal/node/discovery/discovery_test.go b/internal/node/discovery/discovery_test.go
index 0cbd0df1..4307d29a 100644
--- a/internal/node/discovery/discovery_test.go
+++ b/internal/node/discovery/discovery_test.go
@@ -28,6 +28,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// newPair builds two connected in-memory hosts with gossipsub and Discovery.
@@ -181,11 +182,11 @@ func TestObserveRejectsForgedAndStale(t *testing.T) {
other := testPeerID(t)
valid := &api.ServiceAnnounce{
- PeerId: signer.String(),
- Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
- ServiceName: "llm",
- Keys: []string{"m1"},
- Timestamp: time.Now().Unix(),
+ PeerId: signer.String(),
+ Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
+ ServiceName: "llm",
+ Keys: []string{"m1"},
+ AnnounceTime: timestamppb.Now(),
}
tests := []struct {
@@ -198,12 +199,12 @@ func TestObserveRejectsForgedAndStale(t *testing.T) {
{"stale timestamp dropped", rawMessage(t, signer, &api.ServiceAnnounce{
PeerId: signer.String(), Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
ServiceName: "llm", Keys: []string{"m1"},
- Timestamp: time.Now().Add(-10 * time.Minute).Unix(),
+ AnnounceTime: timestamppb.New(time.Now().Add(-10 * time.Minute)),
}), 0},
{"future timestamp dropped", rawMessage(t, signer, &api.ServiceAnnounce{
PeerId: signer.String(), Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
ServiceName: "llm", Keys: []string{"m1"},
- Timestamp: time.Now().Add(10 * time.Minute).Unix(),
+ AnnounceTime: timestamppb.New(time.Now().Add(10 * time.Minute)),
}), 0},
{"invalid payload dropped", &pubsub.Message{
Message: &pubsub_pb.Message{From: []byte(signer), Data: []byte("junk")},
@@ -227,7 +228,7 @@ func TestProviderTableIsBounded(t *testing.T) {
d.observe(rawMessage(t, signer, &api.ServiceAnnounce{
PeerId: signer.String(), Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
ServiceName: "llm", Keys: []string{"m1"},
- Timestamp: time.Now().Unix(),
+ AnnounceTime: timestamppb.Now(),
}))
}
if got := len(d.providers); got != 2 {
@@ -244,7 +245,7 @@ func TestProviderTableCapsEntriesPerSigner(t *testing.T) {
d.observe(rawMessage(t, honest, &api.ServiceAnnounce{
PeerId: honest.String(), Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
ServiceName: "llm", Keys: []string{"m1"},
- Timestamp: time.Now().Unix(),
+ AnnounceTime: timestamppb.Now(),
}))
loud := testPeerID(t)
@@ -252,7 +253,7 @@ func TestProviderTableCapsEntriesPerSigner(t *testing.T) {
d.observe(rawMessage(t, loud, &api.ServiceAnnounce{
PeerId: loud.String(), Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
ServiceName: "svc-" + string(rune('a'+i%26)) + string(rune('a'+i/26)), Keys: []string{"m1"},
- Timestamp: time.Now().Unix(),
+ AnnounceTime: timestamppb.Now(),
}))
}
@@ -273,8 +274,8 @@ func TestPeerLabels(t *testing.T) {
d.observe(rawMessage(t, signer, &api.ServiceAnnounce{
PeerId: signer.String(), Type: api.ServiceType_SERVICE_TYPE_MCP,
ServiceName: "reviewer", Keys: []string{"review_pr"},
- Labels: map[string]string{"region": "eu"},
- Timestamp: time.Now().Unix(),
+ Labels: map[string]string{"region": "eu"},
+ AnnounceTime: timestamppb.Now(),
}))
if got := d.PeerLabels(signer.String()); got["region"] != "eu" {
@@ -289,7 +290,7 @@ func TestValidateServiceAnnounceCaps(t *testing.T) {
base := func() *api.ServiceAnnounce {
return &api.ServiceAnnounce{
PeerId: "12D3KooWTest", Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
- ServiceName: "llm", Keys: []string{"m1"}, Timestamp: 1,
+ ServiceName: "llm", Keys: []string{"m1"}, AnnounceTime: timestamppb.Now(),
}
}
tooMany := make([]string, api.MaxAnnounceKeys+1)
@@ -307,7 +308,7 @@ func TestValidateServiceAnnounceCaps(t *testing.T) {
{"too many keys", func(a *api.ServiceAnnounce) { a.Keys = tooMany }, true},
{"empty peer", func(a *api.ServiceAnnounce) { a.PeerId = "" }, true},
{"unspecified type", func(a *api.ServiceAnnounce) { a.Type = api.ServiceType_SERVICE_TYPE_UNSPECIFIED }, true},
- {"no timestamp", func(a *api.ServiceAnnounce) { a.Timestamp = 0 }, true},
+ {"no announce time", func(a *api.ServiceAnnounce) { a.AnnounceTime = nil }, true},
{"oversized label", func(a *api.ServiceAnnounce) {
a.Labels = map[string]string{"k": string(make([]byte, api.MaxAnnounceStringLen+1))}
}, true},
@@ -347,8 +348,8 @@ func TestObserveKeysOnTheCanonicalPeerID(t *testing.T) {
d.observe(rawMessage(t, signer, &api.ServiceAnnounce{
PeerId: spelling, Type: api.ServiceType_SERVICE_TYPE_INFERENCE,
ServiceName: "llm", Keys: []string{"m1"},
- Labels: map[string]string{"region": "eu"},
- Timestamp: time.Now().Unix(),
+ Labels: map[string]string{"region": "eu"},
+ AnnounceTime: timestamppb.Now(),
}))
}
diff --git a/internal/node/discovery/view.go b/internal/node/discovery/view.go
index c5f18cc5..88bddf72 100644
--- a/internal/node/discovery/view.go
+++ b/internal/node/discovery/view.go
@@ -120,7 +120,7 @@ func (d *Discovery) observe(msg *pubsub.Message) {
logger.Warnf("[Discovery] dropping announce with peer_id %q not matching signer %s", ann.GetPeerId(), msg.GetFrom())
return
}
- ts := time.Unix(ann.GetTimestamp(), 0)
+ ts := ann.GetAnnounceTime().AsTime()
if age := time.Since(ts); age > maxAnnounceSkew || age < -maxAnnounceSkew {
logger.Debugf("[Discovery] dropping stale/future announce from %s (age %v)", msg.GetFrom(), time.Since(ts))
return
diff --git a/internal/node/enroll.go b/internal/node/enroll.go
index 6f93e3e5..0b7e88cc 100644
--- a/internal/node/enroll.go
+++ b/internal/node/enroll.go
@@ -35,10 +35,21 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
var logger = golog.Logger("sam-node")
+// expireUnix is the unix seconds of a control plane's expire_time for the
+// store; an unset one is 0, an already-expired credential, so the node
+// refreshes at once instead of trusting a token of unknown lifetime.
+func expireUnix(t *timestamppb.Timestamp) int64 {
+ if t == nil {
+ return 0
+ }
+ return t.AsTime().Unix()
+}
+
// GetOrGenerateKey retrieves a persistent private key or creates one if it's the first run
func GetOrGenerateKey(s *Store) crypto.PrivKey {
kb, _ := s.LoadKey()
@@ -107,7 +118,7 @@ func (n *SamNode) enrollHTTP(ctx context.Context, controlPlaneURL, jwt string, p
PublicKey: pubBytes,
RequestedRole: n.config.RequiredRole,
Labels: n.labels(),
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
data, err := proto.Marshal(req)
@@ -204,7 +215,7 @@ func (n *SamNode) processEnrollResponse(resp *http.Response) (*api.EnrollRespons
}
n.SetIdentityCache(enrollResp.BiscuitToken)
- if err := n.Store.SaveIdentityExpiration(enrollResp.Expiration); err != nil {
+ if err := n.Store.SaveIdentityExpiration(expireUnix(enrollResp.ExpireTime)); err != nil {
return nil, fmt.Errorf("failed to save identity expiration: %v", err)
}
if err := n.Store.SaveMeshConfig(enrollResp.ControlPlanePublicKey, enrollResp.RouterAddresses); err != nil {
@@ -259,7 +270,7 @@ func (n *SamNode) EnrollBootstrap(ctx context.Context, controlPlaneURL string, b
PublicKey: pubBytes,
RequestedRole: n.config.RequiredRole,
Labels: n.labels(),
- Timestamp: enrollTS,
+ ChallengeUnixMs: enrollTS,
ChallengeSignature: enrollSig,
}
data, err := proto.Marshal(req)
@@ -397,7 +408,7 @@ func (n *SamNode) EnrollBootstrap(ctx context.Context, controlPlaneURL string, b
}
n.SetIdentityCache(enrollResp.BiscuitToken)
- if err := n.Store.SaveIdentityExpiration(enrollResp.Expiration); err != nil {
+ if err := n.Store.SaveIdentityExpiration(expireUnix(enrollResp.ExpireTime)); err != nil {
return fmt.Errorf("failed to save identity expiration: %v", err)
}
diff --git a/internal/node/enroll_test.go b/internal/node/enroll_test.go
index b5eae163..fbddab9f 100644
--- a/internal/node/enroll_test.go
+++ b/internal/node/enroll_test.go
@@ -37,6 +37,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-msgio"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// Enrollment hands out a biscuit signed by the current key and then learns
@@ -61,7 +62,7 @@ func TestEnrollmentPinsIdentityKeySet(t *testing.T) {
mux.HandleFunc("/register", protoHandler(t, &api.EnrollResponse{
BiscuitToken: credential,
ControlPlanePublicKey: currentPub,
- Expiration: time.Now().Add(24 * time.Hour).Unix(),
+ ExpireTime: timestamppb.New(time.Now().Add(24 * time.Hour)),
}))
mux.HandleFunc("/keys", keysHandler(t, []ed25519.PublicKey{gracePub, currentPub}, []ed25519.PrivateKey{gracePriv, currentPriv}))
mux.HandleFunc("/info", protoHandler(t, &api.ControlPlaneInfoResponse{}))
@@ -249,7 +250,7 @@ func TestStartRecoversStaleIdentityViaRefreshToken(t *testing.T) {
BiscuitToken: mint(cpPriv, req.PeerId),
ControlPlanePublicKey: cpPub,
RouterAddresses: []string{routerAddr},
- Expiration: time.Now().Add(24 * time.Hour).Unix(),
+ ExpireTime: timestamppb.New(time.Now().Add(24 * time.Hour)),
}
data, _ := proto.Marshal(resp)
w.Header().Set("Content-Type", "application/x-protobuf")
@@ -400,14 +401,14 @@ func TestStartRecoversStaleIdentityViaAutonomousRefresh(t *testing.T) {
http.Error(w, "Invalid biscuit", http.StatusUnauthorized)
return
}
- ok, err := privKey.GetPublic().Verify(api.RefreshChallenge(req.PeerId, req.Timestamp), req.ChallengeSignature)
+ ok, err := privKey.GetPublic().Verify(api.RefreshChallenge(req.PeerId, req.ChallengeUnixMs), req.ChallengeSignature)
if err != nil || !ok {
http.Error(w, "Challenge verification failed", http.StatusUnauthorized)
return
}
data, err := proto.Marshal(&api.TokenRefreshResponse{
BiscuitToken: mint(cpPriv, req.PeerId),
- ExpiresAt: time.Now().Add(24 * time.Hour).Unix(),
+ ExpireTime: timestamppb.New(time.Now().Add(24 * time.Hour)),
})
if err != nil {
t.Errorf("marshal TokenRefreshResponse: %v", err)
@@ -558,7 +559,7 @@ func TestEnroll_InvalidControlPlanePublicKeySize(t *testing.T) {
}
resp := &api.EnrollResponse{
BiscuitToken: []byte("mock-token"),
- Expiration: time.Now().Add(1 * time.Hour).Unix(),
+ ExpireTime: timestamppb.New(time.Now().Add(1 * time.Hour)),
ControlPlanePublicKey: invalidKey,
RouterAddresses: []string{"/ip4/127.0.0.1/tcp/4001"},
}
@@ -644,7 +645,7 @@ func TestEnrollTrustsRouterSignedByGraceKey(t *testing.T) {
BiscuitToken: mintRoleBiscuit(t, currentPriv, peerID, api.RoleNode),
ControlPlanePublicKey: currentPub,
RouterAddresses: []string{routerAddr},
- Expiration: time.Now().Add(24 * time.Hour).Unix(),
+ ExpireTime: timestamppb.New(time.Now().Add(24 * time.Hour)),
})(w, r)
})
mux.HandleFunc("/keys", keysHandler(t, []ed25519.PublicKey{retiredPub, currentPub}, []ed25519.PrivateKey{retiredPriv, currentPriv}))
diff --git a/internal/node/gossip_hardening_test.go b/internal/node/gossip_hardening_test.go
index 7b5c7886..fccf90b0 100644
--- a/internal/node/gossip_hardening_test.go
+++ b/internal/node/gossip_hardening_test.go
@@ -33,13 +33,14 @@ import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// signedMeshEvent returns a BANNED event for target signed by cpPriv, as the
// control plane would publish it.
func signedMeshEvent(t *testing.T, cpPriv ed25519.PrivateKey, target peer.ID, at time.Time) []byte {
t.Helper()
- event := &api.MeshEvent{Type: api.MeshEvent_BANNED, PeerId: target.String(), Timestamp: at.UnixMilli()}
+ event := &api.MeshEvent{Type: api.MeshEvent_BANNED, PeerId: target.String(), EventTime: timestamppb.New(at)}
unsigned, err := proto.MarshalOptions{Deterministic: true}.Marshal(event)
if err != nil {
t.Fatal(err)
diff --git a/internal/node/identity_evidence.go b/internal/node/identity_evidence.go
index f9a40fda..9a435c85 100644
--- a/internal/node/identity_evidence.go
+++ b/internal/node/identity_evidence.go
@@ -31,6 +31,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
type trustedKeySnapshot struct {
@@ -248,10 +249,10 @@ func (n *SamNode) buildIdentityEvidence(checkedAt time.Time) (*api.IdentityEvide
return &api.IdentityEvidenceResponse{
PeerId: n.Host.ID().String(),
Biscuit: append([]byte(nil), biscuitBytes...),
- BiscuitExpiresAt: claims.Expiration.Unix(),
+ BiscuitExpireTime: timestamppb.New(claims.Expiration),
ControlPlaneUrl: controlPlaneURL,
TrustedControlPlaneKeys: keyEvidence,
- CheckedAt: checkedAt.Unix(),
+ CheckTime: timestamppb.New(checkedAt),
}, nil
}
@@ -289,9 +290,9 @@ func (n *SamNode) buildPeerEvidence(requested peer.ID, observation peerBiscuitOb
VerifyingKey: append([]byte(nil), selected.SPKIDER...),
Roles: append([]string(nil), claims.Roles...),
Labels: claims.Labels,
- Expiration: claims.Expiration.Unix(),
+ ExpireTime: timestamppb.New(claims.Expiration),
RevocationIds: revocationIDs,
- CheckedAt: checkedAt.Unix(),
+ CheckTime: timestamppb.New(checkedAt),
}, nil
}
diff --git a/internal/node/identity_evidence_test.go b/internal/node/identity_evidence_test.go
index 21e691f3..d499364c 100644
--- a/internal/node/identity_evidence_test.go
+++ b/internal/node/identity_evidence_test.go
@@ -124,8 +124,8 @@ func TestIdentityEvidenceReturnsVerifiableClosedResponse(t *testing.T) {
if response.PeerId != node.Host.ID().String() || len(response.Biscuit) == 0 {
t.Fatalf("unexpected identity response: peer=%q biscuit=%d", response.PeerId, len(response.Biscuit))
}
- if response.BiscuitExpiresAt != expiresAt.Unix() || len(response.TrustedControlPlaneKeys) != 1 {
- t.Fatalf("unexpected expiry or key set: expiry=%d keys=%d", response.BiscuitExpiresAt, len(response.TrustedControlPlaneKeys))
+ if response.GetBiscuitExpireTime().AsTime().Unix() != expiresAt.Unix() || len(response.TrustedControlPlaneKeys) != 1 {
+ t.Fatalf("unexpected expiry or key set: expiry=%v keys=%d", response.GetBiscuitExpireTime().AsTime(), len(response.TrustedControlPlaneKeys))
}
parsedKey, err := x509.ParsePKIXPublicKey(response.TrustedControlPlaneKeys[0])
if err != nil {
@@ -135,8 +135,8 @@ func TestIdentityEvidenceReturnsVerifiableClosedResponse(t *testing.T) {
if !ok || !publicKey.Equal(node.trustedKeys[0].Key) {
t.Fatalf("trusted control-plane key is not the enrolled key")
}
- if response.CheckedAt <= 0 || response.CheckedAt > response.BiscuitExpiresAt {
- t.Fatalf("invalid checked/expiry timestamps: checked=%d expiry=%d", response.CheckedAt, response.BiscuitExpiresAt)
+ if response.CheckTime == nil || response.CheckTime.AsTime().After(response.GetBiscuitExpireTime().AsTime()) {
+ t.Fatalf("invalid check/expiry times: check=%v expiry=%v", response.GetCheckTime().AsTime(), response.GetBiscuitExpireTime().AsTime())
}
}
@@ -173,8 +173,8 @@ func TestBuildPeerEvidenceBindsRequestedConnectionAndBiscuitPeers(t *testing.T)
if response.Labels["region"] != "us-east-1" || len(response.RevocationIds) == 0 {
t.Fatalf("missing attestation or revocation evidence: %+v", response)
}
- if response.Expiration != expiresAt.Unix() || response.CheckedAt <= 0 || response.CheckedAt > response.Expiration {
- t.Fatalf("invalid checked/expiry timestamps: checked=%d expiry=%d", response.CheckedAt, response.Expiration)
+ if response.GetExpireTime().AsTime().Unix() != expiresAt.Unix() || response.CheckTime == nil || response.CheckTime.AsTime().After(response.GetExpireTime().AsTime()) {
+ t.Fatalf("invalid check/expiry times: check=%v expiry=%v", response.GetCheckTime().AsTime(), response.GetExpireTime().AsTime())
}
parsedKey, err := x509.ParsePKIXPublicKey(response.VerifyingKey)
if err != nil {
diff --git a/internal/node/middleware_test.go b/internal/node/middleware_test.go
index 5c23f2ba..b6fecee5 100644
--- a/internal/node/middleware_test.go
+++ b/internal/node/middleware_test.go
@@ -41,6 +41,7 @@ import (
"github.com/libp2p/go-msgio"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
type mockConn struct {
@@ -812,7 +813,7 @@ func TestVerifyEvent(t *testing.T) {
event := &api.MeshEvent{
Type: api.MeshEvent_BANNED,
PeerId: "attacker-peer",
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
}
// Sign it
diff --git a/internal/node/node.go b/internal/node/node.go
index e45dce19..af908022 100644
--- a/internal/node/node.go
+++ b/internal/node/node.go
@@ -1150,7 +1150,7 @@ func (n *SamNode) RefreshEnrollment(ctx context.Context) error {
// server-side); it is cross-checked against the biscuit otherwise.
req := &api.TokenRefreshRequest{
ChallengeSignature: sig,
- Timestamp: timestamp,
+ ChallengeUnixMs: timestamp,
PeerId: peerID.String(),
}
reqData, err := proto.Marshal(req)
@@ -1229,7 +1229,7 @@ func (n *SamNode) RefreshEnrollment(ctx context.Context) error {
return fmt.Errorf("failed to save refreshed identity: %w", err)
}
n.SetIdentityCache(refreshResp.BiscuitToken)
- if err := n.Store.SaveIdentityExpiration(refreshResp.ExpiresAt); err != nil {
+ if err := n.Store.SaveIdentityExpiration(expireUnix(refreshResp.ExpireTime)); err != nil {
return fmt.Errorf("failed to save refreshed expiration: %w", err)
}
n.recordIdentityKeySet()
@@ -1376,22 +1376,23 @@ func (n *SamNode) handleBannedEvent(event *api.MeshEvent) {
}
canonicalID := p.String()
+ eventMs := event.GetEventTime().AsTime().UnixMilli()
n.mu.Lock()
if n.peerLastEventTime == nil {
n.peerLastEventTime = make(map[string]int64)
}
- if event.Timestamp < n.peerLastEventTime[canonicalID] {
- logger.Warnf("[Mesh Event] Dropping out-of-order BANNED event for peer %s (event timestamp: %d, last processed: %d)", canonicalID, event.Timestamp, n.peerLastEventTime[canonicalID])
+ if eventMs < n.peerLastEventTime[canonicalID] {
+ logger.Warnf("[Mesh Event] Dropping out-of-order BANNED event for peer %s (event time: %d, last processed: %d)", canonicalID, eventMs, n.peerLastEventTime[canonicalID])
n.mu.Unlock()
return
}
- n.peerLastEventTime[canonicalID] = event.Timestamp
+ n.peerLastEventTime[canonicalID] = eventMs
n.mu.Unlock()
logger.Infow("[Mesh Event] peer banned", "event", meshEventBanned, "peer", canonicalID)
// Not written to disk: a restarted node picks the ban back up from the
// control plane's ban set in /info, which is also how an unban reaches it.
- n.banPeer(p, event.Timestamp)
+ n.banPeer(p, eventMs)
}
func containsTrustedKey(keys []TrustedKey, key ed25519.PublicKey) bool {
@@ -1527,9 +1528,13 @@ func (n *SamNode) validateMeshEvent(_ context.Context, from peer.ID, msg *pubsub
logger.Warnw("[Mesh Event] potential spoofing attempt: invalid event signature", "event", meshEventSpoofingAttempt, "peer", from.String())
return pubsub.ValidationReject
}
- eventTime := time.UnixMilli(event.Timestamp)
+ if event.EventTime == nil {
+ logger.Warnw("[Mesh Event] dropping event without event_time", "event", meshEventStaleEvent, "peer", from.String())
+ return pubsub.ValidationReject
+ }
+ eventTime := event.EventTime.AsTime()
if time.Since(eventTime) > FreshnessThreshold || time.Until(eventTime) > FreshnessThreshold {
- logger.Warnw("[Mesh Event] dropping stale or future event", "event", meshEventStaleEvent, "peer", from.String(), "timestamp", event.Timestamp)
+ logger.Warnw("[Mesh Event] dropping stale or future event", "event", meshEventStaleEvent, "peer", from.String(), "event_time", eventTime.UTC().Format(time.RFC3339))
return pubsub.ValidationIgnore
}
return pubsub.ValidationAccept
diff --git a/internal/node/node_test.go b/internal/node/node_test.go
index a22bcaef..2a77c93d 100644
--- a/internal/node/node_test.go
+++ b/internal/node/node_test.go
@@ -39,6 +39,7 @@ import (
"github.com/libp2p/go-msgio"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func TestAnnounceFilter(t *testing.T) {
@@ -134,7 +135,7 @@ func TestHandleBannedEvent(t *testing.T) {
node.handleBannedEvent(&api.MeshEvent{
Type: api.MeshEvent_BANNED,
PeerId: spelling,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
})
if !node.revokedPeers.Contains(banned.String()) {
@@ -172,7 +173,7 @@ func TestBannedPeerCanonicalisation(t *testing.T) {
node.handleBannedEvent(&api.MeshEvent{
Type: api.MeshEvent_BANNED,
PeerId: cidv1ID,
- Timestamp: ts,
+ EventTime: timestamppb.New(time.UnixMilli(ts)),
})
if !node.revokedPeers.Contains(canonicalID) {
@@ -194,7 +195,7 @@ func TestHandleKeyRotationEvent(t *testing.T) {
event := &api.MeshEvent{
Type: api.MeshEvent_KEY_ROTATION,
NewPublicKey: pub,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
}
node.handleKeyRotationEvent(event)
@@ -224,13 +225,13 @@ func TestKeyRotationEventSurvivesRestart(t *testing.T) {
node.handleKeyRotationEvent(&api.MeshEvent{
Type: api.MeshEvent_KEY_ROTATION,
NewPublicKey: rotatedKey,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
})
// Duplicate event must not grow the persisted set
node.handleKeyRotationEvent(&api.MeshEvent{
Type: api.MeshEvent_KEY_ROTATION,
NewPublicKey: rotatedKey,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
})
// "Restart": a fresh node built from the same store must trust the rotated key
diff --git a/internal/node/refresh_test.go b/internal/node/refresh_test.go
index 38d61e5f..abc9086f 100644
--- a/internal/node/refresh_test.go
+++ b/internal/node/refresh_test.go
@@ -33,6 +33,7 @@ import (
"github.com/google/sam/api"
"github.com/libp2p/go-libp2p/core/peer"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// refreshHarness is a node with a stored identity and a mock control plane
@@ -113,7 +114,7 @@ func newRefreshHarness(t *testing.T, refresh http.HandlerFunc) *refreshHarness {
func writeRefreshResponse(t *testing.T, w http.ResponseWriter, token []byte) {
t.Helper()
- data, err := proto.Marshal(&api.TokenRefreshResponse{BiscuitToken: token, ExpiresAt: time.Now().Add(24 * time.Hour).Unix()})
+ data, err := proto.Marshal(&api.TokenRefreshResponse{BiscuitToken: token, ExpireTime: timestamppb.New(time.Now().Add(24 * time.Hour))})
if err != nil {
t.Fatal(err)
}
diff --git a/internal/node/relay_acl_test.go b/internal/node/relay_acl_test.go
index 94d86574..2f78cbac 100644
--- a/internal/node/relay_acl_test.go
+++ b/internal/node/relay_acl_test.go
@@ -22,6 +22,7 @@ import (
lru "github.com/hashicorp/golang-lru/v2"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func TestNodeRelayACL_AllowConnect(t *testing.T) {
@@ -125,7 +126,7 @@ func TestBannedPeerLosesRelayRights(t *testing.T) {
node.handleBannedEvent(&api.MeshEvent{
Type: api.MeshEvent_BANNED,
PeerId: peerID.String(),
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
})
if acl.AllowReserve(peerID, addr) {
diff --git a/internal/router/relay_acl_test.go b/internal/router/relay_acl_test.go
index ac6bc2c4..e6b8b4a3 100644
--- a/internal/router/relay_acl_test.go
+++ b/internal/router/relay_acl_test.go
@@ -28,6 +28,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func newTestPeerID(t *testing.T) peer.ID {
@@ -89,7 +90,7 @@ func TestRouterValidateMeshEvent(t *testing.T) {
from, target := newTestPeerID(t), newTestPeerID(t)
signed := func(key ed25519.PrivateKey, at time.Time) []byte {
- event := &api.MeshEvent{Type: api.MeshEvent_BANNED, PeerId: target.String(), Timestamp: at.UnixMilli()}
+ event := &api.MeshEvent{Type: api.MeshEvent_BANNED, PeerId: target.String(), EventTime: timestamppb.New(at)}
unsigned, err := proto.MarshalOptions{Deterministic: true}.Marshal(event)
if err != nil {
t.Fatal(err)
diff --git a/internal/router/router.go b/internal/router/router.go
index 87d35778..425b4a90 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -62,6 +62,7 @@ import (
"github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
var logger = golog.Logger("sam-router")
@@ -122,10 +123,16 @@ type credential struct {
issuedUnder []ed25519.PublicKey
}
-func newCredential(biscuit []byte, expiresAt int64, issuedUnder []ed25519.PublicKey) credential {
+// newCredential builds the router's credential; an unset expire_time is an
+// expired credential, so a control plane that sent none forces a refresh.
+func newCredential(biscuit []byte, expireTime *timestamppb.Timestamp, issuedUnder []ed25519.PublicKey) credential {
+ var expiration time.Time
+ if expireTime != nil {
+ expiration = expireTime.AsTime()
+ }
return credential{
biscuit: biscuit,
- expiration: time.Unix(expiresAt, 0),
+ expiration: expiration,
issuedUnder: append([]ed25519.PublicKey(nil), issuedUnder...),
}
}
@@ -479,7 +486,7 @@ func (r *Router) enroll(peerID peer.ID) error {
PeerId: peerID.String(),
PublicKey: pubBytes,
RequestedRole: r.config.RequiredRole,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
data, err := proto.Marshal(req)
@@ -510,7 +517,7 @@ func (r *Router) enroll(peerID peer.ID) error {
}
r.keysMu.Lock()
- r.credential = newCredential(enrollResp.BiscuitToken, enrollResp.Expiration, nil)
+ r.credential = newCredential(enrollResp.BiscuitToken, enrollResp.ExpireTime, nil)
r.trustedPublicKeys = []ed25519.PublicKey{enrollResp.ControlPlanePublicKey}
r.keysMu.Unlock()
@@ -539,7 +546,7 @@ func (r *Router) enrollBootstrap(peerID peer.ID) error {
PeerId: peerID.String(),
PublicKey: pubBytes,
RequestedRole: r.config.RequiredRole,
- Timestamp: enrollTS,
+ ChallengeUnixMs: enrollTS,
ChallengeSignature: enrollSig,
}
data, err := proto.Marshal(req)
@@ -654,7 +661,7 @@ func (r *Router) enrollBootstrap(peerID peer.ID) error {
}
r.keysMu.Lock()
- r.credential = newCredential(enrollResp.BiscuitToken, enrollResp.Expiration, nil)
+ r.credential = newCredential(enrollResp.BiscuitToken, enrollResp.ExpireTime, nil)
r.trustedPublicKeys = []ed25519.PublicKey{enrollResp.ControlPlanePublicKey}
r.keysMu.Unlock()
@@ -809,7 +816,11 @@ func (r *Router) validateMeshEvent(_ context.Context, from peer.ID, msg *pubsub.
logger.Warnf("[Router Event] Potential spoofing attempt: invalid signature on event from %s", from)
return pubsub.ValidationReject
}
- eventTime := time.UnixMilli(event.Timestamp)
+ if event.EventTime == nil {
+ logger.Warnf("[Router Event] Dropping event without event_time from %s", from)
+ return pubsub.ValidationReject
+ }
+ eventTime := event.EventTime.AsTime()
if time.Since(eventTime) > meshEventFreshness || time.Until(eventTime) > meshEventFreshness {
logger.Warnf("[Router Event] Dropping stale or future event from %s", from)
return pubsub.ValidationIgnore
@@ -955,7 +966,7 @@ func (r *Router) renewLease() {
Biscuit: biscuit,
ConnectedPeers: connectedPeers,
DhtSize: dhtSize,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
data, _ := proto.Marshal(req)
@@ -1004,7 +1015,7 @@ func (r *Router) renewLease() {
logger.Errorf("Lease renewal failed: %s", leaseResp.Error)
leaseRenewalsTotal.WithLabelValues(leaseRejected).Inc()
} else {
- logger.Debugf("Lease renewed successfully. Expires at: %s", time.Unix(leaseResp.ExpiresAt, 0))
+ logger.Debugf("Lease renewed successfully. Expires at: %s", leaseResp.GetExpireTime().AsTime().Format(time.RFC3339))
leaseRenewalsTotal.WithLabelValues(leaseOK).Inc()
}
return
@@ -1397,7 +1408,7 @@ func (r *Router) RefreshEnrollment(ctx context.Context) error {
// opt-in server-side); it is cross-checked against the biscuit otherwise.
req := &api.TokenRefreshRequest{
ChallengeSignature: sig,
- Timestamp: timestamp,
+ ChallengeUnixMs: timestamp,
PeerId: peerID.String(),
}
reqData, err := proto.Marshal(req)
@@ -1462,7 +1473,7 @@ func (r *Router) RefreshEnrollment(ctx context.Context) error {
// Update local biscuit token and expiration under lock
r.keysMu.Lock()
- r.credential = newCredential(refreshResp.BiscuitToken, refreshResp.ExpiresAt, r.trustedPublicKeys)
+ r.credential = newCredential(refreshResp.BiscuitToken, refreshResp.ExpireTime, r.trustedPublicKeys)
r.keysMu.Unlock()
logger.Infof("Router biscuit token refreshed successfully.")
diff --git a/internal/router/router_test.go b/internal/router/router_test.go
index e817c825..1a870c0d 100644
--- a/internal/router/router_test.go
+++ b/internal/router/router_test.go
@@ -45,6 +45,7 @@ import (
"github.com/libp2p/go-msgio"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func startCustomMockOIDC(t *testing.T) (string, func(claims map[string]interface{}) string) {
@@ -244,7 +245,7 @@ func TestRouterIntegration(t *testing.T) {
PeerId: nodePeerID.String(),
PublicKey: nodePubKeyBytes,
RequestedRole: api.RoleNode,
- Timestamp: regTS,
+ ChallengeUnixMs: regTS,
ChallengeSignature: regSig,
}
reqData, _ := proto.Marshal(enrollNodeReq)
@@ -693,7 +694,7 @@ func TestRouterGossipSubBannedEvent(t *testing.T) {
event := &api.MeshEvent{
Type: api.MeshEvent_BANNED,
PeerId: bannedPeerIDStr,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
}
eventData, err := proto.MarshalOptions{Deterministic: true}.Marshal(event)
if err != nil {
diff --git a/internal/router/trust_test.go b/internal/router/trust_test.go
index d4eab4fd..e7f33ce4 100644
--- a/internal/router/trust_test.go
+++ b/internal/router/trust_test.go
@@ -34,6 +34,7 @@ import (
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
// A router pointed at a plaintext control plane on another host has no way
@@ -125,7 +126,7 @@ func TestSyncKeysRequiresTrustedSignature(t *testing.T) {
})
t.Run("empty set preserves trusted keys", func(t *testing.T) {
- body = marshal(&api.KeysResponse{Timestamp: time.Now().UnixMilli()})
+ body = marshal(&api.KeysResponse{SignTime: timestamppb.Now()})
router := newRouter()
if err := router.syncKeys(); err == nil {
t.Fatal("an empty /keys answer must not be adopted")
@@ -259,7 +260,7 @@ func TestSyncKeysRefreshesOnRotation(t *testing.T) {
http.Error(w, "temporarily unavailable", http.StatusServiceUnavailable)
return
}
- response = &api.TokenRefreshResponse{BiscuitToken: fresh, ExpiresAt: time.Now().Add(24 * time.Hour).Unix()}
+ response = &api.TokenRefreshResponse{BiscuitToken: fresh, ExpireTime: timestamppb.New(time.Now().Add(24 * time.Hour))}
default:
t.Errorf("unexpected request to %s", request.URL.Path)
http.NotFound(w, request)
@@ -346,7 +347,7 @@ func TestRouterConcurrentRefreshesAreSerialized(t *testing.T) {
return
}
lastIssued = mintRouterBiscuit(t, cpPriv, peerID, api.RoleRouter)
- body, err := proto.Marshal(&api.TokenRefreshResponse{BiscuitToken: lastIssued, ExpiresAt: time.Now().Add(time.Hour).Unix()})
+ body, err := proto.Marshal(&api.TokenRefreshResponse{BiscuitToken: lastIssued, ExpireTime: timestamppb.New(time.Now().Add(time.Hour))})
if err != nil {
t.Error(err)
return
@@ -441,7 +442,7 @@ func TestRouterRefreshEnrollmentHardening(t *testing.T) {
}
tokenResponse := func(token []byte) func(http.ResponseWriter) {
return func(w http.ResponseWriter) {
- data, err := proto.Marshal(&api.TokenRefreshResponse{BiscuitToken: token, ExpiresAt: time.Now().Add(time.Hour).Unix()})
+ data, err := proto.Marshal(&api.TokenRefreshResponse{BiscuitToken: token, ExpireTime: timestamppb.New(time.Now().Add(time.Hour))})
if err != nil {
t.Fatal(err)
}
diff --git a/sdk/README.md b/sdk/README.md
index 6e89f18c..b3d1cf7f 100644
--- a/sdk/README.md
+++ b/sdk/README.md
@@ -162,9 +162,13 @@ messages in `api/sam.proto`. Bodies are capped at 1 MiB on both sides.
| `GET /policies` | header `Authorization: Bearer <base64 biscuit>` | `PolicyConfigGetResponse{datalog_rules}` | none; the biscuit must belong to an admitted node |
| `POST /nodes/catalog` | `NodeCatalogReport`, header `Authorization: Bearer <base64 biscuit>` | `204` | none; the reporting peer is read from the biscuit |
-- `<ts>` is unix milliseconds and must be within 5 minutes of the control
- plane's clock (`challengeMaxAge`). Challenges are defined in
- `api/network.go`.
+- `<ts>` is the request's `challenge_unix_ms`, unix milliseconds, and must
+ be within 5 minutes of the control plane's clock (`challengeMaxAge`).
+ Challenges are defined in `api/network.go`. It is the one instant on the
+ wire that is an `int64`: it is the number in the signed text. Every other
+ instant (`expire_time`, `sign_time`, `event_time`, `announce_time`) is a
+ `google.protobuf.Timestamp`, and a receiver rejects a message whose
+ required instant is unset.
- A bootstrap enrollment answers `PENDING` until an operator approves it,
unless the control plane runs with auto-approval. The client polls
`/enroll/status` at the returned `poll_interval_seconds`.
@@ -172,9 +176,9 @@ messages in `api/sam.proto`. Bodies are capped at 1 MiB on both sides.
peer. A client must persist the new biscuit before using it; losing it
means re-enrolling.
- `/keys` signatures cover the deterministic protobuf encoding of
- `KeysResponse{public_keys, timestamp}` with `signatures` cleared, one
+ `KeysResponse{public_keys, sign_time}` with `signatures` cleared, one
signature per key by that key. The receiver accepts the set when a key it
- already trusts (the enrollment key) vouches for it and the timestamp is
+ already trusts (the enrollment key) vouches for it and `sign_time` is
within 5 minutes (`api/trust.go`). Rotation keeps several keys valid, so
a member must trust the whole set to verify peers enrolled under a
retiring key.
diff --git a/sdk/js/src/controlplane.test.ts b/sdk/js/src/controlplane.test.ts
index 6a2efb5f..a368ae55 100644
--- a/sdk/js/src/controlplane.test.ts
+++ b/sdk/js/src/controlplane.test.ts
@@ -18,6 +18,7 @@
// tests/integration/sdk_enroll_test.go.
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
+import { timestampFromMs } from "@bufbuild/protobuf/wkt";
import assert from "node:assert/strict";
import { test } from "node:test";
import { enrollChallenge, enrollStatusChallenge, refreshChallenge, registerChallenge } from "./challenges.ts";
@@ -66,7 +67,7 @@ function fakeFetch(routes: Record<string, Handler>): typeof fetch {
/** Signs a KeysResponse the way api.SignKeysResponse does. */
function signedKeys(signers: Identity[], timestamp = Date.now()): KeysResponse {
- const unsigned = create(KeysResponseSchema, { publicKeys: signers.map((s) => s.publicKeyRaw), timestamp: BigInt(timestamp) });
+ const unsigned = create(KeysResponseSchema, { publicKeys: signers.map((s) => s.publicKeyRaw), signTime: timestampFromMs(timestamp) });
const payload = toBinary(KeysResponseSchema, unsigned);
return create(KeysResponseSchema, { ...unsigned, signatures: signers.map((s) => s.sign(payload)) });
}
@@ -98,8 +99,8 @@ test("enrollBootstrap sends a bound proof of possession and polls until approved
assert.deepEqual(r.publicKey, id.libp2pPublicKey);
assert.equal(r.requestedRole, ROLE_NODE);
assert.deepEqual(r.labels, { region: "eu" });
- assert.ok(Math.abs(Number(r.timestamp) - Date.now()) < 5000);
- assert.ok(verifyEd25519(id.publicKeyRaw, enrollChallenge(r.peerId, Number(r.timestamp)), r.challengeSignature));
+ assert.ok(Math.abs(Number(r.challengeUnixMs) - Date.now()) < 5000);
+ assert.ok(verifyEd25519(id.publicKeyRaw, enrollChallenge(r.peerId, Number(r.challengeUnixMs)), r.challengeSignature));
seen.push("enroll");
return proto(toBinary(BootstrapEnrollResponseSchema, create(BootstrapEnrollResponseSchema, { status: EnrollmentStatus.PENDING, pollIntervalSeconds: 30 })));
},
@@ -121,7 +122,7 @@ test("enrollBootstrap sends a bound proof of possession and polls until approved
biscuitToken: biscuit,
controlPlanePublicKey: cpKey.publicKeyRaw,
routerAddresses: routerAddrs,
- expiration: 1_800_000_000n,
+ expireTime: timestampFromMs(1_800_000_000_000),
})
: create(BootstrapEnrollResponseSchema, { status: EnrollmentStatus.PENDING, pollIntervalSeconds: 30 }),
),
@@ -187,8 +188,8 @@ test("register carries the JWT and the register-bound challenge", async () => {
assert.equal(r.jwt, "eyJ.fake.jwt");
assert.equal(r.peerId, id.peerId);
assert.equal(r.requestedRole, "sam:role:custom");
- assert.ok(verifyEd25519(id.publicKeyRaw, registerChallenge(r.peerId, Number(r.timestamp)), r.challengeSignature));
- return proto(toBinary(EnrollResponseSchema, create(EnrollResponseSchema, { biscuitToken: biscuit, controlPlanePublicKey: cpKey.publicKeyRaw, expiration: 7n })));
+ assert.ok(verifyEd25519(id.publicKeyRaw, registerChallenge(r.peerId, Number(r.challengeUnixMs)), r.challengeSignature));
+ return proto(toBinary(EnrollResponseSchema, create(EnrollResponseSchema, { biscuitToken: biscuit, controlPlanePublicKey: cpKey.publicKeyRaw, expireTime: timestampFromMs(7_000) })));
},
}),
});
@@ -213,8 +214,8 @@ test("refresh presents the biscuit as a bearer and signs the refresh challenge",
assert.equal(req.headers.get("authorization"), `Bearer ${Buffer.from(biscuit).toString("base64")}`);
const r = fromBinary(TokenRefreshRequestSchema, body);
assert.equal(r.peerId, id.peerId);
- assert.ok(verifyEd25519(id.publicKeyRaw, refreshChallenge(id.peerId, Number(r.timestamp)), r.challengeSignature));
- return proto(toBinary(TokenRefreshResponseSchema, create(TokenRefreshResponseSchema, { biscuitToken: fresh, expiresAt: 99n })));
+ assert.ok(verifyEd25519(id.publicKeyRaw, refreshChallenge(id.peerId, Number(r.challengeUnixMs)), r.challengeSignature));
+ return proto(toBinary(TokenRefreshResponseSchema, create(TokenRefreshResponseSchema, { biscuitToken: fresh, expireTime: timestampFromMs(99_000) })));
},
}),
});
@@ -244,7 +245,7 @@ test("verifyKeysResponse accepts a set vouched for by a trusted key and nothing
const forged = create(KeysResponseSchema, { ...resp, publicKeys: [Identity.generate().publicKeyRaw, retiring.publicKeyRaw] });
assert.throws(() => verifyKeysResponse(forged, [retiring.publicKeyRaw]), /not signed by any trusted/);
- const unsigned = create(KeysResponseSchema, { publicKeys: resp.publicKeys, timestamp: resp.timestamp });
+ const unsigned = create(KeysResponseSchema, { publicKeys: resp.publicKeys, signTime: resp.signTime });
assert.throws(() => verifyKeysResponse(unsigned, [cpKey.publicKeyRaw]), /carries 0 signatures for 2 keys/);
});
diff --git a/sdk/js/src/controlplane.ts b/sdk/js/src/controlplane.ts
index a624b5f6..cc7c90ce 100644
--- a/sdk/js/src/controlplane.ts
+++ b/sdk/js/src/controlplane.ts
@@ -16,6 +16,7 @@
// (api/sam.proto). The operator plane (/admin/*, JSON) is out of scope.
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
+import { timestampMs, type Timestamp } from "@bufbuild/protobuf/wkt";
import { enrollChallenge, enrollStatusChallenge, refreshChallenge, registerChallenge } from "./challenges.ts";
import {
BootstrapEnrollRequestSchema,
@@ -171,13 +172,16 @@ export function verifyKeysResponse(resp: KeysResponse, trusted: Uint8Array[], no
if (resp.signatures.length !== resp.publicKeys.length) {
throw new Error(`keys response carries ${resp.signatures.length} signatures for ${resp.publicKeys.length} keys`);
}
- const issued = Number(resp.timestamp);
+ if (resp.signTime === undefined) {
+ throw new Error("keys response carries no sign_time");
+ }
+ const issued = timestampMs(resp.signTime);
if (Math.abs(nowMs - issued) > KEYS_RESPONSE_FRESHNESS_MS) {
- throw new Error(`keys response timestamp ${new Date(issued).toISOString()} is outside the freshness window`);
+ throw new Error(`keys response sign_time ${new Date(issued).toISOString()} is outside the freshness window`);
}
- // Each signature covers the set and the timestamp, deterministically
+ // Each signature covers the set and the signing time, deterministically
// encoded with the signatures cleared.
- const payload = toBinary(KeysResponseSchema, create(KeysResponseSchema, { publicKeys: resp.publicKeys, timestamp: resp.timestamp }));
+ const payload = toBinary(KeysResponseSchema, create(KeysResponseSchema, { publicKeys: resp.publicKeys, signTime: resp.signTime }));
const keys: Uint8Array[] = [];
let verified = false;
resp.publicKeys.forEach((pub, i) => {
@@ -261,7 +265,7 @@ export class ControlPlaneClient {
publicKey: identity.libp2pPublicKey,
requestedRole: role,
labels: params.labels ?? {},
- timestamp: BigInt(ts),
+ challengeUnixMs: BigInt(ts),
challengeSignature: identity.sign(enrollChallenge(identity.peerId, ts)),
});
let resp = fromBinary(BootstrapEnrollResponseSchema, await this.#request("POST", "/enroll", toBinary(BootstrapEnrollRequestSchema, req)));
@@ -294,7 +298,7 @@ export class ControlPlaneClient {
publicKey: identity.libp2pPublicKey,
requestedRole: params.role ?? ROLE_NODE,
labels: params.labels ?? {},
- timestamp: BigInt(ts),
+ challengeUnixMs: BigInt(ts),
challengeSignature: identity.sign(registerChallenge(identity.peerId, ts)),
});
const resp = fromBinary(EnrollResponseSchema, await this.#request("POST", "/register", toBinary(EnrollRequestSchema, req)));
@@ -303,10 +307,9 @@ export class ControlPlaneClient {
}
return checkedEnrollment({
biscuit: resp.biscuitToken,
- expiration: Number(resp.expiration),
controlPlanePublicKey: resp.controlPlanePublicKey,
routerAddresses: resp.routerAddresses,
- });
+ }, resp.expireTime);
}
/**
@@ -317,7 +320,7 @@ export class ControlPlaneClient {
const { identity } = params;
const ts = Date.now();
const req = create(TokenRefreshRequestSchema, {
- timestamp: BigInt(ts),
+ challengeUnixMs: BigInt(ts),
challengeSignature: identity.sign(refreshChallenge(identity.peerId, ts)),
peerId: identity.peerId,
});
@@ -331,7 +334,7 @@ export class ControlPlaneClient {
if (resp.biscuitToken.length === 0) {
throw new Error("refresh returned an empty biscuit");
}
- return { biscuit: resp.biscuitToken, expiration: Number(resp.expiresAt) };
+ return { biscuit: resp.biscuitToken, expiration: expirationSeconds(resp.expireTime, "refresh") };
}
/**
@@ -397,10 +400,9 @@ function enrollmentFromBootstrapResponse(resp: BootstrapEnrollResponse): Enrollm
case EnrollmentStatus.APPROVED:
return checkedEnrollment({
biscuit: resp.biscuitToken,
- expiration: Number(resp.expiration),
controlPlanePublicKey: resp.controlPlanePublicKey,
routerAddresses: resp.routerAddresses,
- });
+ }, resp.expireTime);
case EnrollmentStatus.REJECTED:
throw new EnrollmentRejectedError(`enrollment rejected: ${resp.errorMessage || "no reason given"}`);
default:
@@ -408,12 +410,20 @@ function enrollmentFromBootstrapResponse(resp: BootstrapEnrollResponse): Enrollm
}
}
-function checkedEnrollment(e: Enrollment): Enrollment {
+function checkedEnrollment(e: Omit<Enrollment, "expiration">, expireTime: Timestamp | undefined): Enrollment {
if (e.biscuit.length === 0) {
throw new Error("received empty biscuit token");
}
if (e.controlPlanePublicKey.length !== ED25519_PUBLIC_KEY_SIZE) {
throw new Error(`received invalid control plane public key size: ${e.controlPlanePublicKey.length} bytes (expected ${ED25519_PUBLIC_KEY_SIZE})`);
}
- return e;
+ return { ...e, expiration: expirationSeconds(expireTime, "enrollment") };
+}
+
+/** A biscuit of unknown lifetime cannot be kept fresh; the control plane must say when it expires. */
+function expirationSeconds(expireTime: Timestamp | undefined, what: string): number {
+ if (expireTime === undefined) {
+ throw new Error(`${what} response carries no expire_time`);
+ }
+ return Math.floor(timestampMs(expireTime) / 1000);
}
diff --git a/sdk/js/src/gen/sam_pb.ts b/sdk/js/src/gen/sam_pb.ts
index 17bbd358..94d899a9 100644
--- a/sdk/js/src/gen/sam_pb.ts
+++ b/sdk/js/src/gen/sam_pb.ts
@@ -26,7 +26,7 @@ import type { Message } from "@bufbuild/protobuf";
* Describes the file sam.proto.
*/
export const file_sam: GenFile = /*@__PURE__*/
- fileDesc("CglzYW0ucHJvdG8SBnNhbS52MSJDCglBdXR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
/**
* @generated from message sam.v1.AuthFrame
@@ -108,9 +108,13 @@ export type MeshEvent = Message<"sam.v1.MeshEvent"> & {
peerId: string;
/**
- * @generated from field: int64 timestamp = 3;
+ * When the control plane recorded the event. Receivers ignore an event
+ * further than a few minutes from their clock and, for bans, one older
+ * than the last they applied for the peer.
+ *
+ * @generated from field: google.protobuf.Timestamp event_time = 3;
*/
- timestamp: bigint;
+ eventTime?: Timestamp | undefined;
/**
* @generated from field: bytes new_public_key = 4;
@@ -191,16 +195,18 @@ export type EnrollRequest = Message<"sam.v1.EnrollRequest"> & {
labels: { [key: string]: string };
/**
- * Proof of possession of public_key's private half: timestamp is unix
- * milliseconds and challenge_signature signs the UTF-8 bytes of
- * "sam:register:<peer_id>:<timestamp>". Required, and peer_id must be
- * derived from public_key. The JWT proves who is asking; this proves
- * they hold the key they are asking to bind, so an identity cannot
- * register (and overwrite) another node's peer_id.
+ * Proof of possession of public_key's private half: challenge_unix_ms is
+ * the caller's clock in unix milliseconds and challenge_signature signs
+ * the UTF-8 bytes of "sam:register:<peer_id>:<challenge_unix_ms>". It is
+ * an int64 because it is the number in the signed text, not an instant
+ * for display. Required, and peer_id must be derived from public_key.
+ * The JWT proves who is asking; this proves they hold the key they are
+ * asking to bind, so an identity cannot register (and overwrite) another
+ * node's peer_id.
*
- * @generated from field: int64 timestamp = 6;
+ * @generated from field: int64 challenge_unix_ms = 6;
*/
- timestamp: bigint;
+ challengeUnixMs: bigint;
/**
* @generated from field: bytes challenge_signature = 7;
@@ -240,9 +246,9 @@ export type EnrollResponse = Message<"sam.v1.EnrollResponse"> & {
routerAddresses: string[];
/**
- * @generated from field: int64 expiration = 5;
+ * @generated from field: google.protobuf.Timestamp expire_time = 5;
*/
- expiration: bigint;
+ expireTime?: Timestamp | undefined;
};
/**
@@ -285,16 +291,16 @@ export type BootstrapEnrollRequest = Message<"sam.v1.BootstrapEnrollRequest"> &
labels: { [key: string]: string };
/**
- * Proof of possession of public_key's private half: timestamp is unix
- * milliseconds and challenge_signature signs the UTF-8 bytes of
- * "sam:enroll:<peer_id>:<timestamp>". Required, and peer_id must be
- * derived from public_key: this is what entitles a repeated POST /enroll
- * to re-fetch an existing enrollment's biscuit, so a bootstrap token
- * alone must never satisfy it.
+ * Proof of possession of public_key's private half: challenge_unix_ms is
+ * the caller's clock in unix milliseconds and challenge_signature signs
+ * the UTF-8 bytes of "sam:enroll:<peer_id>:<challenge_unix_ms>". Required,
+ * and peer_id must be derived from public_key: this is what entitles a
+ * repeated POST /enroll to re-fetch an existing enrollment's biscuit, so
+ * a bootstrap token alone must never satisfy it.
*
- * @generated from field: int64 timestamp = 6;
+ * @generated from field: int64 challenge_unix_ms = 6;
*/
- timestamp: bigint;
+ challengeUnixMs: bigint;
/**
* @generated from field: bytes challenge_signature = 7;
@@ -361,9 +367,9 @@ export type BootstrapEnrollResponse = Message<"sam.v1.BootstrapEnrollResponse">
/**
* Populated only if APPROVED
*
- * @generated from field: int64 expiration = 7;
+ * @generated from field: google.protobuf.Timestamp expire_time = 7;
*/
- expiration: bigint;
+ expireTime?: Timestamp | undefined;
};
/**
@@ -541,9 +547,9 @@ export type ServiceAnnounce = Message<"sam.v1.ServiceAnnounce"> & {
latencyEwmaMs: number;
/**
- * @generated from field: int64 timestamp = 8;
+ * @generated from field: google.protobuf.Timestamp announce_time = 8;
*/
- timestamp: bigint;
+ announceTime?: Timestamp | undefined;
};
/**
@@ -627,15 +633,15 @@ export type RouterLeaseRequest = Message<"sam.v1.RouterLeaseRequest"> & {
dhtSize: number;
/**
- * Proof of possession of the router's enrolled key: timestamp is unix
- * milliseconds and challenge_signature signs the UTF-8 bytes of
- * "sam:routers-lease:<peer_id>:<timestamp>" with the key the router
- * enrolled with. Required. The biscuit alone is not proof: routers hand
- * theirs to every peer they authenticate.
+ * Proof of possession of the router's enrolled key: challenge_unix_ms is
+ * the caller's clock in unix milliseconds and challenge_signature signs
+ * the UTF-8 bytes of "sam:routers-lease:<peer_id>:<challenge_unix_ms>"
+ * with the key the router enrolled with. Required. The biscuit alone is
+ * not proof: routers hand theirs to every peer they authenticate.
*
- * @generated from field: int64 timestamp = 6;
+ * @generated from field: int64 challenge_unix_ms = 6;
*/
- timestamp: bigint;
+ challengeUnixMs: bigint;
/**
* @generated from field: bytes challenge_signature = 7;
@@ -665,9 +671,9 @@ export type RouterLeaseResponse = Message<"sam.v1.RouterLeaseResponse"> & {
error: string;
/**
- * @generated from field: int64 expires_at = 3;
+ * @generated from field: google.protobuf.Timestamp expire_time = 3;
*/
- expiresAt: bigint;
+ expireTime?: Timestamp | undefined;
};
/**
@@ -845,12 +851,12 @@ export type KeysResponse = Message<"sam.v1.KeysResponse"> & {
publicKeys: Uint8Array[];
/**
- * Unix milliseconds at which the set was signed; receivers reject responses
- * outside a short freshness window so a captured set cannot be replayed.
+ * When the set was signed; receivers reject responses outside a short
+ * freshness window so a captured set cannot be replayed.
*
- * @generated from field: int64 timestamp = 2;
+ * @generated from field: google.protobuf.Timestamp sign_time = 2;
*/
- timestamp: bigint;
+ signTime?: Timestamp | undefined;
/**
* One ed25519 signature per entry of public_keys, by that key, over the
@@ -876,20 +882,21 @@ export const KeysResponseSchema: GenMessage<KeysResponse> = /*@__PURE__*/
export type TokenRefreshRequest = Message<"sam.v1.TokenRefreshRequest"> & {
/**
* Signature with the node key over the UTF-8 bytes of
- * "sam:refresh:<peer_id>:<timestamp>", where peer_id is the one bound in
- * the presented biscuit. Peer- and endpoint-bound so a captured signature
- * verifies nowhere else.
+ * "sam:refresh:<peer_id>:<challenge_unix_ms>", where peer_id is the one
+ * bound in the presented biscuit. Peer- and endpoint-bound so a captured
+ * signature verifies nowhere else.
*
* @generated from field: bytes challenge_signature = 1;
*/
challengeSignature: Uint8Array;
/**
- * Unix milliseconds. Must be within the control plane's freshness window.
+ * The caller's clock in unix milliseconds, the number in the signed text.
+ * Must be within the control plane's freshness window.
*
- * @generated from field: int64 timestamp = 2;
+ * @generated from field: int64 challenge_unix_ms = 2;
*/
- timestamp: bigint;
+ challengeUnixMs: bigint;
/**
* The caller's peer ID. Optional: the control plane normally reads it
@@ -922,9 +929,9 @@ export type TokenRefreshResponse = Message<"sam.v1.TokenRefreshResponse"> & {
biscuitToken: Uint8Array;
/**
- * @generated from field: int64 expires_at = 2;
+ * @generated from field: google.protobuf.Timestamp expire_time = 2;
*/
- expiresAt: bigint;
+ expireTime?: Timestamp | undefined;
/**
* @generated from field: string error_message = 3;
@@ -1293,9 +1300,9 @@ export type AgentRefreshResponse = Message<"sam.v1.AgentRefreshResponse"> & {
error: string;
/**
- * @generated from field: int64 expires_at = 3;
+ * @generated from field: google.protobuf.Timestamp expire_time = 3;
*/
- expiresAt: bigint;
+ expireTime?: Timestamp | undefined;
};
/**
@@ -1345,9 +1352,9 @@ export type AgentStatus = Message<"sam.v1.AgentStatus"> & {
ingress: AgentIngress[];
/**
- * @generated from field: int64 credential_expires_at = 4;
+ * @generated from field: google.protobuf.Timestamp credential_expire_time = 4;
*/
- credentialExpiresAt: bigint;
+ credentialExpireTime?: Timestamp | undefined;
};
/**
@@ -1394,9 +1401,9 @@ export type IdentityEvidenceResponse = Message<"sam.v1.IdentityEvidenceResponse"
biscuit: Uint8Array;
/**
- * @generated from field: int64 biscuit_expires_at = 3;
+ * @generated from field: google.protobuf.Timestamp biscuit_expire_time = 3;
*/
- biscuitExpiresAt: bigint;
+ biscuitExpireTime?: Timestamp | undefined;
/**
* @generated from field: string control_plane_url = 4;
@@ -1411,9 +1418,9 @@ export type IdentityEvidenceResponse = Message<"sam.v1.IdentityEvidenceResponse"
trustedControlPlaneKeys: Uint8Array[];
/**
- * @generated from field: int64 checked_at = 6;
+ * @generated from field: google.protobuf.Timestamp check_time = 6;
*/
- checkedAt: bigint;
+ checkTime?: Timestamp | undefined;
};
/**
@@ -1455,9 +1462,9 @@ export type PeerEvidenceResponse = Message<"sam.v1.PeerEvidenceResponse"> & {
labels: { [key: string]: string };
/**
- * @generated from field: int64 expiration = 6;
+ * @generated from field: google.protobuf.Timestamp expire_time = 6;
*/
- expiration: bigint;
+ expireTime?: Timestamp | undefined;
/**
* hex
@@ -1467,9 +1474,9 @@ export type PeerEvidenceResponse = Message<"sam.v1.PeerEvidenceResponse"> & {
revocationIds: string[];
/**
- * @generated from field: int64 checked_at = 8;
+ * @generated from field: google.protobuf.Timestamp check_time = 8;
*/
- checkedAt: bigint;
+ checkTime?: Timestamp | undefined;
};
/**
diff --git a/sdk/js/src/index.ts b/sdk/js/src/index.ts
index 42db0ac6..a5fc1441 100644
--- a/sdk/js/src/index.ts
+++ b/sdk/js/src/index.ts
@@ -63,4 +63,4 @@ export {
type ServiceSpec,
} from "./serve.ts";
export { BASELINE_DATALOG } from "./gen/datalog.ts";
-export { BanSet, EVENT_FRESHNESS_MS, GOSSIP_EVENTS_TOPIC, verifyMeshEvent } from "./sync.ts";
+export { BanSet, EVENT_FRESHNESS_MS, GOSSIP_EVENTS_TOPIC, verifyMeshEvent, type VerifiedMeshEvent } from "./sync.ts";
diff --git a/sdk/js/src/mesh.test.ts b/sdk/js/src/mesh.test.ts
index bffefb24..500234bd 100644
--- a/sdk/js/src/mesh.test.ts
+++ b/sdk/js/src/mesh.test.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
+import { timestampFromMs } from "@bufbuild/protobuf/wkt";
import assert from "node:assert/strict";
import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
@@ -41,7 +42,7 @@ function proto(bytes: Uint8Array): Response {
function fakeControlPlane(keysOk = true): { fetch: typeof fetch; issued: number } {
const state = { issued: 0 };
const signedKeys = () => {
- const unsigned = create(KeysResponseSchema, { publicKeys: [cpKey.publicKeyRaw], timestamp: BigInt(Date.now()) });
+ const unsigned = create(KeysResponseSchema, { publicKeys: [cpKey.publicKeyRaw], signTime: timestampFromMs(Date.now()) });
return create(KeysResponseSchema, { ...unsigned, signatures: [cpKey.sign(toBinary(KeysResponseSchema, unsigned))] });
};
const fetch: typeof globalThis.fetch = (async (input: Parameters<typeof globalThis.fetch>[0], init?: RequestInit) => {
@@ -58,13 +59,13 @@ function fakeControlPlane(keysOk = true): { fetch: typeof fetch; issued: number
biscuitToken: text(`biscuit-${state.issued}`),
controlPlanePublicKey: cpKey.publicKeyRaw,
routerAddresses: ["/dns4/router.example/tcp/4001/p2p/12D3KooWP8iKhDf3iCMo2H3butNVfdTUtYwYWYQ75jTGnynXPFMp"],
- expiration: BigInt(Math.floor(Date.now() / 1000) + 3600),
+ expireTime: timestampFromMs(Date.now() + 3600_000),
}),
),
);
case "POST /refresh":
state.issued++;
- return proto(toBinary(TokenRefreshResponseSchema, create(TokenRefreshResponseSchema, { biscuitToken: text(`biscuit-${state.issued}`), expiresAt: BigInt(Math.floor(Date.now() / 1000) + 7200) })));
+ return proto(toBinary(TokenRefreshResponseSchema, create(TokenRefreshResponseSchema, { biscuitToken: text(`biscuit-${state.issued}`), expireTime: timestampFromMs(Date.now() + 7200_000) })));
case "GET /keys":
return keysOk ? proto(toBinary(KeysResponseSchema, signedKeys())) : new Response("boom", { status: 500 });
default:
diff --git a/sdk/js/src/session.test.ts b/sdk/js/src/session.test.ts
index 42b537a7..17bf632d 100644
--- a/sdk/js/src/session.test.ts
+++ b/sdk/js/src/session.test.ts
@@ -18,6 +18,7 @@
// plane are exercised by tests/integration/sdk_join_test.go.
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
+import { timestampFromMs } from "@bufbuild/protobuf/wkt";
import { yamux } from "@chainsafe/libp2p-yamux";
import { circuitRelayServer, circuitRelayTransport } from "@libp2p/circuit-relay-v2";
import { privateKeyFromProtobuf } from "@libp2p/crypto/keys";
@@ -72,14 +73,14 @@ function fakeControlPlane(routerAddresses: string[]): typeof fetch {
biscuitToken: mint(enroll.peerId, ROLE_NODE),
controlPlanePublicKey: cpKey,
routerAddresses,
- expiration: BigInt(Math.floor(Date.now() / 1000) + 3600),
+ expireTime: timestampFromMs(Date.now() + 3600_000),
}),
),
);
}
if (req.method === "GET" && path === "/keys") {
// Unsigned: the client keeps the enrollment key when /keys cannot be verified.
- return proto(toBinary(KeysResponseSchema, create(KeysResponseSchema, { publicKeys: [cpKey], timestamp: BigInt(Date.now()) })));
+ return proto(toBinary(KeysResponseSchema, create(KeysResponseSchema, { publicKeys: [cpKey], signTime: timestampFromMs(Date.now()) })));
}
return new Response(`no route for ${req.method} ${path}`, { status: 404 });
}) as typeof fetch;
diff --git a/sdk/js/src/session.ts b/sdk/js/src/session.ts
index 4d9f468f..0d93a4e5 100644
--- a/sdk/js/src/session.ts
+++ b/sdk/js/src/session.ts
@@ -13,6 +13,7 @@
// limitations under the License.
import type { Connection } from "@libp2p/interface";
+import { timestampMs } from "@bufbuild/protobuf/wkt";
import { TopicValidatorResult } from "@libp2p/gossipsub";
import { peerIdFromString } from "@libp2p/peer-id";
import { isMultiaddr, multiaddr, type Multiaddr } from "@multiformats/multiaddr";
@@ -382,7 +383,7 @@ export class MeshSession {
switch (event.type) {
case MeshEvent_Type.BANNED:
// Not persisted: a restarted member picks the ban back up from /info.
- if (this.banned.add(event.peerId, Number(event.timestamp))) {
+ if (this.banned.add(event.peerId, timestampMs(event.eventTime))) {
void this.#evict(event.peerId);
}
break;
diff --git a/sdk/js/src/sync.test.ts b/sdk/js/src/sync.test.ts
index 15f6594b..9f9ae5fe 100644
--- a/sdk/js/src/sync.test.ts
+++ b/sdk/js/src/sync.test.ts
@@ -19,6 +19,7 @@
// router are exercised by tests/integration/sdk_mesh_test.go.
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
+import { timestampFromMs } from "@bufbuild/protobuf/wkt";
import { yamux } from "@chainsafe/libp2p-yamux";
import { circuitRelayServer, circuitRelayTransport } from "@libp2p/circuit-relay-v2";
import { privateKeyFromProtobuf } from "@libp2p/crypto/keys";
@@ -101,14 +102,14 @@ class FakeControlPlane {
biscuitToken: this.current.mint(enroll.peerId, ROLE_NODE),
controlPlanePublicKey: this.current.pub,
routerAddresses: [routerAddr],
- expiration: BigInt(Math.floor(Date.now() / 1000) + 3600),
+ expireTime: timestampFromMs(Date.now() + 3600_000),
}),
),
);
}
if (req.method === "GET" && path === "/keys") {
// Signed as api.VerifyKeysResponse expects: each key over the set with signatures cleared.
- const unsigned = create(KeysResponseSchema, { publicKeys: this.keys.map((k) => k.pub), timestamp: BigInt(Date.now()) });
+ const unsigned = create(KeysResponseSchema, { publicKeys: this.keys.map((k) => k.pub), signTime: timestampFromMs(Date.now()) });
const payload = toBinary(KeysResponseSchema, unsigned);
return proto(toBinary(KeysResponseSchema, create(KeysResponseSchema, { ...unsigned, signatures: this.keys.map((k) => k.identity.sign(payload)) })));
}
@@ -138,7 +139,7 @@ class FakeControlPlane {
return proto(
toBinary(
TokenRefreshResponseSchema,
- create(TokenRefreshResponseSchema, { biscuitToken: this.current.mint(peerId, ROLE_NODE), expiresAt: BigInt(Math.floor(Date.now() / 1000) + 7200) }),
+ create(TokenRefreshResponseSchema, { biscuitToken: this.current.mint(peerId, ROLE_NODE), expireTime: timestampFromMs(Date.now() + 7200_000) }),
),
);
}
@@ -189,13 +190,13 @@ test("a mesh event verifies only under a trusted key and only when fresh", () =>
return toBinary(MeshEventSchema, { ...event, signature: key.identity.sign(unsigned) });
};
const now = new Date();
- const banned = sign(create(MeshEventSchema, { type: MeshEvent_Type.BANNED, peerId: "12D3KooWx", timestamp: BigInt(now.getTime()) }));
+ const banned = sign(create(MeshEventSchema, { type: MeshEvent_Type.BANNED, peerId: "12D3KooWx", eventTime: timestampFromMs(now.getTime()) }));
assert.equal(verifyMeshEvent(banned, [key.pub], now)?.peerId, "12D3KooWx");
assert.equal(verifyMeshEvent(banned, [new SigningKey().pub], now), undefined, "untrusted key");
const tampered = new Uint8Array(banned);
tampered[tampered.length - 1] = (tampered[tampered.length - 1] ?? 0) ^ 1;
assert.equal(verifyMeshEvent(tampered, [key.pub], now), undefined, "tampered signature");
- const stale = sign(create(MeshEventSchema, { type: MeshEvent_Type.BANNED, peerId: "12D3KooWx", timestamp: BigInt(now.getTime() - EVENT_FRESHNESS_MS - 1) }));
+ const stale = sign(create(MeshEventSchema, { type: MeshEvent_Type.BANNED, peerId: "12D3KooWx", eventTime: timestampFromMs(now.getTime() - EVENT_FRESHNESS_MS - 1) }));
assert.equal(verifyMeshEvent(stale, [key.pub], now), undefined, "stale");
assert.equal(verifyMeshEvent(new Uint8Array([1, 2, 3]), [key.pub], now), undefined, "garbage");
});
diff --git a/sdk/js/src/sync.ts b/sdk/js/src/sync.ts
index a56e0f64..c720ec68 100644
--- a/sdk/js/src/sync.ts
+++ b/sdk/js/src/sync.ts
@@ -17,6 +17,7 @@
// the gossip events that bring the next pull forward.
import { fromBinary, toBinary } from "@bufbuild/protobuf";
+import { timestampMs, type Timestamp } from "@bufbuild/protobuf/wkt";
import { verifyEd25519 } from "./identity.ts";
import { MeshEvent_Type, MeshEventSchema, type MeshEvent } from "./gen/sam_pb.ts";
@@ -81,13 +82,16 @@ export class BanSet {
}
}
+/** A MeshEvent that verified: signed by a trusted key and carrying a fresh event_time. */
+export type VerifiedMeshEvent = MeshEvent & { eventTime: Timestamp };
+
/**
* Verifies a MeshEvent as sam-node's verifyEvent does: the signature covers
* the deterministic encoding of the event with the signature cleared, under
* any trusted control plane key. Returns the event, or undefined when it
* does not verify or is not fresh.
*/
-export function verifyMeshEvent(data: Uint8Array, trustedKeys: Uint8Array[], now: Date = new Date()): MeshEvent | undefined {
+export function verifyMeshEvent(data: Uint8Array, trustedKeys: Uint8Array[], now: Date = new Date()): VerifiedMeshEvent | undefined {
let event: MeshEvent;
try {
event = fromBinary(MeshEventSchema, data);
@@ -99,11 +103,14 @@ export function verifyMeshEvent(data: Uint8Array, trustedKeys: Uint8Array[], now
if (!trustedKeys.some((key) => verifyEd25519(key, unsigned, signature))) {
return undefined;
}
- const skew = Math.abs(now.getTime() - Number(event.timestamp));
+ if (event.eventTime === undefined) {
+ return undefined;
+ }
+ const skew = Math.abs(now.getTime() - timestampMs(event.eventTime));
if (skew > EVENT_FRESHNESS_MS) {
return undefined;
}
- return event;
+ return event as VerifiedMeshEvent;
}
export { MeshEvent_Type };
diff --git a/sdk/python/src/agent_mesh/_proto/sam_pb2.py b/sdk/python/src/agent_mesh/_proto/sam_pb2.py
index a4cde925..05f2781d 100644
--- a/sdk/python/src/agent_mesh/_proto/sam_pb2.py
+++ b/sdk/python/src/agent_mesh/_proto/sam_pb2.py
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tsam.proto\x12\x06sam.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"C\n\tAuthFrame\x12\x0f\n\x07\x62iscuit\x18\x01 \x01(\x0c\x12\x16\n\x0etarget_service\x18\x02 \x01(\t\x12\r\n\x05\x61gent\x18\x03 \x01(\t\"?\n\x0c\x41uthResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x03 \x01(\x0c\"\xb9\x01\n\tMeshEvent\x12$\n\x04type\x18\x01 \x01(\x0e\x32\x16.sam.v1.MeshEvent.Type\x12\x0f\n\x07peer_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\x03\x12\x16\n\x0enew_public_key\x18\x04 \x01(\x0c\x12\x11\n\tsignature\x18\x05 \x01(\x0c\"7\n\x04Type\x12\n\n\x06\x42\x41NNED\x10\x00\x12\x10\n\x0cKEY_ROTATION\x10\x01\x12\x11\n\rPOLICY_UPDATE\x10\x02\"\xeb\x01\n\rEnrollRequest\x12\x0b\n\x03jwt\x18\x01 \x01(\t\x12\x0f\n\x07peer_id\x18\x02 \x01(\t\x12\x12\n\npublic_key\x18\x03 \x01(\x0c\x12\x16\n\x0erequested_role\x18\x04 \x01(\t\x12\x31\n\x06labels\x18\x05 \x03(\x0b\x32!.sam.v1.EnrollRequest.LabelsEntry\x12\x11\n\ttimestamp\x18\x06 \x01(\x03\x12\x1b\n\x13\x63hallenge_signature\x18\x07 \x01(\x0c\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x8e\x01\n\x0e\x45nrollResponse\x12\x15\n\rbiscuit_token\x18\x01 \x01(\x0c\x12\x15\n\rerror_message\x18\x02 \x01(\t\x12 \n\x18\x63ontrol_plane_public_key\x18\x03 \x01(\x0c\x12\x18\n\x10router_addresses\x18\x04 \x03(\t\x12\x12\n\nexpiration\x18\x05 \x01(\x03\"\x89\x02\n\x16\x42ootstrapEnrollRequest\x12\x17\n\x0f\x62ootstrap_token\x18\x01 \x01(\t\x12\x0f\n\x07peer_id\x18\x02 \x01(\t\x12\x12\n\npublic_key\x18\x03 \x01(\x0c\x12\x16\n\x0erequested_role\x18\x04 \x01(\t\x12:\n\x06labels\x18\x05 \x03(\x0b\x32*.sam.v1.BootstrapEnrollRequest.LabelsEntry\x12\x11\n\ttimestamp\x18\x06 \x01(\x03\x12\x1b\n\x13\x63hallenge_signature\x18\x07 \x01(\x0c\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xe0\x01\n\x17\x42ootstrapEnrollResponse\x12(\n\x06status\x18\x01 \x01(\x0e\x32\x18.sam.v1.EnrollmentStatus\x12\x15\n\rbiscuit_token\x18\x02 \x01(\x0c\x12\x1d\n\x15poll_interval_seconds\x18\x03 \x01(\x05\x12\x15\n\rerror_message\x18\x04 \x01(\t\x12 \n\x18\x63ontrol_plane_public_key\x18\x05 \x01(\x0c\x12\x18\n\x10router_addresses\x18\x06 \x03(\t\x12\x12\n\nexpiration\x18\x07 \x01(\x03\"S\n\x0bServiceInfo\x12!\n\x04type\x18\x01 \x01(\x0e\x32\x13.sam.v1.ServiceType\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\"{\n\x0e\x43ommandBackend\x12\x0f\n\x07\x63ommand\x18\x01 \x03(\t\x12,\n\x03\x65nv\x18\x02 \x03(\x0b\x32\x1f.sam.v1.CommandBackend.EnvEntry\x1a*\n\x08\x45nvEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x8a\x01\n\x16RegisterServiceRequest\x12$\n\x07service\x18\x01 \x01(\x0b\x32\x13.sam.v1.ServiceInfo\x12\x14\n\ntarget_url\x18\x02 \x01(\tH\x00\x12)\n\x07\x63ommand\x18\x03 \x01(\x0b\x32\x16.sam.v1.CommandBackendH\x00\x42\t\n\x07\x62\x61\x63kend\"i\n\x12\x44iscoveredProvider\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x17\n\x0flocal_proxy_url\x18\x02 \x01(\t\x12\x10\n\x08srv_name\x18\x03 \x01(\t\x12\x17\n\x0fsrv_description\x18\x04 \x01(\t\"\x92\x02\n\x0fServiceAnnounce\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12!\n\x04type\x18\x02 \x01(\x0e\x32\x13.sam.v1.ServiceType\x12\x14\n\x0cservice_name\x18\x03 \x01(\t\x12\x0c\n\x04keys\x18\x04 \x03(\t\x12\x33\n\x06labels\x18\x05 \x03(\x0b\x32#.sam.v1.ServiceAnnounce.LabelsEntry\x12\x17\n\x0f\x61\x63tive_requests\x18\x06 \x01(\r\x12\x17\n\x0flatency_ewma_ms\x18\x07 \x01(\x01\x12\x11\n\ttimestamp\x18\x08 \x01(\x03\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x87\x01\n\x18\x43ontrolPlaneInfoResponse\x12\x13\n\x0boidc_issuer\x18\x01 \x01(\t\x12\x11\n\tclient_id\x18\x02 \x01(\t\x12\x10\n\x08\x61udience\x18\x03 \x01(\t\x12\x18\n\x10router_addresses\x18\x04 \x03(\t\x12\x17\n\x0f\x62\x61nned_peer_ids\x18\x05 \x03(\t\"\xa4\x01\n\x12RouterLeaseRequest\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x11\n\taddresses\x18\x02 \x03(\t\x12\x0f\n\x07\x62iscuit\x18\x03 \x01(\x0c\x12\x17\n\x0f\x63onnected_peers\x18\x04 \x03(\t\x12\x10\n\x08\x64ht_size\x18\x05 \x01(\x05\x12\x11\n\ttimestamp\x18\x06 \x01(\x03\x12\x1b\n\x13\x63hallenge_signature\x18\x07 \x01(\x0c\"I\n\x13RouterLeaseResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12\x12\n\nexpires_at\x18\x03 \x01(\x03\"\x95\x01\n\nPolicyRole\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\x0f\x61llowed_targets\x18\x02 \x03(\t\x12\x18\n\x10\x61llowed_services\x18\x03 \x03(\t\x12\x16\n\x0e\x63ustom_datalog\x18\x04 \x03(\t\x12\x16\n\x0e\x61llowed_agents\x18\x05 \x03(\t\x12\x16\n\x0e\x61llowed_labels\x18\x06 \x03(\t\".\n\rPolicyBinding\x12\x0c\n\x04role\x18\x01 \x01(\t\x12\x0f\n\x07members\x18\x02 \x03(\t\"Z\n\x0cPolicyConfig\x12!\n\x05roles\x18\x01 \x03(\x0b\x32\x12.sam.v1.PolicyRole\x12\'\n\x08\x62indings\x18\x02 \x03(\x0b\x32\x15.sam.v1.PolicyBinding\"\x18\n\x16PolicyConfigGetRequest\"M\n\x17PolicyConfigGetResponse\x12\x15\n\rdatalog_rules\x18\x03 \x03(\tJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03R\x05rolesR\x08\x62indings\"<\n\x1aPolicyConfigUpdateResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"J\n\x0cKeysResponse\x12\x13\n\x0bpublic_keys\x18\x01 \x03(\x0c\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\x12\x12\n\nsignatures\x18\x03 \x03(\x0c\"V\n\x13TokenRefreshRequest\x12\x1b\n\x13\x63hallenge_signature\x18\x01 \x01(\x0c\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\x12\x0f\n\x07peer_id\x18\x03 \x01(\t\"X\n\x14TokenRefreshResponse\x12\x15\n\rbiscuit_token\x18\x01 \x01(\x0c\x12\x12\n\nexpires_at\x18\x02 \x01(\x03\x12\x15\n\rerror_message\x18\x03 \x01(\t\":\n\x11NodeCatalogReport\x12%\n\x08services\x18\x01 \x03(\x0b\x32\x13.sam.v1.ServiceInfo\"%\n\x12TokenRevokeRequest\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\"5\n\x13TokenRevokeResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"R\n\x0b\x41gentSecret\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04kind\x18\x02 \x01(\t\x12\x13\n\x0bheader_name\x18\x03 \x01(\t\x12\x12\n\nvalue_path\x18\x04 \x01(\t\"B\n\x0b\x41gentEgress\x12\r\n\x05\x61llow\x18\x01 \x03(\t\x12$\n\x07secrets\x18\x02 \x03(\x0b\x32\x13.sam.v1.AgentSecret\"b\n\x0c\x41gentIngress\x12!\n\x04type\x18\x01 \x01(\x0e\x32\x13.sam.v1.ServiceType\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0c\n\x04port\x18\x03 \x01(\r\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\"\xaa\x01\n\x0b\x41gentBundle\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x10\n\x08\x61gent_id\x18\x02 \x01(\t\x12\x13\n\x0b\x65xternal_id\x18\x03 \x01(\t\x12\x17\n\x0f\x63redential_path\x18\x04 \x01(\t\x12#\n\x06\x65gress\x18\x05 \x01(\x0b\x32\x13.sam.v1.AgentEgress\x12%\n\x07ingress\x18\x06 \x03(\x0b\x32\x14.sam.v1.AgentIngress\"9\n\x12\x41gentAttachRequest\x12#\n\x06\x62undle\x18\x01 \x01(\x0b\x32\x13.sam.v1.AgentBundle\"S\n\x13\x41gentAttachResponse\x12\x15\n\regress_socket\x18\x01 \x01(\t\x12\x16\n\x0eingress_socket\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\t\"&\n\x12\x41gentDetachRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\"5\n\x13\x41gentDetachResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"@\n\x13\x41gentRefreshRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x17\n\x0f\x63redential_path\x18\x02 \x01(\t\"J\n\x14\x41gentRefreshResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12\x12\n\nexpires_at\x18\x03 \x01(\x03\"&\n\x12\x41gentStatusRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\"w\n\x0b\x41gentStatus\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x10\n\x08\x61ttached\x18\x02 \x01(\x08\x12%\n\x07ingress\x18\x03 \x03(\x0b\x32\x14.sam.v1.AgentIngress\x12\x1d\n\x15\x63redential_expires_at\x18\x04 \x01(\x03\"I\n\x13\x41gentStatusResponse\x12#\n\x06\x61gents\x18\x01 \x03(\x0b\x32\x13.sam.v1.AgentStatus\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"\xab\x01\n\x18IdentityEvidenceResponse\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x02 \x01(\x0c\x12\x1a\n\x12\x62iscuit_expires_at\x18\x03 \x01(\x03\x12\x19\n\x11\x63ontrol_plane_url\x18\x04 \x01(\t\x12\"\n\x1atrusted_control_plane_keys\x18\x05 \x03(\x0c\x12\x12\n\nchecked_at\x18\x06 \x01(\x03\"\x87\x02\n\x14PeerEvidenceResponse\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x02 \x01(\x0c\x12\x15\n\rverifying_key\x18\x03 \x01(\x0c\x12\r\n\x05roles\x18\x04 \x03(\t\x12\x38\n\x06labels\x18\x05 \x03(\x0b\x32(.sam.v1.PeerEvidenceResponse.LabelsEntry\x12\x12\n\nexpiration\x18\x06 \x01(\x03\x12\x16\n\x0erevocation_ids\x18\x07 \x03(\t\x12\x12\n\nchecked_at\x18\x08 \x01(\x03\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x80\x02\n\x10MemberCredential\x12\x19\n\x11\x63ontrol_plane_url\x18\x01 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x02 \x01(\x0c\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0ctrusted_keys\x18\x04 \x03(\x0b\x32\x19.sam.v1.TrustedSigningKey\x12\x19\n\x11issued_under_keys\x18\x05 \x03(\x0c\x12\x18\n\x10router_addresses\x18\x06 \x03(\t\x12)\n\x0coidc_session\x18\x07 \x01(\x0b\x32\x13.sam.v1.OIDCSession\"Y\n\x11TrustedSigningKey\x12\x12\n\npublic_key\x18\x01 \x01(\x0c\x12\x30\n\x0creceive_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"Y\n\x0bOIDCSession\x12\x0e\n\x06issuer\x18\x01 \x01(\t\x12\x11\n\tclient_id\x18\x02 \x01(\t\x12\x10\n\x08\x61udience\x18\x03 \x01(\t\x12\x15\n\rrefresh_token\x18\x04 \x01(\t*\x94\x01\n\x10\x45nrollmentStatus\x12!\n\x1d\x45NROLLMENT_STATUS_UNSPECIFIED\x10\x00\x12\x1d\n\x19\x45NROLLMENT_STATUS_PENDING\x10\x01\x12\x1e\n\x1a\x45NROLLMENT_STATUS_APPROVED\x10\x02\x12\x1e\n\x1a\x45NROLLMENT_STATUS_REJECTED\x10\x03*s\n\x0bServiceType\x12\x1c\n\x18SERVICE_TYPE_UNSPECIFIED\x10\x00\x12\x14\n\x10SERVICE_TYPE_MCP\x10\x01\x12\x1a\n\x16SERVICE_TYPE_INFERENCE\x10\x02\x12\x14\n\x10SERVICE_TYPE_A2A\x10\x03\x42\x1bZ\x19github.com/google/sam/apib\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tsam.proto\x12\x06sam.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"C\n\tAuthFrame\x12\x0f\n\x07\x62iscuit\x18\x01 \x01(\x0c\x12\x16\n\x0etarget_service\x18\x02 \x01(\t\x12\r\n\x05\x61gent\x18\x03 \x01(\t\"?\n\x0c\x41uthResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x03 \x01(\x0c\"\xd6\x01\n\tMeshEvent\x12$\n\x04type\x18\x01 \x01(\x0e\x32\x16.sam.v1.MeshEvent.Type\x12\x0f\n\x07peer_id\x18\x02 \x01(\t\x12.\n\nevent_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x16\n\x0enew_public_key\x18\x04 \x01(\x0c\x12\x11\n\tsignature\x18\x05 \x01(\x0c\"7\n\x04Type\x12\n\n\x06\x42\x41NNED\x10\x00\x12\x10\n\x0cKEY_ROTATION\x10\x01\x12\x11\n\rPOLICY_UPDATE\x10\x02\"\xf3\x01\n\rEnrollRequest\x12\x0b\n\x03jwt\x18\x01 \x01(\t\x12\x0f\n\x07peer_id\x18\x02 \x01(\t\x12\x12\n\npublic_key\x18\x03 \x01(\x0c\x12\x16\n\x0erequested_role\x18\x04 \x01(\t\x12\x31\n\x06labels\x18\x05 \x03(\x0b\x32!.sam.v1.EnrollRequest.LabelsEntry\x12\x19\n\x11\x63hallenge_unix_ms\x18\x06 \x01(\x03\x12\x1b\n\x13\x63hallenge_signature\x18\x07 \x01(\x0c\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xab\x01\n\x0e\x45nrollResponse\x12\x15\n\rbiscuit_token\x18\x01 \x01(\x0c\x12\x15\n\rerror_message\x18\x02 \x01(\t\x12 \n\x18\x63ontrol_plane_public_key\x18\x03 \x01(\x0c\x12\x18\n\x10router_addresses\x18\x04 \x03(\t\x12/\n\x0b\x65xpire_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x91\x02\n\x16\x42ootstrapEnrollRequest\x12\x17\n\x0f\x62ootstrap_token\x18\x01 \x01(\t\x12\x0f\n\x07peer_id\x18\x02 \x01(\t\x12\x12\n\npublic_key\x18\x03 \x01(\x0c\x12\x16\n\x0erequested_role\x18\x04 \x01(\t\x12:\n\x06labels\x18\x05 \x03(\x0b\x32*.sam.v1.BootstrapEnrollRequest.LabelsEntry\x12\x19\n\x11\x63hallenge_unix_ms\x18\x06 \x01(\x03\x12\x1b\n\x13\x63hallenge_signature\x18\x07 \x01(\x0c\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xfd\x01\n\x17\x42ootstrapEnrollResponse\x12(\n\x06status\x18\x01 \x01(\x0e\x32\x18.sam.v1.EnrollmentStatus\x12\x15\n\rbiscuit_token\x18\x02 \x01(\x0c\x12\x1d\n\x15poll_interval_seconds\x18\x03 \x01(\x05\x12\x15\n\rerror_message\x18\x04 \x01(\t\x12 \n\x18\x63ontrol_plane_public_key\x18\x05 \x01(\x0c\x12\x18\n\x10router_addresses\x18\x06 \x03(\t\x12/\n\x0b\x65xpire_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"S\n\x0bServiceInfo\x12!\n\x04type\x18\x01 \x01(\x0e\x32\x13.sam.v1.ServiceType\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\"{\n\x0e\x43ommandBackend\x12\x0f\n\x07\x63ommand\x18\x01 \x03(\t\x12,\n\x03\x65nv\x18\x02 \x03(\x0b\x32\x1f.sam.v1.CommandBackend.EnvEntry\x1a*\n\x08\x45nvEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x8a\x01\n\x16RegisterServiceRequest\x12$\n\x07service\x18\x01 \x01(\x0b\x32\x13.sam.v1.ServiceInfo\x12\x14\n\ntarget_url\x18\x02 \x01(\tH\x00\x12)\n\x07\x63ommand\x18\x03 \x01(\x0b\x32\x16.sam.v1.CommandBackendH\x00\x42\t\n\x07\x62\x61\x63kend\"i\n\x12\x44iscoveredProvider\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x17\n\x0flocal_proxy_url\x18\x02 \x01(\t\x12\x10\n\x08srv_name\x18\x03 \x01(\t\x12\x17\n\x0fsrv_description\x18\x04 \x01(\t\"\xb2\x02\n\x0fServiceAnnounce\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12!\n\x04type\x18\x02 \x01(\x0e\x32\x13.sam.v1.ServiceType\x12\x14\n\x0cservice_name\x18\x03 \x01(\t\x12\x0c\n\x04keys\x18\x04 \x03(\t\x12\x33\n\x06labels\x18\x05 \x03(\x0b\x32#.sam.v1.ServiceAnnounce.LabelsEntry\x12\x17\n\x0f\x61\x63tive_requests\x18\x06 \x01(\r\x12\x17\n\x0flatency_ewma_ms\x18\x07 \x01(\x01\x12\x31\n\rannounce_time\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x87\x01\n\x18\x43ontrolPlaneInfoResponse\x12\x13\n\x0boidc_issuer\x18\x01 \x01(\t\x12\x11\n\tclient_id\x18\x02 \x01(\t\x12\x10\n\x08\x61udience\x18\x03 \x01(\t\x12\x18\n\x10router_addresses\x18\x04 \x03(\t\x12\x17\n\x0f\x62\x61nned_peer_ids\x18\x05 \x03(\t\"\xac\x01\n\x12RouterLeaseRequest\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x11\n\taddresses\x18\x02 \x03(\t\x12\x0f\n\x07\x62iscuit\x18\x03 \x01(\x0c\x12\x17\n\x0f\x63onnected_peers\x18\x04 \x03(\t\x12\x10\n\x08\x64ht_size\x18\x05 \x01(\x05\x12\x19\n\x11\x63hallenge_unix_ms\x18\x06 \x01(\x03\x12\x1b\n\x13\x63hallenge_signature\x18\x07 \x01(\x0c\"f\n\x13RouterLeaseResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x95\x01\n\nPolicyRole\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x17\n\x0f\x61llowed_targets\x18\x02 \x03(\t\x12\x18\n\x10\x61llowed_services\x18\x03 \x03(\t\x12\x16\n\x0e\x63ustom_datalog\x18\x04 \x03(\t\x12\x16\n\x0e\x61llowed_agents\x18\x05 \x03(\t\x12\x16\n\x0e\x61llowed_labels\x18\x06 \x03(\t\".\n\rPolicyBinding\x12\x0c\n\x04role\x18\x01 \x01(\t\x12\x0f\n\x07members\x18\x02 \x03(\t\"Z\n\x0cPolicyConfig\x12!\n\x05roles\x18\x01 \x03(\x0b\x32\x12.sam.v1.PolicyRole\x12\'\n\x08\x62indings\x18\x02 \x03(\x0b\x32\x15.sam.v1.PolicyBinding\"\x18\n\x16PolicyConfigGetRequest\"M\n\x17PolicyConfigGetResponse\x12\x15\n\rdatalog_rules\x18\x03 \x03(\tJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03R\x05rolesR\x08\x62indings\"<\n\x1aPolicyConfigUpdateResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"f\n\x0cKeysResponse\x12\x13\n\x0bpublic_keys\x18\x01 \x03(\x0c\x12-\n\tsign_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x12\n\nsignatures\x18\x03 \x03(\x0c\"^\n\x13TokenRefreshRequest\x12\x1b\n\x13\x63hallenge_signature\x18\x01 \x01(\x0c\x12\x19\n\x11\x63hallenge_unix_ms\x18\x02 \x01(\x03\x12\x0f\n\x07peer_id\x18\x03 \x01(\t\"u\n\x14TokenRefreshResponse\x12\x15\n\rbiscuit_token\x18\x01 \x01(\x0c\x12/\n\x0b\x65xpire_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x15\n\rerror_message\x18\x03 \x01(\t\":\n\x11NodeCatalogReport\x12%\n\x08services\x18\x01 \x03(\x0b\x32\x13.sam.v1.ServiceInfo\"%\n\x12TokenRevokeRequest\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\"5\n\x13TokenRevokeResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"R\n\x0b\x41gentSecret\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04kind\x18\x02 \x01(\t\x12\x13\n\x0bheader_name\x18\x03 \x01(\t\x12\x12\n\nvalue_path\x18\x04 \x01(\t\"B\n\x0b\x41gentEgress\x12\r\n\x05\x61llow\x18\x01 \x03(\t\x12$\n\x07secrets\x18\x02 \x03(\x0b\x32\x13.sam.v1.AgentSecret\"b\n\x0c\x41gentIngress\x12!\n\x04type\x18\x01 \x01(\x0e\x32\x13.sam.v1.ServiceType\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0c\n\x04port\x18\x03 \x01(\r\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\"\xaa\x01\n\x0b\x41gentBundle\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x10\n\x08\x61gent_id\x18\x02 \x01(\t\x12\x13\n\x0b\x65xternal_id\x18\x03 \x01(\t\x12\x17\n\x0f\x63redential_path\x18\x04 \x01(\t\x12#\n\x06\x65gress\x18\x05 \x01(\x0b\x32\x13.sam.v1.AgentEgress\x12%\n\x07ingress\x18\x06 \x03(\x0b\x32\x14.sam.v1.AgentIngress\"9\n\x12\x41gentAttachRequest\x12#\n\x06\x62undle\x18\x01 \x01(\x0b\x32\x13.sam.v1.AgentBundle\"S\n\x13\x41gentAttachResponse\x12\x15\n\regress_socket\x18\x01 \x01(\t\x12\x16\n\x0eingress_socket\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\t\"&\n\x12\x41gentDetachRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\"5\n\x13\x41gentDetachResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"@\n\x13\x41gentRefreshRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x17\n\x0f\x63redential_path\x18\x02 \x01(\t\"g\n\x14\x41gentRefreshResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"&\n\x12\x41gentStatusRequest\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\"\x94\x01\n\x0b\x41gentStatus\x12\x10\n\x08\x61gent_id\x18\x01 \x01(\t\x12\x10\n\x08\x61ttached\x18\x02 \x01(\x08\x12%\n\x07ingress\x18\x03 \x03(\x0b\x32\x14.sam.v1.AgentIngress\x12:\n\x16\x63redential_expire_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"I\n\x13\x41gentStatusResponse\x12#\n\x06\x61gents\x18\x01 \x03(\x0b\x32\x13.sam.v1.AgentStatus\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"\xe4\x01\n\x18IdentityEvidenceResponse\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x02 \x01(\x0c\x12\x37\n\x13\x62iscuit_expire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x19\n\x11\x63ontrol_plane_url\x18\x04 \x01(\t\x12\"\n\x1atrusted_control_plane_keys\x18\x05 \x03(\x0c\x12.\n\ncheck_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xc0\x02\n\x14PeerEvidenceResponse\x12\x0f\n\x07peer_id\x18\x01 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x02 \x01(\x0c\x12\x15\n\rverifying_key\x18\x03 \x01(\x0c\x12\r\n\x05roles\x18\x04 \x03(\t\x12\x38\n\x06labels\x18\x05 \x03(\x0b\x32(.sam.v1.PeerEvidenceResponse.LabelsEntry\x12/\n\x0b\x65xpire_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x16\n\x0erevocation_ids\x18\x07 \x03(\t\x12.\n\ncheck_time\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x80\x02\n\x10MemberCredential\x12\x19\n\x11\x63ontrol_plane_url\x18\x01 \x01(\t\x12\x0f\n\x07\x62iscuit\x18\x02 \x01(\x0c\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0ctrusted_keys\x18\x04 \x03(\x0b\x32\x19.sam.v1.TrustedSigningKey\x12\x19\n\x11issued_under_keys\x18\x05 \x03(\x0c\x12\x18\n\x10router_addresses\x18\x06 \x03(\t\x12)\n\x0coidc_session\x18\x07 \x01(\x0b\x32\x13.sam.v1.OIDCSession\"Y\n\x11TrustedSigningKey\x12\x12\n\npublic_key\x18\x01 \x01(\x0c\x12\x30\n\x0creceive_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"Y\n\x0bOIDCSession\x12\x0e\n\x06issuer\x18\x01 \x01(\t\x12\x11\n\tclient_id\x18\x02 \x01(\t\x12\x10\n\x08\x61udience\x18\x03 \x01(\t\x12\x15\n\rrefresh_token\x18\x04 \x01(\t*\x94\x01\n\x10\x45nrollmentStatus\x12!\n\x1d\x45NROLLMENT_STATUS_UNSPECIFIED\x10\x00\x12\x1d\n\x19\x45NROLLMENT_STATUS_PENDING\x10\x01\x12\x1e\n\x1a\x45NROLLMENT_STATUS_APPROVED\x10\x02\x12\x1e\n\x1a\x45NROLLMENT_STATUS_REJECTED\x10\x03*s\n\x0bServiceType\x12\x1c\n\x18SERVICE_TYPE_UNSPECIFIED\x10\x00\x12\x14\n\x10SERVICE_TYPE_MCP\x10\x01\x12\x1a\n\x16SERVICE_TYPE_INFERENCE\x10\x02\x12\x14\n\x10SERVICE_TYPE_A2A\x10\x03\x42\x1bZ\x19github.com/google/sam/apib\x06proto3')
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'sam_pb2', globals())
@@ -32,110 +32,110 @@ if _descriptor._USE_C_DESCRIPTORS == False:
_SERVICEANNOUNCE_LABELSENTRY._serialized_options = b'8\001'
_PEEREVIDENCERESPONSE_LABELSENTRY._options = None
_PEEREVIDENCERESPONSE_LABELSENTRY._serialized_options = b'8\001'
- _ENROLLMENTSTATUS._serialized_start=5160
- _ENROLLMENTSTATUS._serialized_end=5308
- _SERVICETYPE._serialized_start=5310
- _SERVICETYPE._serialized_end=5425
+ _ENROLLMENTSTATUS._serialized_start=5570
+ _ENROLLMENTSTATUS._serialized_end=5718
+ _SERVICETYPE._serialized_start=5720
+ _SERVICETYPE._serialized_end=5835
_AUTHFRAME._serialized_start=54
_AUTHFRAME._serialized_end=121
_AUTHRESPONSE._serialized_start=123
_AUTHRESPONSE._serialized_end=186
_MESHEVENT._serialized_start=189
- _MESHEVENT._serialized_end=374
- _MESHEVENT_TYPE._serialized_start=319
- _MESHEVENT_TYPE._serialized_end=374
- _ENROLLREQUEST._serialized_start=377
- _ENROLLREQUEST._serialized_end=612
- _ENROLLREQUEST_LABELSENTRY._serialized_start=567
- _ENROLLREQUEST_LABELSENTRY._serialized_end=612
- _ENROLLRESPONSE._serialized_start=615
- _ENROLLRESPONSE._serialized_end=757
- _BOOTSTRAPENROLLREQUEST._serialized_start=760
- _BOOTSTRAPENROLLREQUEST._serialized_end=1025
- _BOOTSTRAPENROLLREQUEST_LABELSENTRY._serialized_start=567
- _BOOTSTRAPENROLLREQUEST_LABELSENTRY._serialized_end=612
- _BOOTSTRAPENROLLRESPONSE._serialized_start=1028
- _BOOTSTRAPENROLLRESPONSE._serialized_end=1252
- _SERVICEINFO._serialized_start=1254
- _SERVICEINFO._serialized_end=1337
- _COMMANDBACKEND._serialized_start=1339
- _COMMANDBACKEND._serialized_end=1462
- _COMMANDBACKEND_ENVENTRY._serialized_start=1420
- _COMMANDBACKEND_ENVENTRY._serialized_end=1462
- _REGISTERSERVICEREQUEST._serialized_start=1465
- _REGISTERSERVICEREQUEST._serialized_end=1603
- _DISCOVEREDPROVIDER._serialized_start=1605
- _DISCOVEREDPROVIDER._serialized_end=1710
- _SERVICEANNOUNCE._serialized_start=1713
- _SERVICEANNOUNCE._serialized_end=1987
- _SERVICEANNOUNCE_LABELSENTRY._serialized_start=567
- _SERVICEANNOUNCE_LABELSENTRY._serialized_end=612
- _CONTROLPLANEINFORESPONSE._serialized_start=1990
- _CONTROLPLANEINFORESPONSE._serialized_end=2125
- _ROUTERLEASEREQUEST._serialized_start=2128
- _ROUTERLEASEREQUEST._serialized_end=2292
- _ROUTERLEASERESPONSE._serialized_start=2294
- _ROUTERLEASERESPONSE._serialized_end=2367
- _POLICYROLE._serialized_start=2370
- _POLICYROLE._serialized_end=2519
- _POLICYBINDING._serialized_start=2521
- _POLICYBINDING._serialized_end=2567
- _POLICYCONFIG._serialized_start=2569
- _POLICYCONFIG._serialized_end=2659
- _POLICYCONFIGGETREQUEST._serialized_start=2661
- _POLICYCONFIGGETREQUEST._serialized_end=2685
- _POLICYCONFIGGETRESPONSE._serialized_start=2687
- _POLICYCONFIGGETRESPONSE._serialized_end=2764
- _POLICYCONFIGUPDATERESPONSE._serialized_start=2766
- _POLICYCONFIGUPDATERESPONSE._serialized_end=2826
- _KEYSRESPONSE._serialized_start=2828
- _KEYSRESPONSE._serialized_end=2902
- _TOKENREFRESHREQUEST._serialized_start=2904
- _TOKENREFRESHREQUEST._serialized_end=2990
- _TOKENREFRESHRESPONSE._serialized_start=2992
- _TOKENREFRESHRESPONSE._serialized_end=3080
- _NODECATALOGREPORT._serialized_start=3082
- _NODECATALOGREPORT._serialized_end=3140
- _TOKENREVOKEREQUEST._serialized_start=3142
- _TOKENREVOKEREQUEST._serialized_end=3179
- _TOKENREVOKERESPONSE._serialized_start=3181
- _TOKENREVOKERESPONSE._serialized_end=3234
- _AGENTSECRET._serialized_start=3236
- _AGENTSECRET._serialized_end=3318
- _AGENTEGRESS._serialized_start=3320
- _AGENTEGRESS._serialized_end=3386
- _AGENTINGRESS._serialized_start=3388
- _AGENTINGRESS._serialized_end=3486
- _AGENTBUNDLE._serialized_start=3489
- _AGENTBUNDLE._serialized_end=3659
- _AGENTATTACHREQUEST._serialized_start=3661
- _AGENTATTACHREQUEST._serialized_end=3718
- _AGENTATTACHRESPONSE._serialized_start=3720
- _AGENTATTACHRESPONSE._serialized_end=3803
- _AGENTDETACHREQUEST._serialized_start=3805
- _AGENTDETACHREQUEST._serialized_end=3843
- _AGENTDETACHRESPONSE._serialized_start=3845
- _AGENTDETACHRESPONSE._serialized_end=3898
- _AGENTREFRESHREQUEST._serialized_start=3900
- _AGENTREFRESHREQUEST._serialized_end=3964
- _AGENTREFRESHRESPONSE._serialized_start=3966
- _AGENTREFRESHRESPONSE._serialized_end=4040
- _AGENTSTATUSREQUEST._serialized_start=4042
- _AGENTSTATUSREQUEST._serialized_end=4080
- _AGENTSTATUS._serialized_start=4082
- _AGENTSTATUS._serialized_end=4201
- _AGENTSTATUSRESPONSE._serialized_start=4203
- _AGENTSTATUSRESPONSE._serialized_end=4276
- _IDENTITYEVIDENCERESPONSE._serialized_start=4279
- _IDENTITYEVIDENCERESPONSE._serialized_end=4450
- _PEEREVIDENCERESPONSE._serialized_start=4453
- _PEEREVIDENCERESPONSE._serialized_end=4716
- _PEEREVIDENCERESPONSE_LABELSENTRY._serialized_start=567
- _PEEREVIDENCERESPONSE_LABELSENTRY._serialized_end=612
- _MEMBERCREDENTIAL._serialized_start=4719
- _MEMBERCREDENTIAL._serialized_end=4975
- _TRUSTEDSIGNINGKEY._serialized_start=4977
- _TRUSTEDSIGNINGKEY._serialized_end=5066
- _OIDCSESSION._serialized_start=5068
- _OIDCSESSION._serialized_end=5157
+ _MESHEVENT._serialized_end=403
+ _MESHEVENT_TYPE._serialized_start=348
+ _MESHEVENT_TYPE._serialized_end=403
+ _ENROLLREQUEST._serialized_start=406
+ _ENROLLREQUEST._serialized_end=649
+ _ENROLLREQUEST_LABELSENTRY._serialized_start=604
+ _ENROLLREQUEST_LABELSENTRY._serialized_end=649
+ _ENROLLRESPONSE._serialized_start=652
+ _ENROLLRESPONSE._serialized_end=823
+ _BOOTSTRAPENROLLREQUEST._serialized_start=826
+ _BOOTSTRAPENROLLREQUEST._serialized_end=1099
+ _BOOTSTRAPENROLLREQUEST_LABELSENTRY._serialized_start=604
+ _BOOTSTRAPENROLLREQUEST_LABELSENTRY._serialized_end=649
+ _BOOTSTRAPENROLLRESPONSE._serialized_start=1102
+ _BOOTSTRAPENROLLRESPONSE._serialized_end=1355
+ _SERVICEINFO._serialized_start=1357
+ _SERVICEINFO._serialized_end=1440
+ _COMMANDBACKEND._serialized_start=1442
+ _COMMANDBACKEND._serialized_end=1565
+ _COMMANDBACKEND_ENVENTRY._serialized_start=1523
+ _COMMANDBACKEND_ENVENTRY._serialized_end=1565
+ _REGISTERSERVICEREQUEST._serialized_start=1568
+ _REGISTERSERVICEREQUEST._serialized_end=1706
+ _DISCOVEREDPROVIDER._serialized_start=1708
+ _DISCOVEREDPROVIDER._serialized_end=1813
+ _SERVICEANNOUNCE._serialized_start=1816
+ _SERVICEANNOUNCE._serialized_end=2122
+ _SERVICEANNOUNCE_LABELSENTRY._serialized_start=604
+ _SERVICEANNOUNCE_LABELSENTRY._serialized_end=649
+ _CONTROLPLANEINFORESPONSE._serialized_start=2125
+ _CONTROLPLANEINFORESPONSE._serialized_end=2260
+ _ROUTERLEASEREQUEST._serialized_start=2263
+ _ROUTERLEASEREQUEST._serialized_end=2435
+ _ROUTERLEASERESPONSE._serialized_start=2437
+ _ROUTERLEASERESPONSE._serialized_end=2539
+ _POLICYROLE._serialized_start=2542
+ _POLICYROLE._serialized_end=2691
+ _POLICYBINDING._serialized_start=2693
+ _POLICYBINDING._serialized_end=2739
+ _POLICYCONFIG._serialized_start=2741
+ _POLICYCONFIG._serialized_end=2831
+ _POLICYCONFIGGETREQUEST._serialized_start=2833
+ _POLICYCONFIGGETREQUEST._serialized_end=2857
+ _POLICYCONFIGGETRESPONSE._serialized_start=2859
+ _POLICYCONFIGGETRESPONSE._serialized_end=2936
+ _POLICYCONFIGUPDATERESPONSE._serialized_start=2938
+ _POLICYCONFIGUPDATERESPONSE._serialized_end=2998
+ _KEYSRESPONSE._serialized_start=3000
+ _KEYSRESPONSE._serialized_end=3102
+ _TOKENREFRESHREQUEST._serialized_start=3104
+ _TOKENREFRESHREQUEST._serialized_end=3198
+ _TOKENREFRESHRESPONSE._serialized_start=3200
+ _TOKENREFRESHRESPONSE._serialized_end=3317
+ _NODECATALOGREPORT._serialized_start=3319
+ _NODECATALOGREPORT._serialized_end=3377
+ _TOKENREVOKEREQUEST._serialized_start=3379
+ _TOKENREVOKEREQUEST._serialized_end=3416
+ _TOKENREVOKERESPONSE._serialized_start=3418
+ _TOKENREVOKERESPONSE._serialized_end=3471
+ _AGENTSECRET._serialized_start=3473
+ _AGENTSECRET._serialized_end=3555
+ _AGENTEGRESS._serialized_start=3557
+ _AGENTEGRESS._serialized_end=3623
+ _AGENTINGRESS._serialized_start=3625
+ _AGENTINGRESS._serialized_end=3723
+ _AGENTBUNDLE._serialized_start=3726
+ _AGENTBUNDLE._serialized_end=3896
+ _AGENTATTACHREQUEST._serialized_start=3898
+ _AGENTATTACHREQUEST._serialized_end=3955
+ _AGENTATTACHRESPONSE._serialized_start=3957
+ _AGENTATTACHRESPONSE._serialized_end=4040
+ _AGENTDETACHREQUEST._serialized_start=4042
+ _AGENTDETACHREQUEST._serialized_end=4080
+ _AGENTDETACHRESPONSE._serialized_start=4082
+ _AGENTDETACHRESPONSE._serialized_end=4135
+ _AGENTREFRESHREQUEST._serialized_start=4137
+ _AGENTREFRESHREQUEST._serialized_end=4201
+ _AGENTREFRESHRESPONSE._serialized_start=4203
+ _AGENTREFRESHRESPONSE._serialized_end=4306
+ _AGENTSTATUSREQUEST._serialized_start=4308
+ _AGENTSTATUSREQUEST._serialized_end=4346
+ _AGENTSTATUS._serialized_start=4349
+ _AGENTSTATUS._serialized_end=4497
+ _AGENTSTATUSRESPONSE._serialized_start=4499
+ _AGENTSTATUSRESPONSE._serialized_end=4572
+ _IDENTITYEVIDENCERESPONSE._serialized_start=4575
+ _IDENTITYEVIDENCERESPONSE._serialized_end=4803
+ _PEEREVIDENCERESPONSE._serialized_start=4806
+ _PEEREVIDENCERESPONSE._serialized_end=5126
+ _PEEREVIDENCERESPONSE_LABELSENTRY._serialized_start=604
+ _PEEREVIDENCERESPONSE_LABELSENTRY._serialized_end=649
+ _MEMBERCREDENTIAL._serialized_start=5129
+ _MEMBERCREDENTIAL._serialized_end=5385
+ _TRUSTEDSIGNINGKEY._serialized_start=5387
+ _TRUSTEDSIGNINGKEY._serialized_end=5476
+ _OIDCSESSION._serialized_start=5478
+ _OIDCSESSION._serialized_end=5567
# @@protoc_insertion_point(module_scope)
diff --git a/sdk/python/src/agent_mesh/_proto/sam_pb2.pyi b/sdk/python/src/agent_mesh/_proto/sam_pb2.pyi
index 52c7c1ca..ce8a269b 100644
--- a/sdk/python/src/agent_mesh/_proto/sam_pb2.pyi
+++ b/sdk/python/src/agent_mesh/_proto/sam_pb2.pyi
@@ -90,14 +90,14 @@ class AgentRefreshRequest(_message.Message):
def __init__(self, agent_id: _Optional[str] = ..., credential_path: _Optional[str] = ...) -> None: ...
class AgentRefreshResponse(_message.Message):
- __slots__ = ["error", "expires_at", "success"]
+ __slots__ = ["error", "expire_time", "success"]
ERROR_FIELD_NUMBER: _ClassVar[int]
- EXPIRES_AT_FIELD_NUMBER: _ClassVar[int]
+ EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
SUCCESS_FIELD_NUMBER: _ClassVar[int]
error: str
- expires_at: int
+ expire_time: _timestamp_pb2.Timestamp
success: bool
- def __init__(self, success: bool = ..., error: _Optional[str] = ..., expires_at: _Optional[int] = ...) -> None: ...
+ def __init__(self, success: bool = ..., error: _Optional[str] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class AgentSecret(_message.Message):
__slots__ = ["header_name", "host", "kind", "value_path"]
@@ -112,16 +112,16 @@ class AgentSecret(_message.Message):
def __init__(self, host: _Optional[str] = ..., kind: _Optional[str] = ..., header_name: _Optional[str] = ..., value_path: _Optional[str] = ...) -> None: ...
class AgentStatus(_message.Message):
- __slots__ = ["agent_id", "attached", "credential_expires_at", "ingress"]
+ __slots__ = ["agent_id", "attached", "credential_expire_time", "ingress"]
AGENT_ID_FIELD_NUMBER: _ClassVar[int]
ATTACHED_FIELD_NUMBER: _ClassVar[int]
- CREDENTIAL_EXPIRES_AT_FIELD_NUMBER: _ClassVar[int]
+ CREDENTIAL_EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
INGRESS_FIELD_NUMBER: _ClassVar[int]
agent_id: str
attached: bool
- credential_expires_at: int
+ credential_expire_time: _timestamp_pb2.Timestamp
ingress: _containers.RepeatedCompositeFieldContainer[AgentIngress]
- def __init__(self, agent_id: _Optional[str] = ..., attached: bool = ..., ingress: _Optional[_Iterable[_Union[AgentIngress, _Mapping]]] = ..., credential_expires_at: _Optional[int] = ...) -> None: ...
+ def __init__(self, agent_id: _Optional[str] = ..., attached: bool = ..., ingress: _Optional[_Iterable[_Union[AgentIngress, _Mapping]]] = ..., credential_expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class AgentStatusRequest(_message.Message):
__slots__ = ["agent_id"]
@@ -158,7 +158,7 @@ class AuthResponse(_message.Message):
def __init__(self, success: bool = ..., error: _Optional[str] = ..., biscuit: _Optional[bytes] = ...) -> None: ...
class BootstrapEnrollRequest(_message.Message):
- __slots__ = ["bootstrap_token", "challenge_signature", "labels", "peer_id", "public_key", "requested_role", "timestamp"]
+ __slots__ = ["bootstrap_token", "challenge_signature", "challenge_unix_ms", "labels", "peer_id", "public_key", "requested_role"]
class LabelsEntry(_message.Message):
__slots__ = ["key", "value"]
KEY_FIELD_NUMBER: _ClassVar[int]
@@ -168,37 +168,37 @@ class BootstrapEnrollRequest(_message.Message):
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
BOOTSTRAP_TOKEN_FIELD_NUMBER: _ClassVar[int]
CHALLENGE_SIGNATURE_FIELD_NUMBER: _ClassVar[int]
+ CHALLENGE_UNIX_MS_FIELD_NUMBER: _ClassVar[int]
LABELS_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int]
REQUESTED_ROLE_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
bootstrap_token: str
challenge_signature: bytes
+ challenge_unix_ms: int
labels: _containers.ScalarMap[str, str]
peer_id: str
public_key: bytes
requested_role: str
- timestamp: int
- def __init__(self, bootstrap_token: _Optional[str] = ..., peer_id: _Optional[str] = ..., public_key: _Optional[bytes] = ..., requested_role: _Optional[str] = ..., labels: _Optional[_Mapping[str, str]] = ..., timestamp: _Optional[int] = ..., challenge_signature: _Optional[bytes] = ...) -> None: ...
+ def __init__(self, bootstrap_token: _Optional[str] = ..., peer_id: _Optional[str] = ..., public_key: _Optional[bytes] = ..., requested_role: _Optional[str] = ..., labels: _Optional[_Mapping[str, str]] = ..., challenge_unix_ms: _Optional[int] = ..., challenge_signature: _Optional[bytes] = ...) -> None: ...
class BootstrapEnrollResponse(_message.Message):
- __slots__ = ["biscuit_token", "control_plane_public_key", "error_message", "expiration", "poll_interval_seconds", "router_addresses", "status"]
+ __slots__ = ["biscuit_token", "control_plane_public_key", "error_message", "expire_time", "poll_interval_seconds", "router_addresses", "status"]
BISCUIT_TOKEN_FIELD_NUMBER: _ClassVar[int]
CONTROL_PLANE_PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int]
ERROR_MESSAGE_FIELD_NUMBER: _ClassVar[int]
- EXPIRATION_FIELD_NUMBER: _ClassVar[int]
+ EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
POLL_INTERVAL_SECONDS_FIELD_NUMBER: _ClassVar[int]
ROUTER_ADDRESSES_FIELD_NUMBER: _ClassVar[int]
STATUS_FIELD_NUMBER: _ClassVar[int]
biscuit_token: bytes
control_plane_public_key: bytes
error_message: str
- expiration: int
+ expire_time: _timestamp_pb2.Timestamp
poll_interval_seconds: int
router_addresses: _containers.RepeatedScalarFieldContainer[str]
status: EnrollmentStatus
- def __init__(self, status: _Optional[_Union[EnrollmentStatus, str]] = ..., biscuit_token: _Optional[bytes] = ..., poll_interval_seconds: _Optional[int] = ..., error_message: _Optional[str] = ..., control_plane_public_key: _Optional[bytes] = ..., router_addresses: _Optional[_Iterable[str]] = ..., expiration: _Optional[int] = ...) -> None: ...
+ def __init__(self, status: _Optional[_Union[EnrollmentStatus, str]] = ..., biscuit_token: _Optional[bytes] = ..., poll_interval_seconds: _Optional[int] = ..., error_message: _Optional[str] = ..., control_plane_public_key: _Optional[bytes] = ..., router_addresses: _Optional[_Iterable[str]] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class CommandBackend(_message.Message):
__slots__ = ["command", "env"]
@@ -242,7 +242,7 @@ class DiscoveredProvider(_message.Message):
def __init__(self, peer_id: _Optional[str] = ..., local_proxy_url: _Optional[str] = ..., srv_name: _Optional[str] = ..., srv_description: _Optional[str] = ...) -> None: ...
class EnrollRequest(_message.Message):
- __slots__ = ["challenge_signature", "jwt", "labels", "peer_id", "public_key", "requested_role", "timestamp"]
+ __slots__ = ["challenge_signature", "challenge_unix_ms", "jwt", "labels", "peer_id", "public_key", "requested_role"]
class LabelsEntry(_message.Message):
__slots__ = ["key", "value"]
KEY_FIELD_NUMBER: _ClassVar[int]
@@ -251,60 +251,60 @@ class EnrollRequest(_message.Message):
value: str
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
CHALLENGE_SIGNATURE_FIELD_NUMBER: _ClassVar[int]
+ CHALLENGE_UNIX_MS_FIELD_NUMBER: _ClassVar[int]
JWT_FIELD_NUMBER: _ClassVar[int]
LABELS_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int]
REQUESTED_ROLE_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
challenge_signature: bytes
+ challenge_unix_ms: int
jwt: str
labels: _containers.ScalarMap[str, str]
peer_id: str
public_key: bytes
requested_role: str
- timestamp: int
- def __init__(self, jwt: _Optional[str] = ..., peer_id: _Optional[str] = ..., public_key: _Optional[bytes] = ..., requested_role: _Optional[str] = ..., labels: _Optional[_Mapping[str, str]] = ..., timestamp: _Optional[int] = ..., challenge_signature: _Optional[bytes] = ...) -> None: ...
+ def __init__(self, jwt: _Optional[str] = ..., peer_id: _Optional[str] = ..., public_key: _Optional[bytes] = ..., requested_role: _Optional[str] = ..., labels: _Optional[_Mapping[str, str]] = ..., challenge_unix_ms: _Optional[int] = ..., challenge_signature: _Optional[bytes] = ...) -> None: ...
class EnrollResponse(_message.Message):
- __slots__ = ["biscuit_token", "control_plane_public_key", "error_message", "expiration", "router_addresses"]
+ __slots__ = ["biscuit_token", "control_plane_public_key", "error_message", "expire_time", "router_addresses"]
BISCUIT_TOKEN_FIELD_NUMBER: _ClassVar[int]
CONTROL_PLANE_PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int]
ERROR_MESSAGE_FIELD_NUMBER: _ClassVar[int]
- EXPIRATION_FIELD_NUMBER: _ClassVar[int]
+ EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
ROUTER_ADDRESSES_FIELD_NUMBER: _ClassVar[int]
biscuit_token: bytes
control_plane_public_key: bytes
error_message: str
- expiration: int
+ expire_time: _timestamp_pb2.Timestamp
router_addresses: _containers.RepeatedScalarFieldContainer[str]
- def __init__(self, biscuit_token: _Optional[bytes] = ..., error_message: _Optional[str] = ..., control_plane_public_key: _Optional[bytes] = ..., router_addresses: _Optional[_Iterable[str]] = ..., expiration: _Optional[int] = ...) -> None: ...
+ def __init__(self, biscuit_token: _Optional[bytes] = ..., error_message: _Optional[str] = ..., control_plane_public_key: _Optional[bytes] = ..., router_addresses: _Optional[_Iterable[str]] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class IdentityEvidenceResponse(_message.Message):
- __slots__ = ["biscuit", "biscuit_expires_at", "checked_at", "control_plane_url", "peer_id", "trusted_control_plane_keys"]
- BISCUIT_EXPIRES_AT_FIELD_NUMBER: _ClassVar[int]
+ __slots__ = ["biscuit", "biscuit_expire_time", "check_time", "control_plane_url", "peer_id", "trusted_control_plane_keys"]
+ BISCUIT_EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
BISCUIT_FIELD_NUMBER: _ClassVar[int]
- CHECKED_AT_FIELD_NUMBER: _ClassVar[int]
+ CHECK_TIME_FIELD_NUMBER: _ClassVar[int]
CONTROL_PLANE_URL_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
TRUSTED_CONTROL_PLANE_KEYS_FIELD_NUMBER: _ClassVar[int]
biscuit: bytes
- biscuit_expires_at: int
- checked_at: int
+ biscuit_expire_time: _timestamp_pb2.Timestamp
+ check_time: _timestamp_pb2.Timestamp
control_plane_url: str
peer_id: str
trusted_control_plane_keys: _containers.RepeatedScalarFieldContainer[bytes]
- def __init__(self, peer_id: _Optional[str] = ..., biscuit: _Optional[bytes] = ..., biscuit_expires_at: _Optional[int] = ..., control_plane_url: _Optional[str] = ..., trusted_control_plane_keys: _Optional[_Iterable[bytes]] = ..., checked_at: _Optional[int] = ...) -> None: ...
+ def __init__(self, peer_id: _Optional[str] = ..., biscuit: _Optional[bytes] = ..., biscuit_expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., control_plane_url: _Optional[str] = ..., trusted_control_plane_keys: _Optional[_Iterable[bytes]] = ..., check_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class KeysResponse(_message.Message):
- __slots__ = ["public_keys", "signatures", "timestamp"]
+ __slots__ = ["public_keys", "sign_time", "signatures"]
PUBLIC_KEYS_FIELD_NUMBER: _ClassVar[int]
SIGNATURES_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
+ SIGN_TIME_FIELD_NUMBER: _ClassVar[int]
public_keys: _containers.RepeatedScalarFieldContainer[bytes]
+ sign_time: _timestamp_pb2.Timestamp
signatures: _containers.RepeatedScalarFieldContainer[bytes]
- timestamp: int
- def __init__(self, public_keys: _Optional[_Iterable[bytes]] = ..., timestamp: _Optional[int] = ..., signatures: _Optional[_Iterable[bytes]] = ...) -> None: ...
+ def __init__(self, public_keys: _Optional[_Iterable[bytes]] = ..., sign_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., signatures: _Optional[_Iterable[bytes]] = ...) -> None: ...
class MemberCredential(_message.Message):
__slots__ = ["biscuit", "control_plane_url", "expire_time", "issued_under_keys", "oidc_session", "router_addresses", "trusted_keys"]
@@ -325,23 +325,23 @@ class MemberCredential(_message.Message):
def __init__(self, control_plane_url: _Optional[str] = ..., biscuit: _Optional[bytes] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., trusted_keys: _Optional[_Iterable[_Union[TrustedSigningKey, _Mapping]]] = ..., issued_under_keys: _Optional[_Iterable[bytes]] = ..., router_addresses: _Optional[_Iterable[str]] = ..., oidc_session: _Optional[_Union[OIDCSession, _Mapping]] = ...) -> None: ...
class MeshEvent(_message.Message):
- __slots__ = ["new_public_key", "peer_id", "signature", "timestamp", "type"]
+ __slots__ = ["event_time", "new_public_key", "peer_id", "signature", "type"]
class Type(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []
BANNED: MeshEvent.Type
+ EVENT_TIME_FIELD_NUMBER: _ClassVar[int]
KEY_ROTATION: MeshEvent.Type
NEW_PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
POLICY_UPDATE: MeshEvent.Type
SIGNATURE_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
TYPE_FIELD_NUMBER: _ClassVar[int]
+ event_time: _timestamp_pb2.Timestamp
new_public_key: bytes
peer_id: str
signature: bytes
- timestamp: int
type: MeshEvent.Type
- def __init__(self, type: _Optional[_Union[MeshEvent.Type, str]] = ..., peer_id: _Optional[str] = ..., timestamp: _Optional[int] = ..., new_public_key: _Optional[bytes] = ..., signature: _Optional[bytes] = ...) -> None: ...
+ def __init__(self, type: _Optional[_Union[MeshEvent.Type, str]] = ..., peer_id: _Optional[str] = ..., event_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., new_public_key: _Optional[bytes] = ..., signature: _Optional[bytes] = ...) -> None: ...
class NodeCatalogReport(_message.Message):
__slots__ = ["services"]
@@ -362,7 +362,7 @@ class OIDCSession(_message.Message):
def __init__(self, issuer: _Optional[str] = ..., client_id: _Optional[str] = ..., audience: _Optional[str] = ..., refresh_token: _Optional[str] = ...) -> None: ...
class PeerEvidenceResponse(_message.Message):
- __slots__ = ["biscuit", "checked_at", "expiration", "labels", "peer_id", "revocation_ids", "roles", "verifying_key"]
+ __slots__ = ["biscuit", "check_time", "expire_time", "labels", "peer_id", "revocation_ids", "roles", "verifying_key"]
class LabelsEntry(_message.Message):
__slots__ = ["key", "value"]
KEY_FIELD_NUMBER: _ClassVar[int]
@@ -371,22 +371,22 @@ class PeerEvidenceResponse(_message.Message):
value: str
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
BISCUIT_FIELD_NUMBER: _ClassVar[int]
- CHECKED_AT_FIELD_NUMBER: _ClassVar[int]
- EXPIRATION_FIELD_NUMBER: _ClassVar[int]
+ CHECK_TIME_FIELD_NUMBER: _ClassVar[int]
+ EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
LABELS_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
REVOCATION_IDS_FIELD_NUMBER: _ClassVar[int]
ROLES_FIELD_NUMBER: _ClassVar[int]
VERIFYING_KEY_FIELD_NUMBER: _ClassVar[int]
biscuit: bytes
- checked_at: int
- expiration: int
+ check_time: _timestamp_pb2.Timestamp
+ expire_time: _timestamp_pb2.Timestamp
labels: _containers.ScalarMap[str, str]
peer_id: str
revocation_ids: _containers.RepeatedScalarFieldContainer[str]
roles: _containers.RepeatedScalarFieldContainer[str]
verifying_key: bytes
- def __init__(self, peer_id: _Optional[str] = ..., biscuit: _Optional[bytes] = ..., verifying_key: _Optional[bytes] = ..., roles: _Optional[_Iterable[str]] = ..., labels: _Optional[_Mapping[str, str]] = ..., expiration: _Optional[int] = ..., revocation_ids: _Optional[_Iterable[str]] = ..., checked_at: _Optional[int] = ...) -> None: ...
+ def __init__(self, peer_id: _Optional[str] = ..., biscuit: _Optional[bytes] = ..., verifying_key: _Optional[bytes] = ..., roles: _Optional[_Iterable[str]] = ..., labels: _Optional[_Mapping[str, str]] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., revocation_ids: _Optional[_Iterable[str]] = ..., check_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class PolicyBinding(_message.Message):
__slots__ = ["members", "role"]
@@ -449,35 +449,35 @@ class RegisterServiceRequest(_message.Message):
def __init__(self, service: _Optional[_Union[ServiceInfo, _Mapping]] = ..., target_url: _Optional[str] = ..., command: _Optional[_Union[CommandBackend, _Mapping]] = ...) -> None: ...
class RouterLeaseRequest(_message.Message):
- __slots__ = ["addresses", "biscuit", "challenge_signature", "connected_peers", "dht_size", "peer_id", "timestamp"]
+ __slots__ = ["addresses", "biscuit", "challenge_signature", "challenge_unix_ms", "connected_peers", "dht_size", "peer_id"]
ADDRESSES_FIELD_NUMBER: _ClassVar[int]
BISCUIT_FIELD_NUMBER: _ClassVar[int]
CHALLENGE_SIGNATURE_FIELD_NUMBER: _ClassVar[int]
+ CHALLENGE_UNIX_MS_FIELD_NUMBER: _ClassVar[int]
CONNECTED_PEERS_FIELD_NUMBER: _ClassVar[int]
DHT_SIZE_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
addresses: _containers.RepeatedScalarFieldContainer[str]
biscuit: bytes
challenge_signature: bytes
+ challenge_unix_ms: int
connected_peers: _containers.RepeatedScalarFieldContainer[str]
dht_size: int
peer_id: str
- timestamp: int
- def __init__(self, peer_id: _Optional[str] = ..., addresses: _Optional[_Iterable[str]] = ..., biscuit: _Optional[bytes] = ..., connected_peers: _Optional[_Iterable[str]] = ..., dht_size: _Optional[int] = ..., timestamp: _Optional[int] = ..., challenge_signature: _Optional[bytes] = ...) -> None: ...
+ def __init__(self, peer_id: _Optional[str] = ..., addresses: _Optional[_Iterable[str]] = ..., biscuit: _Optional[bytes] = ..., connected_peers: _Optional[_Iterable[str]] = ..., dht_size: _Optional[int] = ..., challenge_unix_ms: _Optional[int] = ..., challenge_signature: _Optional[bytes] = ...) -> None: ...
class RouterLeaseResponse(_message.Message):
- __slots__ = ["error", "expires_at", "success"]
+ __slots__ = ["error", "expire_time", "success"]
ERROR_FIELD_NUMBER: _ClassVar[int]
- EXPIRES_AT_FIELD_NUMBER: _ClassVar[int]
+ EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
SUCCESS_FIELD_NUMBER: _ClassVar[int]
error: str
- expires_at: int
+ expire_time: _timestamp_pb2.Timestamp
success: bool
- def __init__(self, success: bool = ..., error: _Optional[str] = ..., expires_at: _Optional[int] = ...) -> None: ...
+ def __init__(self, success: bool = ..., error: _Optional[str] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class ServiceAnnounce(_message.Message):
- __slots__ = ["active_requests", "keys", "labels", "latency_ewma_ms", "peer_id", "service_name", "timestamp", "type"]
+ __slots__ = ["active_requests", "announce_time", "keys", "labels", "latency_ewma_ms", "peer_id", "service_name", "type"]
class LabelsEntry(_message.Message):
__slots__ = ["key", "value"]
KEY_FIELD_NUMBER: _ClassVar[int]
@@ -486,22 +486,22 @@ class ServiceAnnounce(_message.Message):
value: str
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
ACTIVE_REQUESTS_FIELD_NUMBER: _ClassVar[int]
+ ANNOUNCE_TIME_FIELD_NUMBER: _ClassVar[int]
KEYS_FIELD_NUMBER: _ClassVar[int]
LABELS_FIELD_NUMBER: _ClassVar[int]
LATENCY_EWMA_MS_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
SERVICE_NAME_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
TYPE_FIELD_NUMBER: _ClassVar[int]
active_requests: int
+ announce_time: _timestamp_pb2.Timestamp
keys: _containers.RepeatedScalarFieldContainer[str]
labels: _containers.ScalarMap[str, str]
latency_ewma_ms: float
peer_id: str
service_name: str
- timestamp: int
type: ServiceType
- def __init__(self, peer_id: _Optional[str] = ..., type: _Optional[_Union[ServiceType, str]] = ..., service_name: _Optional[str] = ..., keys: _Optional[_Iterable[str]] = ..., labels: _Optional[_Mapping[str, str]] = ..., active_requests: _Optional[int] = ..., latency_ewma_ms: _Optional[float] = ..., timestamp: _Optional[int] = ...) -> None: ...
+ def __init__(self, peer_id: _Optional[str] = ..., type: _Optional[_Union[ServiceType, str]] = ..., service_name: _Optional[str] = ..., keys: _Optional[_Iterable[str]] = ..., labels: _Optional[_Mapping[str, str]] = ..., active_requests: _Optional[int] = ..., latency_ewma_ms: _Optional[float] = ..., announce_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ...
class ServiceInfo(_message.Message):
__slots__ = ["description", "name", "type"]
@@ -514,24 +514,24 @@ class ServiceInfo(_message.Message):
def __init__(self, type: _Optional[_Union[ServiceType, str]] = ..., name: _Optional[str] = ..., description: _Optional[str] = ...) -> None: ...
class TokenRefreshRequest(_message.Message):
- __slots__ = ["challenge_signature", "peer_id", "timestamp"]
+ __slots__ = ["challenge_signature", "challenge_unix_ms", "peer_id"]
CHALLENGE_SIGNATURE_FIELD_NUMBER: _ClassVar[int]
+ CHALLENGE_UNIX_MS_FIELD_NUMBER: _ClassVar[int]
PEER_ID_FIELD_NUMBER: _ClassVar[int]
- TIMESTAMP_FIELD_NUMBER: _ClassVar[int]
challenge_signature: bytes
+ challenge_unix_ms: int
peer_id: str
- timestamp: int
- def __init__(self, challenge_signature: _Optional[bytes] = ..., timestamp: _Optional[int] = ..., peer_id: _Optional[str] = ...) -> None: ...
+ def __init__(self, challenge_signature: _Optional[bytes] = ..., challenge_unix_ms: _Optional[int] = ..., peer_id: _Optional[str] = ...) -> None: ...
class TokenRefreshResponse(_message.Message):
- __slots__ = ["biscuit_token", "error_message", "expires_at"]
+ __slots__ = ["biscuit_token", "error_message", "expire_time"]
BISCUIT_TOKEN_FIELD_NUMBER: _ClassVar[int]
ERROR_MESSAGE_FIELD_NUMBER: _ClassVar[int]
- EXPIRES_AT_FIELD_NUMBER: _ClassVar[int]
+ EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int]
biscuit_token: bytes
error_message: str
- expires_at: int
- def __init__(self, biscuit_token: _Optional[bytes] = ..., expires_at: _Optional[int] = ..., error_message: _Optional[str] = ...) -> None: ...
+ expire_time: _timestamp_pb2.Timestamp
+ def __init__(self, biscuit_token: _Optional[bytes] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., error_message: _Optional[str] = ...) -> None: ...
class TokenRevokeRequest(_message.Message):
__slots__ = ["peer_id"]
diff --git a/sdk/python/src/agent_mesh/controlplane.py b/sdk/python/src/agent_mesh/controlplane.py
index 4c504cdb..b9c53a41 100644
--- a/sdk/python/src/agent_mesh/controlplane.py
+++ b/sdk/python/src/agent_mesh/controlplane.py
@@ -27,6 +27,7 @@ import urllib.request
from dataclasses import dataclass, field
from typing import Callable, Mapping, Optional, Sequence
+from google.protobuf.timestamp_pb2 import Timestamp
from google.protobuf.unknown_fields import UnknownFieldSet
from . import challenges
@@ -123,11 +124,14 @@ def verify_keys_response(resp: pb.KeysResponse, trusted: Sequence[bytes], now_ms
if len(resp.signatures) != len(resp.public_keys):
raise ValueError(f"keys response carries {len(resp.signatures)} signatures for {len(resp.public_keys)} keys")
now_ms = int(time.time() * 1000) if now_ms is None else now_ms
- if abs(now_ms - resp.timestamp) > KEYS_RESPONSE_FRESHNESS_MS:
- raise ValueError(f"keys response timestamp {resp.timestamp} is outside the freshness window")
- # Each signature covers the set and the timestamp, deterministically
+ if not resp.HasField("sign_time"):
+ raise ValueError("keys response carries no sign_time")
+ issued_ms = resp.sign_time.ToMilliseconds()
+ if abs(now_ms - issued_ms) > KEYS_RESPONSE_FRESHNESS_MS:
+ raise ValueError(f"keys response sign_time {resp.sign_time.ToJsonString()} is outside the freshness window")
+ # Each signature covers the set and the signing time, deterministically
# encoded with the signatures cleared.
- payload = pb.KeysResponse(public_keys=list(resp.public_keys), timestamp=resp.timestamp).SerializeToString(deterministic=True)
+ payload = pb.KeysResponse(public_keys=list(resp.public_keys), sign_time=resp.sign_time).SerializeToString(deterministic=True)
keys: list[bytes] = []
verified = False
for pub, sig in zip(resp.public_keys, resp.signatures):
@@ -194,7 +198,7 @@ class ControlPlaneClient:
public_key=identity.libp2p_public_key,
requested_role=role,
labels=dict(labels or {}),
- timestamp=ts,
+ challenge_unix_ms=ts,
challenge_signature=identity.sign(challenges.enroll_challenge(identity.peer_id, ts)),
)
resp = pb.BootstrapEnrollResponse.FromString(self._request("POST", "/enroll", req.SerializeToString()))
@@ -237,19 +241,17 @@ class ControlPlaneClient:
public_key=identity.libp2p_public_key,
requested_role=role,
labels=dict(labels or {}),
- timestamp=ts,
+ challenge_unix_ms=ts,
challenge_signature=identity.sign(challenges.register_challenge(identity.peer_id, ts)),
)
resp = pb.EnrollResponse.FromString(self._request("POST", "/register", req.SerializeToString()))
if resp.error_message:
raise EnrollmentRejectedError(f"enrollment failed: {resp.error_message}")
return _checked_enrollment(
- Enrollment(
- biscuit=resp.biscuit_token,
- expiration=resp.expiration,
- control_plane_public_key=resp.control_plane_public_key,
- router_addresses=list(resp.router_addresses),
- )
+ biscuit=resp.biscuit_token,
+ expire_time=resp.expire_time if resp.HasField("expire_time") else None,
+ control_plane_public_key=resp.control_plane_public_key,
+ router_addresses=list(resp.router_addresses),
)
def refresh(self, identity: Identity, biscuit: bytes) -> RefreshResult:
@@ -257,7 +259,7 @@ class ControlPlaneClient:
spent by this call; callers must persist the result before using it."""
ts = _now_ms()
req = pb.TokenRefreshRequest(
- timestamp=ts,
+ challenge_unix_ms=ts,
challenge_signature=identity.sign(challenges.refresh_challenge(identity.peer_id, ts)),
peer_id=identity.peer_id,
)
@@ -272,7 +274,9 @@ class ControlPlaneClient:
raise EnrollmentRejectedError(f"refresh failed: {resp.error_message}")
if not resp.biscuit_token:
raise ValueError("refresh returned an empty biscuit")
- return RefreshResult(biscuit=resp.biscuit_token, expiration=resp.expires_at)
+ if not resp.HasField("expire_time"):
+ raise ValueError("refresh response carries no expire_time")
+ return RefreshResult(biscuit=resp.biscuit_token, expiration=resp.expire_time.ToSeconds())
def policy_rules(self, biscuit: bytes) -> list[str]:
"""GET /policies: the mesh policy as the Datalog rules a provider adds
@@ -316,23 +320,31 @@ def _now_ms() -> int:
def _enrollment_from_bootstrap_response(resp: pb.BootstrapEnrollResponse) -> Enrollment:
if resp.status == pb.ENROLLMENT_STATUS_APPROVED:
return _checked_enrollment(
- Enrollment(
- biscuit=resp.biscuit_token,
- expiration=resp.expiration,
- control_plane_public_key=resp.control_plane_public_key,
- router_addresses=list(resp.router_addresses),
- )
+ biscuit=resp.biscuit_token,
+ expire_time=resp.expire_time if resp.HasField("expire_time") else None,
+ control_plane_public_key=resp.control_plane_public_key,
+ router_addresses=list(resp.router_addresses),
)
if resp.status == pb.ENROLLMENT_STATUS_REJECTED:
raise EnrollmentRejectedError(f"enrollment rejected: {resp.error_message or 'no reason given'}")
raise ValueError(f"unexpected enrollment status {resp.status}: {resp.error_message}")
-def _checked_enrollment(e: Enrollment) -> Enrollment:
- if not e.biscuit:
+def _checked_enrollment(
+ *, biscuit: bytes, expire_time: Optional[Timestamp], control_plane_public_key: bytes, router_addresses: list[str]
+) -> Enrollment:
+ if not biscuit:
raise ValueError("received empty biscuit token")
- if len(e.control_plane_public_key) != PUBLIC_KEY_SIZE:
+ if len(control_plane_public_key) != PUBLIC_KEY_SIZE:
raise ValueError(
- f"received invalid control plane public key size: {len(e.control_plane_public_key)} bytes (expected {PUBLIC_KEY_SIZE})"
+ f"received invalid control plane public key size: {len(control_plane_public_key)} bytes (expected {PUBLIC_KEY_SIZE})"
)
- return e
+ # A biscuit of unknown lifetime cannot be kept fresh; the control plane must say when it expires.
+ if expire_time is None:
+ raise ValueError("enrollment response carries no expire_time")
+ return Enrollment(
+ biscuit=biscuit,
+ expiration=expire_time.ToSeconds(),
+ control_plane_public_key=control_plane_public_key,
+ router_addresses=router_addresses,
+ )
diff --git a/sdk/python/src/agent_mesh/session.py b/sdk/python/src/agent_mesh/session.py
index a3e00579..6d227263 100644
--- a/sdk/python/src/agent_mesh/session.py
+++ b/sdk/python/src/agent_mesh/session.py
@@ -335,7 +335,7 @@ class MeshSession:
continue
if event.type == pb.MeshEvent.BANNED:
# Not persisted: a restarted member picks the ban back up from /info.
- if self.banned.add(event.peer_id, event.timestamp):
+ if self.banned.add(event.peer_id, event.event_time.ToMilliseconds()):
logger.info("peer %s banned by the control plane", event.peer_id)
await self._evict(event.peer_id)
elif event.type == pb.MeshEvent.KEY_ROTATION:
diff --git a/sdk/python/src/agent_mesh/sync.py b/sdk/python/src/agent_mesh/sync.py
index 104ecc2d..70841576 100644
--- a/sdk/python/src/agent_mesh/sync.py
+++ b/sdk/python/src/agent_mesh/sync.py
@@ -85,6 +85,6 @@ def verify_mesh_event(data: bytes, trusted_keys: Sequence[bytes], now_ms: Option
if not any(verify_ed25519(key, payload, signature) for key in trusted_keys):
return None
now_ms = int(time.time() * 1000) if now_ms is None else now_ms
- if abs(now_ms - event.timestamp) > EVENT_FRESHNESS_MS:
+ if not event.HasField("event_time") or abs(now_ms - event.event_time.ToMilliseconds()) > EVENT_FRESHNESS_MS:
return None
return event
diff --git a/sdk/python/tests/test_controlplane.py b/sdk/python/tests/test_controlplane.py
index 530654cb..d38e7eea 100644
--- a/sdk/python/tests/test_controlplane.py
+++ b/sdk/python/tests/test_controlplane.py
@@ -39,6 +39,19 @@ from agent_mesh.controlplane import (
verify_keys_response,
)
from agent_mesh.identity import Identity, verify_ed25519
+from google.protobuf.timestamp_pb2 import Timestamp
+
+
+def _ts_ms(ms: int) -> Timestamp:
+ t = Timestamp()
+ t.FromMilliseconds(int(ms))
+ return t
+
+
+def _ts_s(seconds: int) -> Timestamp:
+ t = Timestamp()
+ t.FromSeconds(int(seconds))
+ return t
CP_KEY = Identity.generate()
BISCUIT = b"not-really-a-biscuit"
@@ -60,9 +73,9 @@ def fake_transport(routes):
def signed_keys(signers, timestamp=None):
"""Signs a KeysResponse the way api.SignKeysResponse does."""
ts = int(time.time() * 1000) if timestamp is None else timestamp
- unsigned = pb.KeysResponse(public_keys=[s.public_key_raw for s in signers], timestamp=ts)
+ unsigned = pb.KeysResponse(public_keys=[s.public_key_raw for s in signers], sign_time=_ts_ms(ts))
payload = unsigned.SerializeToString(deterministic=True)
- return pb.KeysResponse(public_keys=list(unsigned.public_keys), timestamp=ts, signatures=[s.sign(payload) for s in signers])
+ return pb.KeysResponse(public_keys=list(unsigned.public_keys), sign_time=_ts_ms(ts), signatures=[s.sign(payload) for s in signers])
def test_validate_control_plane_url():
@@ -92,8 +105,8 @@ def test_enroll_bootstrap_sends_bound_proof_and_polls_until_approved():
assert r.public_key == identity.libp2p_public_key
assert r.requested_role == ROLE_NODE
assert dict(r.labels) == {"region": "eu"}
- assert abs(r.timestamp - time.time() * 1000) < 5000
- assert verify_ed25519(identity.public_key_raw, challenges.enroll_challenge(r.peer_id, r.timestamp), r.challenge_signature)
+ assert abs(r.challenge_unix_ms - time.time() * 1000) < 5000
+ assert verify_ed25519(identity.public_key_raw, challenges.enroll_challenge(r.peer_id, r.challenge_unix_ms), r.challenge_signature)
seen.append("enroll")
return 200, pb.BootstrapEnrollResponse(status=pb.ENROLLMENT_STATUS_PENDING, poll_interval_seconds=30).SerializeToString()
@@ -110,7 +123,7 @@ def test_enroll_bootstrap_sends_bound_proof_and_polls_until_approved():
biscuit_token=BISCUIT,
control_plane_public_key=CP_KEY.public_key_raw,
router_addresses=router_addrs,
- expiration=1_800_000_000,
+ expire_time=_ts_s(1_800_000_000),
).SerializeToString()
client = ControlPlaneClient("http://127.0.0.1:1", transport=fake_transport({"POST /enroll": enroll, "GET /enroll/status": status}))
@@ -166,8 +179,8 @@ def test_register_carries_jwt_and_register_bound_challenge():
assert r.jwt == "eyJ.fake.jwt"
assert r.peer_id == identity.peer_id
assert r.requested_role == "sam:role:custom"
- assert verify_ed25519(identity.public_key_raw, challenges.register_challenge(r.peer_id, r.timestamp), r.challenge_signature)
- return 200, pb.EnrollResponse(biscuit_token=BISCUIT, control_plane_public_key=CP_KEY.public_key_raw, expiration=7).SerializeToString()
+ assert verify_ed25519(identity.public_key_raw, challenges.register_challenge(r.peer_id, r.challenge_unix_ms), r.challenge_signature)
+ return 200, pb.EnrollResponse(biscuit_token=BISCUIT, control_plane_public_key=CP_KEY.public_key_raw, expire_time=_ts_s(7)).SerializeToString()
e = ControlPlaneClient("http://127.0.0.1:1", transport=fake_transport({"POST /register": register})).register(
identity, "eyJ.fake.jwt", role="sam:role:custom"
@@ -187,8 +200,8 @@ def test_refresh_presents_bearer_biscuit_and_signs_refresh_challenge():
assert headers["Authorization"] == "Bearer " + base64.b64encode(BISCUIT).decode()
r = pb.TokenRefreshRequest.FromString(body)
assert r.peer_id == identity.peer_id
- assert verify_ed25519(identity.public_key_raw, challenges.refresh_challenge(identity.peer_id, r.timestamp), r.challenge_signature)
- return 200, pb.TokenRefreshResponse(biscuit_token=b"fresher-biscuit", expires_at=99).SerializeToString()
+ assert verify_ed25519(identity.public_key_raw, challenges.refresh_challenge(identity.peer_id, r.challenge_unix_ms), r.challenge_signature)
+ return 200, pb.TokenRefreshResponse(biscuit_token=b"fresher-biscuit", expire_time=_ts_s(99)).SerializeToString()
result = ControlPlaneClient("http://127.0.0.1:1", transport=fake_transport({"POST /refresh": refresh})).refresh(identity, BISCUIT)
assert result.biscuit == b"fresher-biscuit"
@@ -213,13 +226,13 @@ def test_verify_keys_response_accepts_only_a_set_vouched_for_by_a_trusted_key():
with pytest.raises(ValueError, match="not signed by any trusted"):
verify_keys_response(resp, [Identity.generate().public_key_raw])
with pytest.raises(ValueError, match="freshness window"):
- verify_keys_response(resp, [CP_KEY.public_key_raw], now_ms=resp.timestamp + KEYS_RESPONSE_FRESHNESS_MS + 1000)
+ verify_keys_response(resp, [CP_KEY.public_key_raw], now_ms=resp.sign_time.ToMilliseconds() + KEYS_RESPONSE_FRESHNESS_MS + 1000)
- forged = pb.KeysResponse(public_keys=[Identity.generate().public_key_raw, retiring.public_key_raw], timestamp=resp.timestamp, signatures=list(resp.signatures))
+ forged = pb.KeysResponse(public_keys=[Identity.generate().public_key_raw, retiring.public_key_raw], sign_time=resp.sign_time, signatures=list(resp.signatures))
with pytest.raises(ValueError, match="not signed by any trusted"):
verify_keys_response(forged, [retiring.public_key_raw])
- unsigned = pb.KeysResponse(public_keys=list(resp.public_keys), timestamp=resp.timestamp)
+ unsigned = pb.KeysResponse(public_keys=list(resp.public_keys), sign_time=resp.sign_time)
with pytest.raises(ValueError, match="carries 0 signatures for 2 keys"):
verify_keys_response(unsigned, [CP_KEY.public_key_raw])
diff --git a/sdk/python/tests/test_mesh.py b/sdk/python/tests/test_mesh.py
index a19bc29c..ead4917d 100644
--- a/sdk/python/tests/test_mesh.py
+++ b/sdk/python/tests/test_mesh.py
@@ -24,6 +24,19 @@ from agent_mesh._proto import sam_pb2 as pb
from agent_mesh.credential import decode_auth_response
from agent_mesh.identity import Identity
from agent_mesh.mesh import AgentMesh
+from google.protobuf.timestamp_pb2 import Timestamp
+
+
+def _ts_ms(ms: int) -> Timestamp:
+ t = Timestamp()
+ t.FromMilliseconds(int(ms))
+ return t
+
+
+def _ts_s(seconds: int) -> Timestamp:
+ t = Timestamp()
+ t.FromSeconds(int(seconds))
+ return t
CP_KEY = Identity.generate()
@@ -37,8 +50,8 @@ class FakeControlPlane:
def _signed_keys(self):
ts = int(time.time() * 1000)
- unsigned = pb.KeysResponse(public_keys=[CP_KEY.public_key_raw], timestamp=ts)
- return pb.KeysResponse(public_keys=[CP_KEY.public_key_raw], timestamp=ts, signatures=[CP_KEY.sign(unsigned.SerializeToString(deterministic=True))])
+ unsigned = pb.KeysResponse(public_keys=[CP_KEY.public_key_raw], sign_time=_ts_ms(ts))
+ return pb.KeysResponse(public_keys=[CP_KEY.public_key_raw], sign_time=_ts_ms(ts), signatures=[CP_KEY.sign(unsigned.SerializeToString(deterministic=True))])
def transport(self, method, url, headers, body):
path = urllib.parse.urlsplit(url).path
@@ -49,11 +62,11 @@ class FakeControlPlane:
biscuit_token=f"biscuit-{self.issued}".encode(),
control_plane_public_key=CP_KEY.public_key_raw,
router_addresses=["/dns4/router.example/tcp/4001/p2p/12D3KooWP8iKhDf3iCMo2H3butNVfdTUtYwYWYQ75jTGnynXPFMp"],
- expiration=int(time.time()) + 3600,
+ expire_time=_ts_s(int(time.time()) + 3600),
).SerializeToString()
if (method, path) == ("POST", "/refresh"):
self.issued += 1
- return 200, pb.TokenRefreshResponse(biscuit_token=f"biscuit-{self.issued}".encode(), expires_at=int(time.time()) + 7200).SerializeToString()
+ return 200, pb.TokenRefreshResponse(biscuit_token=f"biscuit-{self.issued}".encode(), expire_time=_ts_s(int(time.time()) + 7200)).SerializeToString()
if (method, path) == ("GET", "/keys"):
return (200, self._signed_keys().SerializeToString()) if self.keys_ok else (500, b"boom")
return 404, f"no route for {method} {path}".encode()
diff --git a/sdk/python/tests/test_session.py b/sdk/python/tests/test_session.py
index 9308bfc9..a334164c 100644
--- a/sdk/python/tests/test_session.py
+++ b/sdk/python/tests/test_session.py
@@ -42,6 +42,19 @@ from agent_mesh.controlplane import ROLE_NODE
from agent_mesh.identity import Identity
from agent_mesh.mesh import AgentMesh
from agent_mesh.relay import HOP_PROTOCOL as RELAY_HOP_PROTOCOL
+from google.protobuf.timestamp_pb2 import Timestamp
+
+
+def _ts_ms(ms: int) -> Timestamp:
+ t = Timestamp()
+ t.FromMilliseconds(int(ms))
+ return t
+
+
+def _ts_s(seconds: int) -> Timestamp:
+ t = Timestamp()
+ t.FromSeconds(int(seconds))
+ return t
CP = ba.KeyPair()
CP_KEY = CP.public_key.to_bytes()
@@ -65,11 +78,11 @@ def fake_control_plane(router_addresses):
biscuit_token=mint(req.peer_id, ROLE_NODE),
control_plane_public_key=CP_KEY,
router_addresses=router_addresses,
- expiration=int(time.time()) + 3600,
+ expire_time=_ts_s(int(time.time()) + 3600),
).SerializeToString()
if (method, path) == ("GET", "/keys"):
# Unsigned: the client keeps the enrollment key when /keys cannot be verified.
- return 200, pb.KeysResponse(public_keys=[CP_KEY], timestamp=int(time.time() * 1000)).SerializeToString()
+ return 200, pb.KeysResponse(public_keys=[CP_KEY], sign_time=_ts_ms(int(time.time() * 1000))).SerializeToString()
return 404, f"no route for {method} {path}".encode()
return transport
diff --git a/sdk/python/tests/test_sync.py b/sdk/python/tests/test_sync.py
index e33ce4d7..bcf46907 100644
--- a/sdk/python/tests/test_sync.py
+++ b/sdk/python/tests/test_sync.py
@@ -38,6 +38,19 @@ from agent_mesh.relay import HOP_PROTOCOL as RELAY_HOP_PROTOCOL
from agent_mesh.sync import EVENT_FRESHNESS_MS, BanSet, verify_mesh_event
from .test_session import hop_handler, libp2p_host
+from google.protobuf.timestamp_pb2 import Timestamp
+
+
+def _ts_ms(ms: int) -> Timestamp:
+ t = Timestamp()
+ t.FromMilliseconds(int(ms))
+ return t
+
+
+def _ts_s(seconds: int) -> Timestamp:
+ t = Timestamp()
+ t.FromSeconds(int(seconds))
+ return t
class SigningKey:
@@ -77,12 +90,12 @@ class FakeControlPlane:
biscuit_token=self.current.mint(req.peer_id, ROLE_NODE),
control_plane_public_key=self.current.pub,
router_addresses=[self.router_addr],
- expiration=int(time.time()) + 3600,
+ expire_time=_ts_s(int(time.time()) + 3600),
).SerializeToString()
if (method, path) == ("GET", "/keys"):
- unsigned = pb.KeysResponse(public_keys=[k.pub for k in self.keys], timestamp=int(time.time() * 1000))
+ unsigned = pb.KeysResponse(public_keys=[k.pub for k in self.keys], sign_time=_ts_ms(int(time.time() * 1000)))
payload = unsigned.SerializeToString(deterministic=True)
- return 200, pb.KeysResponse(public_keys=[k.pub for k in self.keys], timestamp=unsigned.timestamp, signatures=[k.identity.sign(payload) for k in self.keys]).SerializeToString()
+ return 200, pb.KeysResponse(public_keys=[k.pub for k in self.keys], sign_time=unsigned.sign_time, signatures=[k.identity.sign(payload) for k in self.keys]).SerializeToString()
if (method, path) == ("GET", "/info"):
return 200, pb.ControlPlaneInfoResponse(router_addresses=[self.router_addr], banned_peer_ids=self.banned).SerializeToString()
if (method, path) == ("POST", "/refresh"):
@@ -93,7 +106,7 @@ class FakeControlPlane:
verified = verify_peer_biscuit_any(presented, key.pub)
except Exception: # noqa: BLE001 - try the next key
continue
- return 200, pb.TokenRefreshResponse(biscuit_token=self.current.mint(verified, ROLE_NODE), expires_at=int(time.time()) + 7200).SerializeToString()
+ return 200, pb.TokenRefreshResponse(biscuit_token=self.current.mint(verified, ROLE_NODE), expire_time=_ts_s(int(time.time()) + 7200)).SerializeToString()
return 401, b"unverifiable biscuit"
return 404, f"no route for {method} {path}".encode()
@@ -151,13 +164,13 @@ def test_mesh_event_verifies_only_under_a_trusted_key_and_only_when_fresh():
return event.SerializeToString(deterministic=True)
now_ms = int(time.time() * 1000)
- banned = sign(pb.MeshEvent(type=pb.MeshEvent.BANNED, peer_id="12D3KooWx", timestamp=now_ms))
+ banned = sign(pb.MeshEvent(type=pb.MeshEvent.BANNED, peer_id="12D3KooWx", event_time=_ts_ms(now_ms)))
assert verify_mesh_event(banned, [key.pub], now_ms).peer_id == "12D3KooWx"
assert verify_mesh_event(banned, [SigningKey().pub], now_ms) is None
tampered = bytearray(banned)
tampered[-1] ^= 1
assert verify_mesh_event(bytes(tampered), [key.pub], now_ms) is None
- stale = sign(pb.MeshEvent(type=pb.MeshEvent.BANNED, peer_id="12D3KooWx", timestamp=now_ms - EVENT_FRESHNESS_MS - 1))
+ stale = sign(pb.MeshEvent(type=pb.MeshEvent.BANNED, peer_id="12D3KooWx", event_time=_ts_ms(now_ms - EVENT_FRESHNESS_MS - 1)))
assert verify_mesh_event(stale, [key.pub], now_ms) is None
assert verify_mesh_event(b"\x01\x02\x03", [key.pub], now_ms) is None
diff --git a/site/content/docs/reference/control-plane.md b/site/content/docs/reference/control-plane.md
index 0f517032..d2da9b0f 100644
--- a/site/content/docs/reference/control-plane.md
+++ b/site/content/docs/reference/control-plane.md
@@ -61,10 +61,12 @@ Responses that carry credentials are sent with `Cache-Control: no-store`.
### Enrollment and refresh
-Every request below carries a `timestamp` and a `challenge_signature`. The
-enrollee signs `sam:<endpoint>:<peer_id>:<unix-millis>` with its key, and the
-control plane accepts the signature within five minutes. This proves that the
-caller holds the key behind the peer ID it names.
+Every request below carries a `challenge_unix_ms` and a `challenge_signature`.
+The enrollee signs `sam:<endpoint>:<peer_id>:<challenge_unix_ms>` with its
+key, and the control plane accepts the signature within five minutes of that
+instant. This proves that the caller holds the key behind the peer ID it
+names. Every instant in a response (`expire_time` and the like) is a
+`google.protobuf.Timestamp`, an RFC 3339 string in JSON.
| Route | Body | Purpose |
|---|---|---|
diff --git a/tests/integration/biscuit_expiry_test.go b/tests/integration/biscuit_expiry_test.go
index 6af4a691..4c853149 100644
--- a/tests/integration/biscuit_expiry_test.go
+++ b/tests/integration/biscuit_expiry_test.go
@@ -54,7 +54,7 @@ const expiryMargin = 2 * time.Second
// expiration check reads.
//
// It also pins the second half of the fix: the biscuit's lifetime is the
-// admin-configured --biscuit-ttl, and EnrollResponse.Expiration (which drives
+// admin-configured --biscuit-ttl, and EnrollResponse.expire_time (which drives
// the node's proactive refresh) reports that same instant rather than the OIDC
// token's own, much later, expiry.
func TestBiscuitExpiryIsEnforcedOnEveryPath(t *testing.T) {
@@ -110,9 +110,9 @@ func TestBiscuitExpiryIsEnforcedOnEveryPath(t *testing.T) {
cpPubKey := ed25519.PublicKey(enrollResp.ControlPlanePublicKey)
// The advertised expiration is the biscuit's, not the OIDC token's (1h).
- reported := time.Unix(enrollResp.Expiration, 0)
+ reported := enrollResp.GetExpireTime().AsTime()
if skew := reported.Sub(mintedAt.Add(testBiscuitTTL)); skew < -2*time.Second || skew > 2*time.Second {
- t.Errorf("EnrollResponse.Expiration is %v, want ~%v (--biscuit-ttl %v after minting)",
+ t.Errorf("EnrollResponse.expire_time is %v, want ~%v (--biscuit-ttl %v after minting)",
reported, mintedAt.Add(testBiscuitTTL), testBiscuitTTL)
}
@@ -170,7 +170,7 @@ func registerOnControlPlane(t *testing.T, cpPort int, clientID peer.ID, privKey
PeerId: clientID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
if err != nil {
diff --git a/tests/integration/identity_evidence_test.go b/tests/integration/identity_evidence_test.go
index af0d22db..efa27c8c 100644
--- a/tests/integration/identity_evidence_test.go
+++ b/tests/integration/identity_evidence_test.go
@@ -95,7 +95,7 @@ func TestIdentityEvidenceOperatorFlow(t *testing.T) {
func verifyIdentityEvidence(t *testing.T, controlPlaneURL string, pinnedControlPlaneKey ed25519.PublicKey, expectedProvider peer.ID, local *api.IdentityEvidenceResponse, remote *api.PeerEvidenceResponse) {
t.Helper()
- if local.ControlPlaneUrl != controlPlaneURL || len(local.Biscuit) == 0 || local.CheckedAt <= 0 || local.BiscuitExpiresAt < local.CheckedAt {
+ if local.ControlPlaneUrl != controlPlaneURL || len(local.Biscuit) == 0 || local.CheckTime == nil || local.BiscuitExpireTime == nil || local.BiscuitExpireTime.AsTime().Before(local.CheckTime.AsTime()) {
t.Fatalf("invalid local identity evidence: %+v", local)
}
localPeer, err := peer.Decode(local.PeerId)
@@ -110,7 +110,7 @@ func verifyIdentityEvidence(t *testing.T, controlPlaneURL string, pinnedControlP
t.Fatalf("third-party verification of local Biscuit failed: %v", err)
}
- if remote.PeerId != expectedProvider.String() || len(remote.Biscuit) == 0 || len(remote.VerifyingKey) == 0 || remote.CheckedAt <= 0 || remote.Expiration < remote.CheckedAt || len(remote.RevocationIds) == 0 {
+ if remote.PeerId != expectedProvider.String() || len(remote.Biscuit) == 0 || len(remote.VerifyingKey) == 0 || remote.CheckTime == nil || remote.ExpireTime == nil || remote.ExpireTime.AsTime().Before(remote.CheckTime.AsTime()) || len(remote.RevocationIds) == 0 {
t.Fatalf("invalid remote identity evidence: %+v", remote)
}
if len(remote.Roles) != 1 || remote.Roles[0] != api.RoleNode || len(remote.Labels) != 0 {
diff --git a/tests/integration/multimaster_test.go b/tests/integration/multimaster_test.go
index 572d3270..8901af74 100644
--- a/tests/integration/multimaster_test.go
+++ b/tests/integration/multimaster_test.go
@@ -295,7 +295,7 @@ func enrollClientOnControlPlane(t *testing.T, cpPort int, clientID peer.ID, priv
PeerId: clientID.String(),
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
}
reqBytes, err := proto.Marshal(req)
diff --git a/tests/integration/policy_grants_test.go b/tests/integration/policy_grants_test.go
index fe4d9367..e18077f2 100644
--- a/tests/integration/policy_grants_test.go
+++ b/tests/integration/policy_grants_test.go
@@ -182,7 +182,7 @@ func TestPolicyGrantsReachTheMintedToken(t *testing.T) {
PublicKey: pubBytes,
RequestedRole: api.RoleNode,
Labels: labels,
- Timestamp: ts,
+ ChallengeUnixMs: ts,
ChallengeSignature: sig,
})
if err != nil {
diff --git a/tests/integration/revocation_test.go b/tests/integration/revocation_test.go
index 3767843b..9ab46f79 100644
--- a/tests/integration/revocation_test.go
+++ b/tests/integration/revocation_test.go
@@ -32,6 +32,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func TestNodeRevocationIntegration(t *testing.T) {
@@ -198,7 +199,7 @@ roles:
event := &api.MeshEvent{
Type: api.MeshEvent_BANNED,
PeerId: node2PeerID,
- Timestamp: time.Now().UnixMilli(),
+ EventTime: timestamppb.Now(),
}
eventData, err := proto.Marshal(event)
if err != nil {