Skip to content

Agent Mesh

fix: define the node catalog report in sam.proto and harden the endpoint

Antonio Ojeaa4ec630fbe10
diff --git a/api/sam.pb.go b/api/sam.pb.go
index 65101f11..0845d1d7 100644
--- a/api/sam.pb.go
+++ b/api/sam.pb.go
@@ -1835,6 +1835,54 @@ func (x *TokenRefreshResponse) GetErrorMessage() string {
return ""
}
+// NodeCatalogReport is the body of POST /nodes/catalog: a node's
+// self-reported list of locally registered services. The reporting peer is
+// taken from the presented biscuit, never from the body, so a node can only
+// ever describe itself. Display-only; carries no authorization weight.
+type NodeCatalogReport struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Services []*ServiceInfo `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *NodeCatalogReport) Reset() {
+ *x = NodeCatalogReport{}
+ mi := &file_api_sam_proto_msgTypes[24]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *NodeCatalogReport) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*NodeCatalogReport) ProtoMessage() {}
+
+func (x *NodeCatalogReport) ProtoReflect() protoreflect.Message {
+ mi := &file_api_sam_proto_msgTypes[24]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use NodeCatalogReport.ProtoReflect.Descriptor instead.
+func (*NodeCatalogReport) Descriptor() ([]byte, []int) {
+ return file_api_sam_proto_rawDescGZIP(), []int{24}
+}
+
+func (x *NodeCatalogReport) GetServices() []*ServiceInfo {
+ if x != nil {
+ return x.Services
+ }
+ return nil
+}
+
type TokenRevokeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
PeerId string `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"`
@@ -1844,7 +1892,7 @@ type TokenRevokeRequest struct {
func (x *TokenRevokeRequest) Reset() {
*x = TokenRevokeRequest{}
- mi := &file_api_sam_proto_msgTypes[24]
+ mi := &file_api_sam_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1856,7 +1904,7 @@ func (x *TokenRevokeRequest) String() string {
func (*TokenRevokeRequest) ProtoMessage() {}
func (x *TokenRevokeRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[24]
+ mi := &file_api_sam_proto_msgTypes[25]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1869,7 +1917,7 @@ func (x *TokenRevokeRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use TokenRevokeRequest.ProtoReflect.Descriptor instead.
func (*TokenRevokeRequest) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{24}
+ return file_api_sam_proto_rawDescGZIP(), []int{25}
}
func (x *TokenRevokeRequest) GetPeerId() string {
@@ -1889,7 +1937,7 @@ type TokenRevokeResponse struct {
func (x *TokenRevokeResponse) Reset() {
*x = TokenRevokeResponse{}
- mi := &file_api_sam_proto_msgTypes[25]
+ mi := &file_api_sam_proto_msgTypes[26]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1901,7 +1949,7 @@ func (x *TokenRevokeResponse) String() string {
func (*TokenRevokeResponse) ProtoMessage() {}
func (x *TokenRevokeResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[25]
+ mi := &file_api_sam_proto_msgTypes[26]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1914,7 +1962,7 @@ func (x *TokenRevokeResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use TokenRevokeResponse.ProtoReflect.Descriptor instead.
func (*TokenRevokeResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{25}
+ return file_api_sam_proto_rawDescGZIP(), []int{26}
}
func (x *TokenRevokeResponse) GetSuccess() bool {
@@ -1945,7 +1993,7 @@ type AgentSecret struct {
func (x *AgentSecret) Reset() {
*x = AgentSecret{}
- mi := &file_api_sam_proto_msgTypes[26]
+ mi := &file_api_sam_proto_msgTypes[27]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1957,7 +2005,7 @@ func (x *AgentSecret) String() string {
func (*AgentSecret) ProtoMessage() {}
func (x *AgentSecret) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[26]
+ mi := &file_api_sam_proto_msgTypes[27]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1970,7 +2018,7 @@ func (x *AgentSecret) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentSecret.ProtoReflect.Descriptor instead.
func (*AgentSecret) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{26}
+ return file_api_sam_proto_rawDescGZIP(), []int{27}
}
func (x *AgentSecret) GetHost() string {
@@ -2013,7 +2061,7 @@ type AgentEgress struct {
func (x *AgentEgress) Reset() {
*x = AgentEgress{}
- mi := &file_api_sam_proto_msgTypes[27]
+ mi := &file_api_sam_proto_msgTypes[28]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2025,7 +2073,7 @@ func (x *AgentEgress) String() string {
func (*AgentEgress) ProtoMessage() {}
func (x *AgentEgress) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[27]
+ mi := &file_api_sam_proto_msgTypes[28]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2038,7 +2086,7 @@ func (x *AgentEgress) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentEgress.ProtoReflect.Descriptor instead.
func (*AgentEgress) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{27}
+ return file_api_sam_proto_rawDescGZIP(), []int{28}
}
func (x *AgentEgress) GetAllow() []string {
@@ -2070,7 +2118,7 @@ type AgentIngress struct {
func (x *AgentIngress) Reset() {
*x = AgentIngress{}
- mi := &file_api_sam_proto_msgTypes[28]
+ mi := &file_api_sam_proto_msgTypes[29]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2082,7 +2130,7 @@ func (x *AgentIngress) String() string {
func (*AgentIngress) ProtoMessage() {}
func (x *AgentIngress) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[28]
+ mi := &file_api_sam_proto_msgTypes[29]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2095,7 +2143,7 @@ func (x *AgentIngress) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentIngress.ProtoReflect.Descriptor instead.
func (*AgentIngress) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{28}
+ return file_api_sam_proto_rawDescGZIP(), []int{29}
}
func (x *AgentIngress) GetType() ServiceType {
@@ -2153,7 +2201,7 @@ type AgentBundle struct {
func (x *AgentBundle) Reset() {
*x = AgentBundle{}
- mi := &file_api_sam_proto_msgTypes[29]
+ mi := &file_api_sam_proto_msgTypes[30]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2165,7 +2213,7 @@ func (x *AgentBundle) String() string {
func (*AgentBundle) ProtoMessage() {}
func (x *AgentBundle) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[29]
+ mi := &file_api_sam_proto_msgTypes[30]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2178,7 +2226,7 @@ func (x *AgentBundle) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentBundle.ProtoReflect.Descriptor instead.
func (*AgentBundle) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{29}
+ return file_api_sam_proto_rawDescGZIP(), []int{30}
}
func (x *AgentBundle) GetVersion() string {
@@ -2234,7 +2282,7 @@ type AgentAttachRequest struct {
func (x *AgentAttachRequest) Reset() {
*x = AgentAttachRequest{}
- mi := &file_api_sam_proto_msgTypes[30]
+ mi := &file_api_sam_proto_msgTypes[31]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2246,7 +2294,7 @@ func (x *AgentAttachRequest) String() string {
func (*AgentAttachRequest) ProtoMessage() {}
func (x *AgentAttachRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[30]
+ mi := &file_api_sam_proto_msgTypes[31]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2259,7 +2307,7 @@ func (x *AgentAttachRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentAttachRequest.ProtoReflect.Descriptor instead.
func (*AgentAttachRequest) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{30}
+ return file_api_sam_proto_rawDescGZIP(), []int{31}
}
func (x *AgentAttachRequest) GetBundle() *AgentBundle {
@@ -2283,7 +2331,7 @@ type AgentAttachResponse struct {
func (x *AgentAttachResponse) Reset() {
*x = AgentAttachResponse{}
- mi := &file_api_sam_proto_msgTypes[31]
+ mi := &file_api_sam_proto_msgTypes[32]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2295,7 +2343,7 @@ func (x *AgentAttachResponse) String() string {
func (*AgentAttachResponse) ProtoMessage() {}
func (x *AgentAttachResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[31]
+ mi := &file_api_sam_proto_msgTypes[32]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2308,7 +2356,7 @@ func (x *AgentAttachResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentAttachResponse.ProtoReflect.Descriptor instead.
func (*AgentAttachResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{31}
+ return file_api_sam_proto_rawDescGZIP(), []int{32}
}
func (x *AgentAttachResponse) GetEgressSocket() string {
@@ -2343,7 +2391,7 @@ type AgentDetachRequest struct {
func (x *AgentDetachRequest) Reset() {
*x = AgentDetachRequest{}
- mi := &file_api_sam_proto_msgTypes[32]
+ mi := &file_api_sam_proto_msgTypes[33]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2355,7 +2403,7 @@ func (x *AgentDetachRequest) String() string {
func (*AgentDetachRequest) ProtoMessage() {}
func (x *AgentDetachRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[32]
+ mi := &file_api_sam_proto_msgTypes[33]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2368,7 +2416,7 @@ func (x *AgentDetachRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentDetachRequest.ProtoReflect.Descriptor instead.
func (*AgentDetachRequest) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{32}
+ return file_api_sam_proto_rawDescGZIP(), []int{33}
}
func (x *AgentDetachRequest) GetAgentId() string {
@@ -2388,7 +2436,7 @@ type AgentDetachResponse struct {
func (x *AgentDetachResponse) Reset() {
*x = AgentDetachResponse{}
- mi := &file_api_sam_proto_msgTypes[33]
+ mi := &file_api_sam_proto_msgTypes[34]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2400,7 +2448,7 @@ func (x *AgentDetachResponse) String() string {
func (*AgentDetachResponse) ProtoMessage() {}
func (x *AgentDetachResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[33]
+ mi := &file_api_sam_proto_msgTypes[34]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2413,7 +2461,7 @@ func (x *AgentDetachResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentDetachResponse.ProtoReflect.Descriptor instead.
func (*AgentDetachResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{33}
+ return file_api_sam_proto_rawDescGZIP(), []int{34}
}
func (x *AgentDetachResponse) GetSuccess() bool {
@@ -2443,7 +2491,7 @@ type AgentRefreshRequest struct {
func (x *AgentRefreshRequest) Reset() {
*x = AgentRefreshRequest{}
- mi := &file_api_sam_proto_msgTypes[34]
+ mi := &file_api_sam_proto_msgTypes[35]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2455,7 +2503,7 @@ func (x *AgentRefreshRequest) String() string {
func (*AgentRefreshRequest) ProtoMessage() {}
func (x *AgentRefreshRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[34]
+ mi := &file_api_sam_proto_msgTypes[35]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2468,7 +2516,7 @@ func (x *AgentRefreshRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentRefreshRequest.ProtoReflect.Descriptor instead.
func (*AgentRefreshRequest) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{34}
+ return file_api_sam_proto_rawDescGZIP(), []int{35}
}
func (x *AgentRefreshRequest) GetAgentId() string {
@@ -2496,7 +2544,7 @@ type AgentRefreshResponse struct {
func (x *AgentRefreshResponse) Reset() {
*x = AgentRefreshResponse{}
- mi := &file_api_sam_proto_msgTypes[35]
+ mi := &file_api_sam_proto_msgTypes[36]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2508,7 +2556,7 @@ func (x *AgentRefreshResponse) String() string {
func (*AgentRefreshResponse) ProtoMessage() {}
func (x *AgentRefreshResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[35]
+ mi := &file_api_sam_proto_msgTypes[36]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2521,7 +2569,7 @@ func (x *AgentRefreshResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentRefreshResponse.ProtoReflect.Descriptor instead.
func (*AgentRefreshResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{35}
+ return file_api_sam_proto_rawDescGZIP(), []int{36}
}
func (x *AgentRefreshResponse) GetSuccess() bool {
@@ -2556,7 +2604,7 @@ type AgentStatusRequest struct {
func (x *AgentStatusRequest) Reset() {
*x = AgentStatusRequest{}
- mi := &file_api_sam_proto_msgTypes[36]
+ mi := &file_api_sam_proto_msgTypes[37]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2568,7 +2616,7 @@ func (x *AgentStatusRequest) String() string {
func (*AgentStatusRequest) ProtoMessage() {}
func (x *AgentStatusRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[36]
+ mi := &file_api_sam_proto_msgTypes[37]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2581,7 +2629,7 @@ func (x *AgentStatusRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentStatusRequest.ProtoReflect.Descriptor instead.
func (*AgentStatusRequest) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{36}
+ return file_api_sam_proto_rawDescGZIP(), []int{37}
}
func (x *AgentStatusRequest) GetAgentId() string {
@@ -2603,7 +2651,7 @@ type AgentStatus struct {
func (x *AgentStatus) Reset() {
*x = AgentStatus{}
- mi := &file_api_sam_proto_msgTypes[37]
+ mi := &file_api_sam_proto_msgTypes[38]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2615,7 +2663,7 @@ func (x *AgentStatus) String() string {
func (*AgentStatus) ProtoMessage() {}
func (x *AgentStatus) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[37]
+ mi := &file_api_sam_proto_msgTypes[38]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2628,7 +2676,7 @@ func (x *AgentStatus) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentStatus.ProtoReflect.Descriptor instead.
func (*AgentStatus) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{37}
+ return file_api_sam_proto_rawDescGZIP(), []int{38}
}
func (x *AgentStatus) GetAgentId() string {
@@ -2669,7 +2717,7 @@ type AgentStatusResponse struct {
func (x *AgentStatusResponse) Reset() {
*x = AgentStatusResponse{}
- mi := &file_api_sam_proto_msgTypes[38]
+ mi := &file_api_sam_proto_msgTypes[39]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2681,7 +2729,7 @@ func (x *AgentStatusResponse) String() string {
func (*AgentStatusResponse) ProtoMessage() {}
func (x *AgentStatusResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[38]
+ mi := &file_api_sam_proto_msgTypes[39]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2694,7 +2742,7 @@ func (x *AgentStatusResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use AgentStatusResponse.ProtoReflect.Descriptor instead.
func (*AgentStatusResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{38}
+ return file_api_sam_proto_rawDescGZIP(), []int{39}
}
func (x *AgentStatusResponse) GetAgents() []*AgentStatus {
@@ -2725,7 +2773,7 @@ type IdentityEvidenceResponse struct {
func (x *IdentityEvidenceResponse) Reset() {
*x = IdentityEvidenceResponse{}
- mi := &file_api_sam_proto_msgTypes[39]
+ mi := &file_api_sam_proto_msgTypes[40]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2737,7 +2785,7 @@ func (x *IdentityEvidenceResponse) String() string {
func (*IdentityEvidenceResponse) ProtoMessage() {}
func (x *IdentityEvidenceResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[39]
+ mi := &file_api_sam_proto_msgTypes[40]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2750,7 +2798,7 @@ func (x *IdentityEvidenceResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use IdentityEvidenceResponse.ProtoReflect.Descriptor instead.
func (*IdentityEvidenceResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{39}
+ return file_api_sam_proto_rawDescGZIP(), []int{40}
}
func (x *IdentityEvidenceResponse) GetPeerId() string {
@@ -2811,7 +2859,7 @@ type PeerEvidenceResponse struct {
func (x *PeerEvidenceResponse) Reset() {
*x = PeerEvidenceResponse{}
- mi := &file_api_sam_proto_msgTypes[40]
+ mi := &file_api_sam_proto_msgTypes[41]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2823,7 +2871,7 @@ func (x *PeerEvidenceResponse) String() string {
func (*PeerEvidenceResponse) ProtoMessage() {}
func (x *PeerEvidenceResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_sam_proto_msgTypes[40]
+ mi := &file_api_sam_proto_msgTypes[41]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2836,7 +2884,7 @@ func (x *PeerEvidenceResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use PeerEvidenceResponse.ProtoReflect.Descriptor instead.
func (*PeerEvidenceResponse) Descriptor() ([]byte, []int) {
- return file_api_sam_proto_rawDescGZIP(), []int{40}
+ return file_api_sam_proto_rawDescGZIP(), []int{41}
}
func (x *PeerEvidenceResponse) GetPeerId() string {
@@ -3041,7 +3089,9 @@ const file_api_sam_proto_rawDesc = "" +
"\rbiscuit_token\x18\x01 \x01(\fR\fbiscuitToken\x12\x1d\n" +
"\n" +
"expires_at\x18\x02 \x01(\x03R\texpiresAt\x12#\n" +
- "\rerror_message\x18\x03 \x01(\tR\ferrorMessage\"-\n" +
+ "\rerror_message\x18\x03 \x01(\tR\ferrorMessage\"D\n" +
+ "\x11NodeCatalogReport\x12/\n" +
+ "\bservices\x18\x01 \x03(\v2\x13.sam.v1.ServiceInfoR\bservices\"-\n" +
"\x12TokenRevokeRequest\x12\x17\n" +
"\apeer_id\x18\x01 \x01(\tR\x06peerId\"E\n" +
"\x13TokenRevokeResponse\x12\x18\n" +
@@ -3146,7 +3196,7 @@ func file_api_sam_proto_rawDescGZIP() []byte {
}
var file_api_sam_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
-var file_api_sam_proto_msgTypes = make([]protoimpl.MessageInfo, 46)
+var file_api_sam_proto_msgTypes = make([]protoimpl.MessageInfo, 47)
var file_api_sam_proto_goTypes = []any{
(EnrollmentStatus)(0), // 0: sam.v1.EnrollmentStatus
(ServiceType)(0), // 1: sam.v1.ServiceType
@@ -3175,57 +3225,59 @@ var file_api_sam_proto_goTypes = []any{
(*KeysResponse)(nil), // 24: sam.v1.KeysResponse
(*TokenRefreshRequest)(nil), // 25: sam.v1.TokenRefreshRequest
(*TokenRefreshResponse)(nil), // 26: sam.v1.TokenRefreshResponse
- (*TokenRevokeRequest)(nil), // 27: sam.v1.TokenRevokeRequest
- (*TokenRevokeResponse)(nil), // 28: sam.v1.TokenRevokeResponse
- (*AgentSecret)(nil), // 29: sam.v1.AgentSecret
- (*AgentEgress)(nil), // 30: sam.v1.AgentEgress
- (*AgentIngress)(nil), // 31: sam.v1.AgentIngress
- (*AgentBundle)(nil), // 32: sam.v1.AgentBundle
- (*AgentAttachRequest)(nil), // 33: sam.v1.AgentAttachRequest
- (*AgentAttachResponse)(nil), // 34: sam.v1.AgentAttachResponse
- (*AgentDetachRequest)(nil), // 35: sam.v1.AgentDetachRequest
- (*AgentDetachResponse)(nil), // 36: sam.v1.AgentDetachResponse
- (*AgentRefreshRequest)(nil), // 37: sam.v1.AgentRefreshRequest
- (*AgentRefreshResponse)(nil), // 38: sam.v1.AgentRefreshResponse
- (*AgentStatusRequest)(nil), // 39: sam.v1.AgentStatusRequest
- (*AgentStatus)(nil), // 40: sam.v1.AgentStatus
- (*AgentStatusResponse)(nil), // 41: sam.v1.AgentStatusResponse
- (*IdentityEvidenceResponse)(nil), // 42: sam.v1.IdentityEvidenceResponse
- (*PeerEvidenceResponse)(nil), // 43: sam.v1.PeerEvidenceResponse
- nil, // 44: sam.v1.EnrollRequest.LabelsEntry
- nil, // 45: sam.v1.BootstrapEnrollRequest.LabelsEntry
- nil, // 46: sam.v1.CommandBackend.EnvEntry
- nil, // 47: sam.v1.ServiceAnnounce.LabelsEntry
- nil, // 48: sam.v1.PeerEvidenceResponse.LabelsEntry
+ (*NodeCatalogReport)(nil), // 27: sam.v1.NodeCatalogReport
+ (*TokenRevokeRequest)(nil), // 28: sam.v1.TokenRevokeRequest
+ (*TokenRevokeResponse)(nil), // 29: sam.v1.TokenRevokeResponse
+ (*AgentSecret)(nil), // 30: sam.v1.AgentSecret
+ (*AgentEgress)(nil), // 31: sam.v1.AgentEgress
+ (*AgentIngress)(nil), // 32: sam.v1.AgentIngress
+ (*AgentBundle)(nil), // 33: sam.v1.AgentBundle
+ (*AgentAttachRequest)(nil), // 34: sam.v1.AgentAttachRequest
+ (*AgentAttachResponse)(nil), // 35: sam.v1.AgentAttachResponse
+ (*AgentDetachRequest)(nil), // 36: sam.v1.AgentDetachRequest
+ (*AgentDetachResponse)(nil), // 37: sam.v1.AgentDetachResponse
+ (*AgentRefreshRequest)(nil), // 38: sam.v1.AgentRefreshRequest
+ (*AgentRefreshResponse)(nil), // 39: sam.v1.AgentRefreshResponse
+ (*AgentStatusRequest)(nil), // 40: sam.v1.AgentStatusRequest
+ (*AgentStatus)(nil), // 41: sam.v1.AgentStatus
+ (*AgentStatusResponse)(nil), // 42: sam.v1.AgentStatusResponse
+ (*IdentityEvidenceResponse)(nil), // 43: sam.v1.IdentityEvidenceResponse
+ (*PeerEvidenceResponse)(nil), // 44: sam.v1.PeerEvidenceResponse
+ nil, // 45: sam.v1.EnrollRequest.LabelsEntry
+ nil, // 46: sam.v1.BootstrapEnrollRequest.LabelsEntry
+ nil, // 47: sam.v1.CommandBackend.EnvEntry
+ nil, // 48: sam.v1.ServiceAnnounce.LabelsEntry
+ nil, // 49: sam.v1.PeerEvidenceResponse.LabelsEntry
}
var file_api_sam_proto_depIdxs = []int32{
2, // 0: sam.v1.MeshEvent.type:type_name -> sam.v1.MeshEvent.Type
- 44, // 1: sam.v1.EnrollRequest.labels:type_name -> sam.v1.EnrollRequest.LabelsEntry
- 45, // 2: sam.v1.BootstrapEnrollRequest.labels:type_name -> sam.v1.BootstrapEnrollRequest.LabelsEntry
+ 45, // 1: sam.v1.EnrollRequest.labels:type_name -> sam.v1.EnrollRequest.LabelsEntry
+ 46, // 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
- 46, // 5: sam.v1.CommandBackend.env:type_name -> sam.v1.CommandBackend.EnvEntry
+ 47, // 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
- 47, // 9: sam.v1.ServiceAnnounce.labels:type_name -> sam.v1.ServiceAnnounce.LabelsEntry
+ 48, // 9: sam.v1.ServiceAnnounce.labels:type_name -> sam.v1.ServiceAnnounce.LabelsEntry
18, // 10: sam.v1.PolicyConfigGetResponse.roles:type_name -> sam.v1.PolicyRole
19, // 11: sam.v1.PolicyConfigGetResponse.bindings:type_name -> sam.v1.PolicyBinding
18, // 12: sam.v1.PolicyConfigUpdateRequest.roles:type_name -> sam.v1.PolicyRole
19, // 13: sam.v1.PolicyConfigUpdateRequest.bindings:type_name -> sam.v1.PolicyBinding
- 29, // 14: sam.v1.AgentEgress.secrets:type_name -> sam.v1.AgentSecret
- 1, // 15: sam.v1.AgentIngress.type:type_name -> sam.v1.ServiceType
- 30, // 16: sam.v1.AgentBundle.egress:type_name -> sam.v1.AgentEgress
- 31, // 17: sam.v1.AgentBundle.ingress:type_name -> sam.v1.AgentIngress
- 32, // 18: sam.v1.AgentAttachRequest.bundle:type_name -> sam.v1.AgentBundle
- 31, // 19: sam.v1.AgentStatus.ingress:type_name -> sam.v1.AgentIngress
- 40, // 20: sam.v1.AgentStatusResponse.agents:type_name -> sam.v1.AgentStatus
- 48, // 21: sam.v1.PeerEvidenceResponse.labels:type_name -> sam.v1.PeerEvidenceResponse.LabelsEntry
- 22, // [22:22] is the sub-list for method output_type
- 22, // [22:22] is the sub-list for method input_type
- 22, // [22:22] is the sub-list for extension type_name
- 22, // [22:22] is the sub-list for extension extendee
- 0, // [0:22] is the sub-list for field type_name
+ 10, // 14: sam.v1.NodeCatalogReport.services:type_name -> sam.v1.ServiceInfo
+ 30, // 15: sam.v1.AgentEgress.secrets:type_name -> sam.v1.AgentSecret
+ 1, // 16: sam.v1.AgentIngress.type:type_name -> sam.v1.ServiceType
+ 31, // 17: sam.v1.AgentBundle.egress:type_name -> sam.v1.AgentEgress
+ 32, // 18: sam.v1.AgentBundle.ingress:type_name -> sam.v1.AgentIngress
+ 33, // 19: sam.v1.AgentAttachRequest.bundle:type_name -> sam.v1.AgentBundle
+ 32, // 20: sam.v1.AgentStatus.ingress:type_name -> sam.v1.AgentIngress
+ 41, // 21: sam.v1.AgentStatusResponse.agents:type_name -> sam.v1.AgentStatus
+ 49, // 22: sam.v1.PeerEvidenceResponse.labels:type_name -> sam.v1.PeerEvidenceResponse.LabelsEntry
+ 23, // [23:23] is the sub-list for method output_type
+ 23, // [23:23] is the sub-list for method input_type
+ 23, // [23:23] is the sub-list for extension type_name
+ 23, // [23:23] is the sub-list for extension extendee
+ 0, // [0:23] is the sub-list for field type_name
}
func init() { file_api_sam_proto_init() }
@@ -3243,7 +3295,7 @@ func file_api_sam_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_sam_proto_rawDesc), len(file_api_sam_proto_rawDesc)),
NumEnums: 3,
- NumMessages: 46,
+ NumMessages: 47,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/api/sam.proto b/api/sam.proto
index b56826ff..13d761d0 100644
--- a/api/sam.proto
+++ b/api/sam.proto
@@ -252,6 +252,14 @@ message TokenRefreshResponse {
string error_message = 3;
}
+// NodeCatalogReport is the body of POST /nodes/catalog: a node's
+// self-reported list of locally registered services. The reporting peer is
+// taken from the presented biscuit, never from the body, so a node can only
+// ever describe itself. Display-only; carries no authorization weight.
+message NodeCatalogReport {
+ repeated ServiceInfo services = 1;
+}
+
message TokenRevokeRequest {
string peer_id = 1;
}
diff --git a/internal/console/public/app.js b/internal/console/public/app.js
index b11f55fe..65295722 100644
--- a/internal/console/public/app.js
+++ b/internal/console/public/app.js
@@ -387,11 +387,9 @@ function renderNodesTable(nodes) {
`).join('');
}
-// Service type is a protobuf enum (SERVICE_TYPE_MCP = 1, SERVICE_TYPE_INFERENCE = 2,
-// SERVICE_TYPE_A2A = 3); plain encoding/json on the Go side emits the bare
-// int, not the enum name, and omits it entirely (omitempty) if it's ever 0.
-const SERVICE_TYPE_NAMES = { 1: 'mcp', 2: 'inference', 3: 'a2a' };
-
+// node_catalog is {peerID: {services: [{name, type, description}], reported_at}},
+// already restricted server-side to nodes that are still admitted; type is
+// the short name ("mcp", "inference", "a2a") rendered by the control plane.
function renderServicesTable(nodeCatalog, labelsByPeer) {
const tbody = document.getElementById('table-services');
const peerIDs = Object.keys(nodeCatalog || {});
@@ -414,7 +412,7 @@ function renderServicesTable(nodeCatalog, labelsByPeer) {
tbody.innerHTML = rows.map(({ peerID, reportedAt, svc }) => `
<tr>
<td>${escapeHTML(svc.name || '')}</td>
- <td>${escapeHTML(SERVICE_TYPE_NAMES[svc.type] || 'unknown')}</td>
+ <td>${escapeHTML(svc.type || 'unknown')}</td>
<td>${escapeHTML(svc.description || '')}</td>
<td>${peerCell(peerID, (labelsByPeer || {})[peerID])}</td>
<td>${reportedAt ? escapeHTML(new Date(reportedAt).toLocaleString()) : '-'}</td>
diff --git a/internal/controlplane/catalog.go b/internal/controlplane/catalog.go
index dcf75c07..bfaab6ff 100644
--- a/internal/controlplane/catalog.go
+++ b/internal/controlplane/catalog.go
@@ -17,7 +17,7 @@ package controlplane
import (
"crypto/ed25519"
"encoding/base64"
- "encoding/json"
+ "fmt"
"io"
"net/http"
"strings"
@@ -25,23 +25,37 @@ import (
"github.com/google/sam/api"
"github.com/google/sam/internal/identity"
+ "github.com/google/sam/internal/storage"
+ "google.golang.org/protobuf/proto"
)
+// maxCatalogServices bounds one report so a single admitted node cannot grow
+// the in-memory cache without limit.
+const maxCatalogServices = 512
+
// nodeCatalogEntry is what HandleNodeCatalog caches per reporting peer.
type nodeCatalogEntry struct {
- Services []*api.ServiceInfo `json:"services"`
- ReportedAt time.Time `json:"reported_at"`
+ Services []*api.ServiceInfo
+ ReportedAt time.Time
+}
+
+// catalogService is the console-facing shape of one reported service: a plain
+// struct so the JSON the console reads does not depend on protoc-gen-go's
+// struct layout or tags.
+type catalogService struct {
+ Name string `json:"name"`
+ Type string `json:"type"`
+ Description string `json:"description"`
}
-// nodeCatalogRequest is HandleNodeCatalog's request body. The reporting
-// peer's identity comes from its verified Biscuit, never from this body -
-// a node can only ever report on itself.
-type nodeCatalogRequest struct {
- Services []*api.ServiceInfo `json:"services"`
+// catalogView is HandleAdminStatus's node_catalog value for one peer.
+type catalogView struct {
+ Services []catalogService `json:"services"`
+ ReportedAt time.Time `json:"reported_at"`
}
// catalogSnapshot returns a stable copy of the current node service catalog
-// cache, safe to range over or marshal without holding catalogMu.
+// cache, safe to range over without holding catalogMu.
func (s *Server) catalogSnapshot() map[string]nodeCatalogEntry {
s.catalogMu.RLock()
defer s.catalogMu.RUnlock()
@@ -52,18 +66,57 @@ func (s *Server) catalogSnapshot() map[string]nodeCatalogEntry {
return snap
}
+// catalogViewFor renders the cache for the console, restricted to nodes that
+// are still admitted so a banned or expired node's last report disappears
+// with its enrollment instead of lingering until the next restart.
+func (s *Server) catalogViewFor(nodes []storage.EnrolledNode, now time.Time) map[string]catalogView {
+ snap := s.catalogSnapshot()
+ view := make(map[string]catalogView, len(snap))
+ for i := range nodes {
+ node := &nodes[i]
+ entry, ok := snap[node.PeerID]
+ if !ok || node.CheckAdmission(now) != nil {
+ continue
+ }
+ services := make([]catalogService, 0, len(entry.Services))
+ for _, svc := range entry.Services {
+ typeName, err := api.ServiceTypeToString(svc.GetType())
+ if err != nil {
+ typeName = "unknown"
+ }
+ services = append(services, catalogService{
+ Name: svc.GetName(),
+ Type: typeName,
+ Description: svc.GetDescription(),
+ })
+ }
+ view[node.PeerID] = catalogView{Services: services, ReportedAt: entry.ReportedAt}
+ }
+ return view
+}
+
+// dropCatalogEntry forgets a peer's report; called when its enrollment ends.
+func (s *Server) dropCatalogEntry(peerID string) {
+ s.catalogMu.Lock()
+ delete(s.catalog, peerID)
+ s.catalogMu.Unlock()
+}
+
// HandleNodeCatalog HTTP POST /nodes/catalog - a node self-reports the
// services it currently has registered locally (the same data
// list_local_services already answers on the node itself), so the control
// plane can show mesh-wide service topology without needing to be a DHT
// participant or open a P2P connection to every enrolled node itself.
//
+// The body is an api.NodeCatalogReport. The reporting peer is the one bound
+// in the presented Biscuit, so a node can only ever describe itself.
+//
// This is a live-status cache, not authoritative state: a node that goes
// offline without ever reporting an empty catalog just leaves its last
-// report in place until ReportedAt visibly goes stale. Good enough for an
-// admin-facing "what's running where" view; not a substitute for the real
-// per-request Biscuit authorization every actual service call still goes
-// through independently.
+// report in place until ReportedAt visibly goes stale or its enrollment
+// ends. It is admin-facing display data only and never feeds authorization,
+// which is also why a bare bearer Biscuit (no signed challenge, unlike
+// /refresh) is accepted here: a replayed token can only repaint a table.
func (s *Server) HandleNodeCatalog(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
@@ -112,27 +165,20 @@ func (s *Server) HandleNodeCatalog(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Failed to read body", http.StatusBadRequest)
return
}
- defer func() { _ = r.Body.Close() }()
- var req nodeCatalogRequest
- if err := json.Unmarshal(body, &req); err != nil {
- http.Error(w, "Invalid JSON body", http.StatusBadRequest)
+ var req api.NodeCatalogReport
+ if err := proto.Unmarshal(body, &req); err != nil {
+ http.Error(w, "Invalid request format", http.StatusBadRequest)
return
}
-
- // A malformed report (e.g. {"services": [null]}) unmarshals into a nil
- // element rather than failing - filter those out so a bad report from one
- // node can't crash rendering for every node's entry in the console.
- var validServices []*api.ServiceInfo
- for _, svc := range req.Services {
- if svc != nil {
- validServices = append(validServices, svc)
- }
+ if len(req.Services) > maxCatalogServices {
+ http.Error(w, fmt.Sprintf("Too many services in report (max %d)", maxCatalogServices), http.StatusBadRequest)
+ return
}
s.catalogMu.Lock()
s.catalog[peerID.String()] = nodeCatalogEntry{
- Services: validServices,
+ Services: req.Services,
ReportedAt: time.Now(),
}
s.catalogMu.Unlock()
diff --git a/internal/controlplane/catalog_test.go b/internal/controlplane/catalog_test.go
index 469492ea..c3f23b8d 100644
--- a/internal/controlplane/catalog_test.go
+++ b/internal/controlplane/catalog_test.go
@@ -17,7 +17,9 @@ package controlplane
import (
"bytes"
"context"
+ "crypto/ed25519"
"encoding/base64"
+ "encoding/json"
"net/http"
"testing"
"time"
@@ -26,21 +28,22 @@ import (
"github.com/google/sam/internal/identity"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
+ "google.golang.org/protobuf/proto"
)
-// postCatalog POSTs a raw catalog report body to /nodes/catalog under the
-// given biscuit and returns the response status.
-func postCatalog(t *testing.T, cpURL string, biscuit []byte, body []byte) int {
+// postCatalog POSTs a raw body to /nodes/catalog under the given
+// Authorization header value and returns the response status.
+func postCatalog(t *testing.T, cpURL, authHeader string, body []byte) int {
t.Helper()
req, err := http.NewRequest(http.MethodPost, cpURL+"/nodes/catalog", bytes.NewReader(body))
if err != nil {
t.Fatalf("NewRequest: %v", err)
}
- if biscuit != nil {
- req.Header.Set("Authorization", "Bearer "+base64.StdEncoding.EncodeToString(biscuit))
+ if authHeader != "" {
+ req.Header.Set("Authorization", authHeader)
}
- req.Header.Set("Content-Type", "application/json")
+ req.Header.Set("Content-Type", "application/x-protobuf")
resp, err := http.DefaultClient.Do(req)
if err != nil {
@@ -50,6 +53,45 @@ func postCatalog(t *testing.T, cpURL string, biscuit []byte, body []byte) int {
return resp.StatusCode
}
+func bearer(biscuit []byte) string {
+ return "Bearer " + base64.StdEncoding.EncodeToString(biscuit)
+}
+
+func catalogBody(t *testing.T, services ...*api.ServiceInfo) []byte {
+ t.Helper()
+ body, err := proto.Marshal(&api.NodeCatalogReport{Services: services})
+ if err != nil {
+ t.Fatalf("Marshal: %v", err)
+ }
+ return body
+}
+
+// adminNodeCatalog fetches /admin/status and returns its node_catalog value.
+func adminNodeCatalog(t *testing.T, cpURL, adminToken string) map[string]catalogView {
+ t.Helper()
+
+ req, err := http.NewRequest(http.MethodGet, cpURL+"/admin/status", nil)
+ if err != nil {
+ t.Fatalf("NewRequest: %v", err)
+ }
+ req.Header.Set("Authorization", "Bearer "+adminToken)
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ t.Fatalf("GET /admin/status: %v", err)
+ }
+ defer func() { _ = resp.Body.Close() }()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("GET /admin/status: status %d", resp.StatusCode)
+ }
+ var status struct {
+ NodeCatalog map[string]catalogView `json:"node_catalog"`
+ }
+ if err := json.NewDecoder(resp.Body).Decode(&status); err != nil {
+ t.Fatalf("decode /admin/status: %v", err)
+ }
+ return status.NodeCatalog
+}
+
func TestHandleNodeCatalog(t *testing.T) {
t.Parallel()
@@ -58,50 +100,63 @@ func TestHandleNodeCatalog(t *testing.T) {
_ = srv.Close()
_ = store.Close()
}()
+ srv.config.AdminToken = "super-secret-admin-token"
ctx := context.Background()
- _, biscuitBytes := enrollRefreshTestNode(t, ctx, store)
+ priv, biscuitBytes := enrollRefreshTestNode(t, ctx, store)
+ nodePeer, err := peer.IDFromPrivateKey(priv)
+ if err != nil {
+ t.Fatalf("IDFromPrivateKey: %v", err)
+ }
- body := []byte(`{"services":[{"type":1,"name":"stvv-compliance-docs","description":"doc lookup"},null,{"type":1,"name":"everything","description":"reference server"}]}`)
- if got := postCatalog(t, cpURL, biscuitBytes, body); got != http.StatusNoContent {
+ body := catalogBody(t,
+ &api.ServiceInfo{Type: api.ServiceType_SERVICE_TYPE_MCP, Name: "stvv-compliance-docs", Description: "doc lookup"},
+ &api.ServiceInfo{Type: api.ServiceType_SERVICE_TYPE_INFERENCE, Name: "llama", Description: "local model"},
+ )
+ if got := postCatalog(t, cpURL, bearer(biscuitBytes), body); got != http.StatusNoContent {
t.Fatalf("HandleNodeCatalog: got status %d, want %d", got, http.StatusNoContent)
}
snap := srv.catalogSnapshot()
- if len(snap) != 1 {
- t.Fatalf("expected exactly one reporting peer in the catalog, got %d", len(snap))
- }
- for peerID, entry := range snap {
- if len(entry.Services) != 2 {
- t.Fatalf("expected the null service element to be filtered out, got %d services: %+v", len(entry.Services), entry.Services)
- }
- for i, svc := range entry.Services {
- if svc == nil {
- t.Fatalf("service at index %d is nil, filtering failed", i)
- }
- }
- if entry.ReportedAt.IsZero() {
- t.Errorf("ReportedAt was not set for peer %s", peerID)
- }
+ entry, ok := snap[nodePeer.String()]
+ if !ok || len(snap) != 1 {
+ t.Fatalf("expected exactly the reporting peer in the catalog, got %v", snap)
+ }
+ if len(entry.Services) != 2 || entry.ReportedAt.IsZero() {
+ t.Fatalf("unexpected cached entry: %+v", entry)
}
-}
-func TestHandleNodeCatalog_MissingAuth(t *testing.T) {
- t.Parallel()
+ // A second report replaces the first rather than accumulating.
+ body = catalogBody(t, &api.ServiceInfo{Type: api.ServiceType_SERVICE_TYPE_A2A, Name: "planner"})
+ if got := postCatalog(t, cpURL, bearer(biscuitBytes), body); got != http.StatusNoContent {
+ t.Fatalf("second report: got status %d, want %d", got, http.StatusNoContent)
+ }
+ entry = srv.catalogSnapshot()[nodePeer.String()]
+ if len(entry.Services) != 1 || entry.Services[0].Name != "planner" {
+ t.Fatalf("second report must replace the first, got %+v", entry.Services)
+ }
- srv, store, cpURL := setupTestServer(t, "")
- defer func() {
- _ = srv.Close()
- _ = store.Close()
- }()
+ // The console sees the plain view with the type rendered as a name.
+ view := adminNodeCatalog(t, cpURL, srv.config.AdminToken)
+ got, ok := view[nodePeer.String()]
+ if !ok || len(view) != 1 {
+ t.Fatalf("expected the reporting peer in node_catalog, got %v", view)
+ }
+ want := []catalogService{{Name: "planner", Type: "a2a", Description: ""}}
+ if len(got.Services) != 1 || got.Services[0] != want[0] || got.ReportedAt.IsZero() {
+ t.Fatalf("node_catalog view = %+v, want services %+v", got, want)
+ }
- body := []byte(`{"services":[]}`)
- if got := postCatalog(t, cpURL, nil, body); got != http.StatusUnauthorized {
- t.Fatalf("missing Authorization header: got status %d, want %d", got, http.StatusUnauthorized)
+ // An empty report is valid and clears the node's services.
+ if got := postCatalog(t, cpURL, bearer(biscuitBytes), catalogBody(t)); got != http.StatusNoContent {
+ t.Fatalf("empty report: got status %d, want %d", got, http.StatusNoContent)
+ }
+ if view := adminNodeCatalog(t, cpURL, srv.config.AdminToken); len(view[nodePeer.String()].Services) != 0 {
+ t.Fatalf("empty report must clear services, got %+v", view)
}
}
-func TestHandleNodeCatalog_UnenrolledPeer(t *testing.T) {
+func TestHandleNodeCatalog_Rejections(t *testing.T) {
t.Parallel()
srv, store, cpURL := setupTestServer(t, "")
@@ -111,37 +166,81 @@ func TestHandleNodeCatalog_UnenrolledPeer(t *testing.T) {
}()
ctx := context.Background()
+ _, biscuitBytes := enrollRefreshTestNode(t, ctx, store)
cpPriv, _, err := store.GetCurrentKey(ctx)
if err != nil {
t.Fatalf("GetCurrentKey: %v", err)
}
- // A biscuit minted for a peer that was never enrolled (or whose
- // enrollment record has since been removed) must be rejected: a node can
- // only ever report a catalog for itself, and self-reporting requires an
- // admitted enrollment record to attribute the report to.
- priv, _, err := crypto.GenerateKeyPair(crypto.Ed25519, -1)
+ // A biscuit minted by a key the control plane never trusted.
+ _, rogueKey, err := ed25519.GenerateKey(nil)
+ if err != nil {
+ t.Fatalf("GenerateKey: %v", err)
+ }
+ strangerPriv, _, err := crypto.GenerateKeyPair(crypto.Ed25519, -1)
if err != nil {
t.Fatalf("GenerateKeyPair: %v", err)
}
- strangerPeer, err := peer.IDFromPrivateKey(priv)
+ strangerPeer, err := peer.IDFromPrivateKey(strangerPriv)
if err != nil {
t.Fatalf("IDFromPrivateKey: %v", err)
}
- strangerBiscuit, err := identity.MintBootstrapBiscuitToken(
- cpPriv, strangerPeer, api.RoleNode, time.Now().Add(api.BiscuitTokenTTL), nil, nil,
- )
+ forged, err := identity.MintBootstrapBiscuitToken(rogueKey, strangerPeer, api.RoleNode, time.Now().Add(api.BiscuitTokenTTL), nil, nil)
if err != nil {
- t.Fatalf("MintBootstrapBiscuitToken: %v", err)
+ t.Fatalf("MintBootstrapBiscuitToken(rogue): %v", err)
+ }
+ // A valid biscuit for a peer that was never enrolled.
+ unenrolled, err := identity.MintBootstrapBiscuitToken(cpPriv, strangerPeer, api.RoleNode, time.Now().Add(api.BiscuitTokenTTL), nil, nil)
+ if err != nil {
+ t.Fatalf("MintBootstrapBiscuitToken(unenrolled): %v", err)
+ }
+
+ tooMany := make([]*api.ServiceInfo, maxCatalogServices+1)
+ for i := range tooMany {
+ tooMany[i] = &api.ServiceInfo{Type: api.ServiceType_SERVICE_TYPE_MCP, Name: "svc"}
+ }
+
+ ok := catalogBody(t)
+ tests := []struct {
+ name string
+ auth string
+ body []byte
+ want int
+ }{
+ {name: "missing authorization", auth: "", body: ok, want: http.StatusUnauthorized},
+ {name: "not a bearer token", auth: "Basic abc", body: ok, want: http.StatusUnauthorized},
+ {name: "malformed base64", auth: "Bearer %%%not-base64", body: ok, want: http.StatusBadRequest},
+ {name: "not a biscuit", auth: bearer([]byte("garbage")), body: ok, want: http.StatusUnauthorized},
+ {name: "forged signature", auth: bearer(forged), body: ok, want: http.StatusUnauthorized},
+ {name: "unenrolled peer", auth: bearer(unenrolled), body: ok, want: http.StatusUnauthorized},
+ {name: "invalid body", auth: bearer(biscuitBytes), body: []byte(`{"services":[]}`), want: http.StatusBadRequest},
+ {name: "too many services", auth: bearer(biscuitBytes), body: catalogBody(t, tooMany...), want: http.StatusBadRequest},
+ }
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := postCatalog(t, cpURL, tc.auth, tc.body); got != tc.want {
+ t.Fatalf("got status %d, want %d", got, tc.want)
+ }
+ })
+ }
+ if len(srv.catalogSnapshot()) != 0 {
+ t.Fatalf("rejected reports must not be cached, got %v", srv.catalogSnapshot())
}
- body := []byte(`{"services":[]}`)
- if got := postCatalog(t, cpURL, strangerBiscuit, body); got != http.StatusUnauthorized {
- t.Fatalf("unenrolled peer: got status %d, want %d", got, http.StatusUnauthorized)
+ resp, err := http.Get(cpURL + "/nodes/catalog")
+ if err != nil {
+ t.Fatalf("Get: %v", err)
+ }
+ _ = resp.Body.Close()
+ if resp.StatusCode != http.StatusMethodNotAllowed {
+ t.Fatalf("GET /nodes/catalog: got status %d, want %d", resp.StatusCode, http.StatusMethodNotAllowed)
}
}
-func TestHandleNodeCatalog_MethodNotAllowed(t *testing.T) {
+// A node's catalog is only ever as trustworthy as its enrollment: once the
+// record is banned or its session lapses, new reports are refused and the
+// cached one drops out of the console view.
+func TestHandleNodeCatalog_Admission(t *testing.T) {
t.Parallel()
srv, store, cpURL := setupTestServer(t, "")
@@ -149,13 +248,50 @@ func TestHandleNodeCatalog_MethodNotAllowed(t *testing.T) {
_ = srv.Close()
_ = store.Close()
}()
+ srv.config.AdminToken = "super-secret-admin-token"
- resp, err := http.Get(cpURL + "/nodes/catalog")
+ ctx := context.Background()
+ priv, biscuitBytes := enrollRefreshTestNode(t, ctx, store)
+ nodePeer, err := peer.IDFromPrivateKey(priv)
if err != nil {
- t.Fatalf("Get: %v", err)
+ t.Fatalf("IDFromPrivateKey: %v", err)
}
- defer func() { _ = resp.Body.Close() }()
- if resp.StatusCode != http.StatusMethodNotAllowed {
- t.Fatalf("GET /nodes/catalog: got status %d, want %d", resp.StatusCode, http.StatusMethodNotAllowed)
+ body := catalogBody(t, &api.ServiceInfo{Type: api.ServiceType_SERVICE_TYPE_MCP, Name: "calc"})
+ if got := postCatalog(t, cpURL, bearer(biscuitBytes), body); got != http.StatusNoContent {
+ t.Fatalf("admitted node: got status %d, want %d", got, http.StatusNoContent)
+ }
+ if _, ok := adminNodeCatalog(t, cpURL, srv.config.AdminToken)[nodePeer.String()]; !ok {
+ t.Fatal("admitted node's report missing from node_catalog")
+ }
+
+ // Session lapsed: the cache still holds the report but the view hides it.
+ record, err := store.GetNode(ctx, nodePeer.String())
+ if err != nil {
+ t.Fatalf("GetNode: %v", err)
+ }
+ record.ExpiresAt = time.Now().Add(-time.Hour)
+ if err := store.EnrollNode(ctx, record); err != nil {
+ t.Fatalf("EnrollNode: %v", err)
+ }
+ if got := postCatalog(t, cpURL, bearer(biscuitBytes), body); got != http.StatusUnauthorized {
+ t.Fatalf("expired session: got status %d, want %d", got, http.StatusUnauthorized)
+ }
+ if view := adminNodeCatalog(t, cpURL, srv.config.AdminToken); len(view) != 0 {
+ t.Fatalf("expired node must not appear in node_catalog, got %v", view)
+ }
+
+ // Banned through the server path: the entry is evicted outright.
+ record.ExpiresAt = time.Now().Add(time.Hour)
+ if err := store.EnrollNode(ctx, record); err != nil {
+ t.Fatalf("EnrollNode: %v", err)
+ }
+ if err := srv.banNode(ctx, record); err != nil {
+ t.Fatalf("banNode: %v", err)
+ }
+ if got := postCatalog(t, cpURL, bearer(biscuitBytes), body); got != http.StatusUnauthorized {
+ t.Fatalf("banned node: got status %d, want %d", got, http.StatusUnauthorized)
+ }
+ if snap := srv.catalogSnapshot(); len(snap) != 0 {
+ t.Fatalf("banning must evict the cached report, got %v", snap)
}
}
diff --git a/internal/controlplane/server.go b/internal/controlplane/server.go
index c771df5f..565a1c47 100644
--- a/internal/controlplane/server.go
+++ b/internal/controlplane/server.go
@@ -2186,6 +2186,7 @@ func (s *Server) banNode(ctx context.Context, node *storage.EnrolledNode) error
if err := s.store.SetNodeBanned(ctx, node.PeerID, true); err != nil {
return err
}
+ s.dropCatalogEntry(node.PeerID)
if node.ClaimsJSON == "" {
return nil
}
diff --git a/internal/controlplane/ui.go b/internal/controlplane/ui.go
index 32b9dd49..064f5a04 100644
--- a/internal/controlplane/ui.go
+++ b/internal/controlplane/ui.go
@@ -17,6 +17,7 @@ package controlplane
import (
"encoding/json"
"net/http"
+ "time"
)
// HandleAdminStatus returns a consolidated JSON state of the control plane.
@@ -86,7 +87,7 @@ func (s *Server) HandleAdminStatus(w http.ResponseWriter, r *http.Request) {
"enrollment_requests": reqs,
"bootstrap_tokens": tokens,
"policy_json": policyJSON,
- "node_catalog": s.catalogSnapshot(),
+ "node_catalog": s.catalogViewFor(nodes, time.Now()),
}
w.Header().Set("Content-Type", "application/json")
diff --git a/internal/node/controlplane.go b/internal/node/controlplane.go
index 9e8ce145..b05392ee 100644
--- a/internal/node/controlplane.go
+++ b/internal/node/controlplane.go
@@ -19,7 +19,6 @@ import (
"context"
"crypto/ed25519"
"encoding/base64"
- "encoding/json"
"fmt"
"io"
"net/http"
@@ -253,14 +252,6 @@ func FetchMeshPolicy(ctx context.Context, controlPlaneURL string, biscuitToken [
return &policyResp, nil
}
-// nodeCatalogRequest mirrors internal/controlplane/catalog.go's request
-// body - kept as a plain JSON struct here rather than a shared package
-// import, matching how this file already treats /policies as a boundary
-// between the two components.
-type nodeCatalogRequest struct {
- Services []*api.ServiceInfo `json:"services"`
-}
-
// ReportNodeCatalog self-reports this node's locally registered services to
// the control plane's /nodes/catalog endpoint, so an admin can see mesh-wide
// service topology (see catalog.go's HandleNodeCatalog for why this exists
@@ -271,7 +262,7 @@ func ReportNodeCatalog(ctx context.Context, controlPlaneURL string, biscuitToken
}
controlPlaneURL = strings.TrimSuffix(controlPlaneURL, "/")
- payload, err := json.Marshal(nodeCatalogRequest{Services: services})
+ payload, err := proto.Marshal(&api.NodeCatalogReport{Services: services})
if err != nil {
return fmt.Errorf("failed to encode catalog report: %w", err)
}
@@ -281,7 +272,7 @@ func ReportNodeCatalog(ctx context.Context, controlPlaneURL string, biscuitToken
if err != nil {
return fmt.Errorf("failed to create HTTP request: %w", err)
}
- req.Header.Set("Content-Type", "application/json")
+ req.Header.Set("Content-Type", "application/x-protobuf")
req.Header.Set("Authorization", "Bearer "+base64.StdEncoding.EncodeToString(biscuitToken))
client := &http.Client{Timeout: 10 * time.Second}
diff --git a/internal/node/controlplane_test.go b/internal/node/controlplane_test.go
index d4adc201..d06a46dd 100644
--- a/internal/node/controlplane_test.go
+++ b/internal/node/controlplane_test.go
@@ -18,7 +18,7 @@ import (
"context"
"crypto/ed25519"
"encoding/base64"
- "encoding/json"
+ "io"
"net/http"
"net/http/httptest"
"reflect"
@@ -228,8 +228,8 @@ func TestReportNodeCatalog(t *testing.T) {
{Type: api.ServiceType_SERVICE_TYPE_MCP, Name: "stvv-compliance-docs", Description: "doc lookup"},
}
- var gotAuth string
- var gotReq nodeCatalogRequest
+ var gotAuth, gotContentType string
+ var gotReq api.NodeCatalogReport
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
t.Errorf("Expected POST, got %s", r.Method)
@@ -238,7 +238,12 @@ func TestReportNodeCatalog(t *testing.T) {
t.Errorf("Expected path /nodes/catalog, got %s", r.URL.Path)
}
gotAuth = r.Header.Get("Authorization")
- if err := json.NewDecoder(r.Body).Decode(&gotReq); err != nil {
+ gotContentType = r.Header.Get("Content-Type")
+ body, err := io.ReadAll(r.Body)
+ if err != nil {
+ t.Errorf("failed to read request body: %v", err)
+ }
+ if err := proto.Unmarshal(body, &gotReq); err != nil {
t.Errorf("failed to decode request body: %v", err)
}
w.WriteHeader(http.StatusNoContent)
@@ -254,7 +259,10 @@ func TestReportNodeCatalog(t *testing.T) {
if gotAuth != wantAuth {
t.Errorf("Expected Authorization header %q, got %q", wantAuth, gotAuth)
}
- if len(gotReq.Services) != 1 || gotReq.Services[0].Name != "stvv-compliance-docs" {
+ if gotContentType != "application/x-protobuf" {
+ t.Errorf("Expected Content-Type application/x-protobuf, got %q", gotContentType)
+ }
+ if len(gotReq.Services) != 1 || gotReq.Services[0].Name != "stvv-compliance-docs" || gotReq.Services[0].Type != api.ServiceType_SERVICE_TYPE_MCP {
t.Errorf("Expected relayed services %v, got %v", services, gotReq.Services)
}
}