OpenStack Identity (Keystone)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
5.5KB

  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. from oslo_policy import policy
  13. from keystone.common.policies import base
  14. user_policies = [
  15. policy.DocumentedRuleDefault(
  16. name=base.IDENTITY % 'get_user',
  17. check_str=base.RULE_ADMIN_OR_OWNER,
  18. # FIXME(lbragstad): First, a system administrator should be able to get
  19. # a user reference for anyone in the system. Second, a project
  20. # administrator should be able to get references for users within the
  21. # project their token is scoped to or their domain. Third, a user
  22. # should be able to get a reference for themselves. This is going to
  23. # require keystone to be smarter about enforcing policy checks in code,
  24. # specifically for the last two cases. Once that is fixed, we can
  25. # uncomment the following line.
  26. # scope_types=['system', 'project'],
  27. description='Show user details.',
  28. operations=[{'path': '/v3/users/{user_id}',
  29. 'method': 'GET'},
  30. {'path': '/v3/users/{user_id}',
  31. 'method': 'HEAD'}]),
  32. policy.DocumentedRuleDefault(
  33. name=base.IDENTITY % 'list_users',
  34. check_str=base.RULE_ADMIN_REQUIRED,
  35. # FIXME(lbragstad): Since listing users has traditionally always been a
  36. # system-level API call, let's maintain that pattern here. A system
  37. # administrator should be able to list all users in the deployment,
  38. # which is what's supported today. Project and domain administrators
  39. # should also be able to list users, but they should only see users
  40. # within their project or domain. Otherwise it would be possible for
  41. # project and domain administrators to see users unrelated to their
  42. # project or domain, which would be a security issue. Once we have that
  43. # support in place, we should update scope_types to include 'project'.
  44. scope_types=['system'],
  45. description='List users.',
  46. operations=[{'path': '/v3/users',
  47. 'method': 'GET'},
  48. {'path': '/v3/users',
  49. 'method': 'HEAD'}]),
  50. policy.DocumentedRuleDefault(
  51. name=base.IDENTITY % 'list_projects_for_user',
  52. check_str='',
  53. # NOTE(lbragstad): We explicitly omit scope_types from this policy
  54. # because it's meant to be called with an unscoped token, which doesn't
  55. # apply to scope_types or its purpose. So long as the user is in the
  56. # system and has a valid token, they should be able to generate a list
  57. # of projects they have access to.
  58. description=('List all projects a user has access to via role '
  59. 'assignments.'),
  60. operations=[{'path': ' /v3/auth/projects',
  61. 'method': 'GET'}]),
  62. policy.DocumentedRuleDefault(
  63. name=base.IDENTITY % 'list_domains_for_user',
  64. check_str='',
  65. # NOTE(lbragstad): We explicitly omit scope_types from this policy
  66. # because it's meant to be called with an unscoped token, which doesn't
  67. # apply to scope_types or its purpose. So long as the user is in the
  68. # system and has a valid token, they should be able to generate a list
  69. # of domains they have access to.
  70. description=('List all domains a user has access to via role '
  71. 'assignments.'),
  72. operations=[{'path': '/v3/auth/domains',
  73. 'method': 'GET'}]),
  74. policy.DocumentedRuleDefault(
  75. name=base.IDENTITY % 'create_user',
  76. check_str=base.RULE_ADMIN_REQUIRED,
  77. # FIXME(lbragstad): This can be considered either a system-level policy
  78. # or a project-level policy. System administrator should have the
  79. # ability to create users in any domain. Domain (or project)
  80. # administrators should have the ability to create users in the domain
  81. # they administer. The second case is going to require a policy check
  82. # in code. Until that happens, we will leave this as a system-level
  83. # policy.
  84. scope_types=['system'],
  85. description='Create a user.',
  86. operations=[{'path': '/v3/users',
  87. 'method': 'POST'}]),
  88. policy.DocumentedRuleDefault(
  89. name=base.IDENTITY % 'update_user',
  90. check_str=base.RULE_ADMIN_REQUIRED,
  91. # FIXME(lbragstad): See the above comment about adding support for
  92. # project scope_types in the future.
  93. scope_types=['system'],
  94. description='Update a user, including administrative password resets.',
  95. operations=[{'path': '/v3/users/{user_id}',
  96. 'method': 'PATCH'}]),
  97. policy.DocumentedRuleDefault(
  98. name=base.IDENTITY % 'delete_user',
  99. check_str=base.RULE_ADMIN_REQUIRED,
  100. # FIXME(lbragstad): See the above comment about adding support for
  101. # project scope_types in the future.
  102. scope_types=['system'],
  103. description='Delete a user.',
  104. operations=[{'path': '/v3/users/{user_id}',
  105. 'method': 'DELETE'}])
  106. ]
  107. def list_rules():
  108. return user_policies