policy.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package types
  2. type PermissionScope string
  3. const (
  4. UserScope PermissionScope = "user"
  5. ProjectScope PermissionScope = "project"
  6. ClusterScope PermissionScope = "cluster"
  7. NamespaceScope PermissionScope = "namespace"
  8. SettingsScope PermissionScope = "settings"
  9. ApplicationScope PermissionScope = "application"
  10. )
  11. type NameOrUInt struct {
  12. Name string `json:"name"`
  13. UInt uint `json:"uint"`
  14. }
  15. type PolicyDocument struct {
  16. Scope PermissionScope `json:"scope"`
  17. Resources []NameOrUInt `json:"resources"`
  18. Verbs []APIVerb `json:"verbs"`
  19. Children map[PermissionScope]*PolicyDocument `json:"children"`
  20. }
  21. type ScopeTree map[PermissionScope]ScopeTree
  22. /* ScopeHeirarchy describes the scope tree:
  23. <<<<<<< HEAD
  24. =======
  25. >>>>>>> master
  26. Project
  27. / \
  28. Cluster Settings
  29. /
  30. Namespace
  31. |
  32. Release
  33. */
  34. var ScopeHeirarchy = ScopeTree{
  35. ProjectScope: {
  36. ClusterScope: {
  37. NamespaceScope: {
  38. ApplicationScope: {},
  39. },
  40. },
  41. SettingsScope: {},
  42. },
  43. }
  44. type Policy []*PolicyDocument
  45. var AdminPolicy = []*PolicyDocument{
  46. {
  47. Scope: ProjectScope,
  48. Verbs: ReadWriteVerbGroup(),
  49. },
  50. }
  51. var DeveloperPolicy = []*PolicyDocument{
  52. {
  53. Scope: ProjectScope,
  54. Verbs: ReadWriteVerbGroup(),
  55. Children: map[PermissionScope]*PolicyDocument{
  56. SettingsScope: {
  57. Scope: SettingsScope,
  58. Verbs: ReadVerbGroup(),
  59. },
  60. },
  61. },
  62. }
  63. var ViewerPolicy = []*PolicyDocument{
  64. {
  65. Scope: ProjectScope,
  66. Verbs: ReadVerbGroup(),
  67. Children: map[PermissionScope]*PolicyDocument{
  68. SettingsScope: {
  69. Scope: SettingsScope,
  70. Verbs: []APIVerb{},
  71. },
  72. },
  73. },
  74. }