Access Service Protobuf Definitions
This repository contains the Protocol Buffer (protobuf) definitions for an Access Management service. It defines the data structures (messages) and the service interface (RPC methods) used for managing access permissions within a system.
Overview
The access.proto file defines:
- Data Structures: How access permissions and related requests/responses are represented.
- Service Contract: The available remote procedure calls (RPCs) for interacting with the access service.
Key Components
Enum: EntityType
Defines the different types of entities that can be associated with an access permission:
ENTITY_TYPE_UNSPECIFIED(Default, should not be used)ENTITY_TYPE_ORGENTITY_TYPE_COMPANYENTITY_TYPE_DEPARTMENTENTITY_TYPE_ROLEENTITY_TYPE_USER
Message: Access
Represents a single access permission record. Key fields include:
id: Unique identifier for the access record.entity_type: The type of entity (Org, User, etc.).entity_id: The specific ID of the entity.app_id: Identifier for the application the access applies to.module_id: Identifier for a specific module within the application.action: A string describing the permitted action (e.g., "read", "write", "delete").value: An integer value associated with the access (interpretation depends on context, e.g., level, boolean flag).- Audit fields (
created_at,created_by,updated_at,updated_by): Timestamps and user IDs for tracking changes.
Message: AccessResponse
A standard response format returned by all service methods. It includes:
message: A human-readable status message.code: A status code (e.g., "OK", "ERROR_NOT_FOUND").data: A list ofAccessobjects (the result of the query or operation).total: The total number of records matching the query (useful for pagination).
Request Messages
CreateAccessRequest: Contains the necessary fields to create a newAccessrecord (excludingidand audit fields).UpdateAccessRequest: Contains fields to update an existingAccessrecord, including theidof the record to modify.GetAccessByIDRequest: Used to request anAccessrecord by its uniqueaccess_id.GetAccessByEntityTypeAndEntityID...Requestvariants: Used to query forAccessrecords based on combinations ofentity_type,entity_id,app_id, andmodule_id.
Service: AccessService
Defines the RPC methods available for managing access permissions:
CreateAccess: Creates a new access permission record.UpdateAccess: Updates an existing access permission record.GetAccessByID: Retrieves a specific access record by its ID.GetAccessByEntityTypeAndEntityIDAndAppIDAndModuleID: Retrieves access records matching entity, app, and module criteria.GetAccessByEntityTypeAndEntityIDAndAppID: Retrieves access records matching entity and app criteria.GetAccessByEntityTypeAndEntityID: Retrieves all access records for a specific entity.
Usage
This .proto file should be used with the Protocol Buffer compiler (protoc) to generate source code stubs in Golang. These generated stubs provide the necessary classes/structs and client/server interfaces for implementing and consuming the AccessService.
Note:
- This file uses
proto3syntax. - It imports
google/protobuf/timestamp.protofor handling timestamp fields. - The
option go_package = "/";is specific to Go code generation.
Go Data Model (internal/models/access.go)
This file defines the Go struct used within the application layer, often interacting directly with the database and potentially marshalled to/from JSON for REST APIs.
Go Constants: EntityType
Defines constants for entity types using Go's string type for better readability within the Go codebase:
const (
EntityTypeOrg EntityType = "org"
EntityTypeCompany EntityType = "company"
EntityTypeDepartment EntityType = "department"
EntityTypeRole EntityType = "role"
EntityTypeUser EntityType = "user"
EntityTypeUnspecified EntityType = "unspecified" // Usually for default/zero value
)