1+ // Access Policy Domain - Role-Based Access Control (RBAC)
2+ //
3+ // Defines roles, permissions, and conditional policies for fine-grained
4+ // access control in multi-tenant environments with attribute-based evaluation.
5+ //
6+ // COMPLIANCE: SOC 2 CC6.1 (Logical access controls), SOC 2 CC6.2 (Access management)
7+ // ISO 27001 A.9.2 (User access management), ISO 27001 A.9.4 (Access control)
8+ // NIST SP 800-53 AC-2 (Account Management), AC-3 (Access Enforcement)
9+ // SECURITY: Principle of least privilege enforced. All operations audited.
10+ // Tenant isolation strictly enforced in all policy evaluations.
11+
112syntax = "proto3" ;
213
314package access_policy.v1 ;
@@ -9,65 +20,114 @@ option go_package = "github.com/geniustechspace/protobuf/gen/go/access_policy/v1
920option java_multiple_files = true ;
1021option java_package = "com.geniustechspace.protobuf.accesspolicy.v1" ;
1122
12- // Permission represents a specific action that can be performed
23+ // Permission represents a granular action that can be performed on a resource.
24+ //
25+ // COMPLIANCE: SOC 2 CC6.1 (Permission granularity), ISO 27001 A.9.2.3
1326message Permission {
27+ // Unique permission identifier
1428 string id = 1 ;
29+
30+ // Human-readable permission name (e.g., "user:create", "billing:read")
1531 string name = 2 ;
32+
33+ // Resource type this permission applies to (e.g., "users", "subscriptions")
1634 string resource = 3 ;
35+
36+ // Action being permitted (e.g., "create", "read", "update", "delete")
1737 string action = 4 ;
38+
39+ // Permission description for documentation
1840 string description = 5 ;
1941}
2042
21- // Role represents a collection of permissions
43+ // Role represents a collection of permissions assigned as a unit.
44+ //
45+ // COMPLIANCE: SOC 2 CC6.1 (Role definition), ISO 27001 A.9.2.1 (User registration)
2246message Role {
47+ // Standard metadata (ID, timestamps, created_by, etc.)
2348 core.v1.Metadata metadata = 1 ;
49+
50+ // Tenant ID for isolation. REQUIRED
2451 string tenant_id = 2 ;
52+
53+ // Role name (e.g., "admin", "editor", "viewer"). REQUIRED, unique per tenant
2554 string name = 3 ;
55+
56+ // Role description for documentation
2657 string description = 4 ;
58+
59+ // Permissions granted by this role
2760 repeated Permission permissions = 5 ;
61+
62+ // System-defined role (cannot be modified/deleted)
2863 bool is_system_role = 6 ;
2964}
3065
31- // Policy defines access rules
66+ // Policy defines conditional access rules with attribute-based evaluation.
67+ //
68+ // COMPLIANCE: SOC 2 CC6.1 (Dynamic access control), NIST SP 800-162 (ABAC)
3269message Policy {
70+ // Standard metadata (ID, timestamps, created_by, etc.)
3371 core.v1.Metadata metadata = 1 ;
72+
73+ // Tenant ID for isolation. REQUIRED
3474 string tenant_id = 2 ;
75+
76+ // Policy name. REQUIRED, unique per tenant
3577 string name = 3 ;
78+
79+ // Policy description
3680 string description = 4 ;
81+
82+ // Access rules defining conditions
3783 repeated PolicyRule rules = 5 ;
84+
85+ // Effect to apply when rules match (allow/deny)
3886 PolicyEffect effect = 6 ;
3987}
4088
41- // PolicyRule defines a specific access rule
89+ // PolicyRule defines resource/action combinations with conditional evaluation.
4290message PolicyRule {
91+ // Resource pattern (e.g., "users/*", "billing/subscriptions/*")
4392 string resource = 1 ;
93+
94+ // Actions permitted on resource (e.g., ["read", "update"])
4495 repeated string actions = 2 ;
96+
97+ // Conditions that must be satisfied for rule to apply
4598 repeated Condition conditions = 3 ;
4699}
47100
48- // Condition for policy evaluation
101+ // Condition represents an attribute-based condition for policy evaluation.
49102message Condition {
103+ // Condition key (e.g., "user.department", "time.hour", "ip.address")
50104 string key = 1 ;
105+
106+ // Comparison operator
51107 ConditionOperator operator = 2 ;
108+
109+ // Values to compare against
52110 repeated string values = 3 ;
53111}
54112
55- // ConditionOperator for condition evaluation
113+ // ConditionOperator defines comparison operators for condition evaluation.
56114enum ConditionOperator {
57115 CONDITION_OPERATOR_UNSPECIFIED = 0 ;
58- CONDITION_OPERATOR_EQUALS = 1 ;
59- CONDITION_OPERATOR_NOT_EQUALS = 2 ;
60- CONDITION_OPERATOR_IN = 3 ;
61- CONDITION_OPERATOR_NOT_IN = 4 ;
62- CONDITION_OPERATOR_CONTAINS = 5 ;
63- CONDITION_OPERATOR_NOT_CONTAINS = 6 ;
116+ CONDITION_OPERATOR_EQUALS = 1 ; // Exact match
117+ CONDITION_OPERATOR_NOT_EQUALS = 2 ; // Not equal
118+ CONDITION_OPERATOR_IN = 3 ; // In list
119+ CONDITION_OPERATOR_NOT_IN = 4 ; // Not in list
120+ CONDITION_OPERATOR_CONTAINS = 5 ; // Contains substring
121+ CONDITION_OPERATOR_NOT_CONTAINS = 6 ; // Does not contain
64122}
65123
66- // PolicyEffect determines whether to allow or deny
124+ // PolicyEffect determines whether access is allowed or denied.
125+ //
126+ // COMPLIANCE: Explicit deny overrides allow (default deny)
67127enum PolicyEffect {
68128 POLICY_EFFECT_UNSPECIFIED = 0 ;
69- POLICY_EFFECT_ALLOW = 1 ;
70- POLICY_EFFECT_DENY = 2 ;
129+ POLICY_EFFECT_ALLOW = 1 ; // Grant access
130+ POLICY_EFFECT_DENY = 2 ; // Deny access (takes precedence)
71131}
72132
73133// CreateRoleRequest for creating a new role
@@ -170,29 +230,40 @@ message CheckPermissionResponse {
170230 string reason = 2 ;
171231}
172232
173- // AccessPolicyService provides access control operations
233+ // AccessPolicyService provides role-based and attribute-based access control.
234+ //
235+ // COMPLIANCE: SOC 2 CC6.1, CC6.2 (Access controls), ISO 27001 A.9.2, A.9.4
236+ // AUTHENTICATION: All RPCs require valid authentication token
237+ // AUTHORIZATION: Requires 'access_policy:admin' permission
238+ // AUDIT: All operations logged with user, timestamp, and changes
174239service AccessPolicyService {
175- // Create a new role
240+ // CreateRole creates a new role with permissions. Requires 'access_policy:admin'.
241+ // COMPLIANCE: SOC 2 CC6.1 (Role creation)
176242 rpc CreateRole (CreateRoleRequest ) returns (CreateRoleResponse );
177243
178- // Get a role by ID
244+ // GetRole retrieves role details. Requires 'access_policy:read'.
179245 rpc GetRole (GetRoleRequest ) returns (GetRoleResponse );
180246
181- // Update a role
247+ // UpdateRole modifies role permissions. Requires 'access_policy:admin'.
248+ // COMPLIANCE: SOC 2 CC6.3 (Change management)
182249 rpc UpdateRole (UpdateRoleRequest ) returns (UpdateRoleResponse );
183250
184- // Delete a role
251+ // DeleteRole removes a role. System roles cannot be deleted. Requires 'access_policy:admin'.
252+ // COMPLIANCE: SOC 2 CC6.2 (Access termination)
185253 rpc DeleteRole (DeleteRoleRequest ) returns (DeleteRoleResponse );
186254
187- // List roles
255+ // ListRoles lists all roles for a tenant. Requires 'access_policy:read'.
188256 rpc ListRoles (ListRolesRequest ) returns (ListRolesResponse );
189257
190- // Assign a role to a user
258+ // AssignRole grants role to user. Requires 'access_policy:admin'.
259+ // COMPLIANCE: SOC 2 CC6.1 (User provisioning)
191260 rpc AssignRole (AssignRoleRequest ) returns (AssignRoleResponse );
192261
193- // Revoke a role from a user
262+ // RevokeRole removes role from user. Requires 'access_policy:admin'.
263+ // COMPLIANCE: SOC 2 CC6.2 (Access revocation)
194264 rpc RevokeRole (RevokeRoleRequest ) returns (RevokeRoleResponse );
195265
196- // Check if a user has permission
266+ // CheckPermission evaluates if user has permission with context. High-frequency operation.
267+ // PERFORMANCE: Cached for 5 minutes. Rate limit: 1000 req/sec per user
197268 rpc CheckPermission (CheckPermissionRequest ) returns (CheckPermissionResponse );
198269}
0 commit comments