permissions.proto 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. // Effective decision for one permission key.
  5. message PermissionGrant {
  6. // Stable permission key, such as "server.manage".
  7. string permission = 1;
  8. // Whether the permission is currently granted.
  9. bool granted = 2;
  10. }
  11. // Effective decision for one capability key.
  12. //
  13. // Built-in keys currently include:
  14. // - admin.view
  15. // - dm.start
  16. // - admin.view-users
  17. // - user.manage-accounts
  18. // - user.invite
  19. // - role.assign
  20. // - role.view
  21. // - role.manage
  22. // - admin.view-system
  23. // - admin.view-audit
  24. // - user.manage-permissions
  25. //
  26. // Clients should ignore unknown keys so servers can add capabilities over time.
  27. message CapabilityGrant {
  28. // Stable capability key, such as "admin.view" or "dm.start".
  29. string capability = 1;
  30. // Whether the capability is currently available.
  31. bool granted = 2;
  32. }
  33. // Scope of effective authority. Channel scopes never include direct messages.
  34. enum EffectivePermissionScopeKind {
  35. // No scope supplied.
  36. EFFECTIVE_PERMISSION_SCOPE_KIND_UNSPECIFIED = 0;
  37. // Server authority or the default for channel rooms.
  38. EFFECTIVE_PERMISSION_SCOPE_KIND_SERVER = 1;
  39. // A channel room group.
  40. EFFECTIVE_PERMISSION_SCOPE_KIND_GROUP = 2;
  41. // One channel room.
  42. EFFECTIVE_PERMISSION_SCOPE_KIND_ROOM = 3;
  43. // Direct-message authority; membership is always required.
  44. EFFECTIVE_PERMISSION_SCOPE_KIND_DM = 4;
  45. }
  46. // Scope metadata visible to the caller.
  47. message EffectivePermissionScope {
  48. // Scope tier.
  49. EffectivePermissionScopeKind kind = 1;
  50. // Room or group ID; empty for server and DM scopes.
  51. string id = 2;
  52. // Current room or group name; empty for server and DM scopes.
  53. string name = 3;
  54. // Parent group ID for a channel room; empty for other scopes.
  55. string parent_group_id = 4;
  56. }
  57. // A permission currently allowed at a scope. Membership and action-specific
  58. // requirements still apply. This is effective authority, not a stored grant.
  59. message EffectivePermission {
  60. // Stable permission identifier.
  61. string permission = 1;
  62. // Scope where the permission is allowed.
  63. EffectivePermissionScope scope = 2;
  64. // True when every applicable child scope also allows this permission.
  65. // Hidden rooms participate in this check without revealing their identities.
  66. // False means clients must not describe this grant as covering all children.
  67. bool covers_descendants = 3;
  68. }
  69. // Read all effective permissions for one account.
  70. message ListEffectivePermissionsRequest {
  71. // Required target account ID.
  72. string user_id = 1 [(buf.validate.field).string.min_len = 1];
  73. }
  74. // All visible effective grants in permission-catalog order, then stable scope-ID order.
  75. // Denied and unconfigured permissions are absent. Inherited and included
  76. // permissions remain separate entries; clients can group them for display.
  77. message ListEffectivePermissionsResponse {
  78. // Effective grants visible to the caller.
  79. repeated EffectivePermission permissions = 1;
  80. }
  81. // Read-only effective authority. Configuration and explanations remain in
  82. // chatto.admin.v1.AdminPermissionService.
  83. service PermissionService {
  84. // Any authenticated member may read a bot's effective permissions. Human
  85. // targets require user.manage-permissions, including self-targeted reads.
  86. // Bot authority includes the owner's current limits. Hidden room identities,
  87. // stored grants, credentials, and individual DM participants are not exposed.
  88. // Missing or deleted targets return NOT_FOUND. Each call returns the complete
  89. // visible set from one coherent read, without pagination or truncation. Clients
  90. // should refresh visible views (the bundled client uses 30 seconds) and clear
  91. // the view on close or read failure.
  92. rpc ListEffectivePermissions(ListEffectivePermissionsRequest) returns (ListEffectivePermissionsResponse);
  93. }