rucio 35.7.0__py3-none-any.whl → 37.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rucio might be problematic. Click here for more details.

Files changed (266) hide show
  1. rucio/alembicrevision.py +1 -1
  2. rucio/{daemons/c3po/collectors → cli}/__init__.py +1 -0
  3. rucio/cli/account.py +216 -0
  4. rucio-35.7.0.data/scripts/rucio → rucio/cli/bin_legacy/rucio.py +769 -486
  5. rucio-35.7.0.data/scripts/rucio-admin → rucio/cli/bin_legacy/rucio_admin.py +476 -423
  6. rucio/cli/command.py +272 -0
  7. rucio/cli/config.py +72 -0
  8. rucio/cli/did.py +191 -0
  9. rucio/cli/download.py +128 -0
  10. rucio/cli/lifetime_exception.py +33 -0
  11. rucio/cli/replica.py +162 -0
  12. rucio/cli/rse.py +293 -0
  13. rucio/cli/rule.py +158 -0
  14. rucio/cli/scope.py +40 -0
  15. rucio/cli/subscription.py +73 -0
  16. rucio/cli/upload.py +60 -0
  17. rucio/cli/utils.py +226 -0
  18. rucio/client/accountclient.py +0 -1
  19. rucio/client/baseclient.py +33 -24
  20. rucio/client/client.py +45 -1
  21. rucio/client/didclient.py +5 -3
  22. rucio/client/downloadclient.py +6 -8
  23. rucio/client/replicaclient.py +0 -2
  24. rucio/client/richclient.py +317 -0
  25. rucio/client/rseclient.py +4 -4
  26. rucio/client/uploadclient.py +26 -12
  27. rucio/common/bittorrent.py +234 -0
  28. rucio/common/cache.py +66 -29
  29. rucio/common/checksum.py +168 -0
  30. rucio/common/client.py +122 -0
  31. rucio/common/config.py +22 -35
  32. rucio/common/constants.py +61 -3
  33. rucio/common/didtype.py +72 -24
  34. rucio/common/dumper/__init__.py +45 -38
  35. rucio/common/dumper/consistency.py +75 -30
  36. rucio/common/dumper/data_models.py +63 -19
  37. rucio/common/dumper/path_parsing.py +19 -8
  38. rucio/common/exception.py +65 -8
  39. rucio/common/extra.py +5 -10
  40. rucio/common/logging.py +13 -13
  41. rucio/common/pcache.py +8 -7
  42. rucio/common/plugins.py +59 -27
  43. rucio/common/policy.py +12 -3
  44. rucio/common/schema/__init__.py +84 -34
  45. rucio/common/schema/generic.py +0 -17
  46. rucio/common/schema/generic_multi_vo.py +0 -17
  47. rucio/common/test_rucio_server.py +12 -6
  48. rucio/common/types.py +132 -52
  49. rucio/common/utils.py +93 -643
  50. rucio/core/account_limit.py +14 -12
  51. rucio/core/authentication.py +2 -2
  52. rucio/core/config.py +23 -42
  53. rucio/core/credential.py +14 -15
  54. rucio/core/did.py +5 -1
  55. rucio/core/did_meta_plugins/elasticsearch_meta.py +407 -0
  56. rucio/core/did_meta_plugins/filter_engine.py +62 -3
  57. rucio/core/did_meta_plugins/json_meta.py +2 -2
  58. rucio/core/did_meta_plugins/mongo_meta.py +43 -30
  59. rucio/core/did_meta_plugins/postgres_meta.py +75 -39
  60. rucio/core/identity.py +6 -5
  61. rucio/core/importer.py +4 -3
  62. rucio/core/lifetime_exception.py +2 -2
  63. rucio/core/lock.py +8 -7
  64. rucio/core/message.py +6 -0
  65. rucio/core/monitor.py +30 -29
  66. rucio/core/naming_convention.py +2 -2
  67. rucio/core/nongrid_trace.py +2 -2
  68. rucio/core/oidc.py +11 -9
  69. rucio/core/permission/__init__.py +79 -37
  70. rucio/core/permission/generic.py +1 -7
  71. rucio/core/permission/generic_multi_vo.py +1 -7
  72. rucio/core/quarantined_replica.py +4 -3
  73. rucio/core/replica.py +464 -139
  74. rucio/core/replica_sorter.py +55 -59
  75. rucio/core/request.py +34 -32
  76. rucio/core/rse.py +301 -97
  77. rucio/core/rse_counter.py +1 -2
  78. rucio/core/rse_expression_parser.py +7 -7
  79. rucio/core/rse_selector.py +9 -7
  80. rucio/core/rule.py +41 -40
  81. rucio/core/rule_grouping.py +42 -40
  82. rucio/core/scope.py +5 -4
  83. rucio/core/subscription.py +26 -28
  84. rucio/core/topology.py +11 -11
  85. rucio/core/trace.py +2 -2
  86. rucio/core/transfer.py +29 -15
  87. rucio/core/volatile_replica.py +4 -3
  88. rucio/daemons/atropos/atropos.py +1 -1
  89. rucio/daemons/auditor/__init__.py +2 -2
  90. rucio/daemons/auditor/srmdumps.py +6 -6
  91. rucio/daemons/automatix/automatix.py +32 -21
  92. rucio/daemons/badreplicas/necromancer.py +2 -2
  93. rucio/daemons/bb8/nuclei_background_rebalance.py +1 -1
  94. rucio/daemons/bb8/t2_background_rebalance.py +1 -1
  95. rucio/daemons/common.py +15 -25
  96. rucio/daemons/conveyor/finisher.py +2 -2
  97. rucio/daemons/conveyor/poller.py +18 -28
  98. rucio/daemons/conveyor/receiver.py +2 -2
  99. rucio/daemons/conveyor/stager.py +1 -0
  100. rucio/daemons/conveyor/submitter.py +3 -3
  101. rucio/daemons/hermes/hermes.py +91 -30
  102. rucio/daemons/judge/evaluator.py +2 -2
  103. rucio/daemons/oauthmanager/oauthmanager.py +3 -3
  104. rucio/daemons/reaper/dark_reaper.py +7 -3
  105. rucio/daemons/reaper/reaper.py +12 -16
  106. rucio/daemons/rsedecommissioner/config.py +1 -1
  107. rucio/daemons/rsedecommissioner/profiles/generic.py +5 -4
  108. rucio/daemons/rsedecommissioner/profiles/types.py +7 -6
  109. rucio/daemons/rsedecommissioner/rse_decommissioner.py +1 -1
  110. rucio/daemons/storage/consistency/actions.py +8 -6
  111. rucio/daemons/tracer/kronos.py +4 -4
  112. rucio/db/sqla/constants.py +5 -0
  113. rucio/db/sqla/migrate_repo/versions/1677d4d803c8_split_rse_availability_into_multiple.py +4 -4
  114. rucio/db/sqla/migrate_repo/versions/30d5206e9cad_increase_oauthrequest_redirect_msg_.py +37 -0
  115. rucio/db/sqla/models.py +157 -154
  116. rucio/db/sqla/session.py +58 -27
  117. rucio/db/sqla/types.py +2 -2
  118. rucio/db/sqla/util.py +2 -2
  119. rucio/gateway/account.py +18 -12
  120. rucio/gateway/account_limit.py +137 -60
  121. rucio/gateway/authentication.py +18 -12
  122. rucio/gateway/config.py +30 -20
  123. rucio/gateway/credential.py +9 -10
  124. rucio/gateway/did.py +70 -53
  125. rucio/gateway/dirac.py +6 -4
  126. rucio/gateway/exporter.py +3 -2
  127. rucio/gateway/heartbeat.py +6 -4
  128. rucio/gateway/identity.py +36 -51
  129. rucio/gateway/importer.py +3 -2
  130. rucio/gateway/lifetime_exception.py +3 -2
  131. rucio/gateway/meta_conventions.py +17 -6
  132. rucio/gateway/permission.py +4 -1
  133. rucio/gateway/quarantined_replica.py +3 -2
  134. rucio/gateway/replica.py +31 -22
  135. rucio/gateway/request.py +27 -18
  136. rucio/gateway/rse.py +69 -37
  137. rucio/gateway/rule.py +46 -26
  138. rucio/gateway/scope.py +3 -2
  139. rucio/gateway/subscription.py +14 -11
  140. rucio/gateway/vo.py +12 -8
  141. rucio/rse/__init__.py +3 -3
  142. rucio/rse/protocols/bittorrent.py +11 -1
  143. rucio/rse/protocols/cache.py +0 -11
  144. rucio/rse/protocols/dummy.py +0 -11
  145. rucio/rse/protocols/gfal.py +14 -9
  146. rucio/rse/protocols/globus.py +1 -1
  147. rucio/rse/protocols/http_cache.py +1 -1
  148. rucio/rse/protocols/posix.py +2 -2
  149. rucio/rse/protocols/protocol.py +84 -317
  150. rucio/rse/protocols/rclone.py +2 -1
  151. rucio/rse/protocols/rfio.py +10 -1
  152. rucio/rse/protocols/ssh.py +2 -1
  153. rucio/rse/protocols/storm.py +2 -13
  154. rucio/rse/protocols/webdav.py +74 -30
  155. rucio/rse/protocols/xrootd.py +2 -1
  156. rucio/rse/rsemanager.py +170 -53
  157. rucio/rse/translation.py +260 -0
  158. rucio/tests/common.py +23 -13
  159. rucio/tests/common_server.py +26 -9
  160. rucio/transfertool/bittorrent.py +15 -14
  161. rucio/transfertool/bittorrent_driver.py +5 -7
  162. rucio/transfertool/bittorrent_driver_qbittorrent.py +9 -8
  163. rucio/transfertool/fts3.py +20 -16
  164. rucio/transfertool/mock.py +2 -3
  165. rucio/vcsversion.py +4 -4
  166. rucio/version.py +7 -0
  167. rucio/web/rest/flaskapi/v1/accounts.py +17 -3
  168. rucio/web/rest/flaskapi/v1/auth.py +5 -5
  169. rucio/web/rest/flaskapi/v1/credentials.py +3 -2
  170. rucio/web/rest/flaskapi/v1/dids.py +21 -15
  171. rucio/web/rest/flaskapi/v1/identities.py +33 -9
  172. rucio/web/rest/flaskapi/v1/redirect.py +5 -4
  173. rucio/web/rest/flaskapi/v1/replicas.py +12 -8
  174. rucio/web/rest/flaskapi/v1/rses.py +15 -4
  175. rucio/web/rest/flaskapi/v1/traces.py +56 -19
  176. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/alembic.ini.template +1 -1
  177. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/alembic_offline.ini.template +1 -1
  178. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/rucio.cfg.atlas.client.template +3 -2
  179. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/rucio.cfg.template +3 -19
  180. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/rucio_multi_vo.cfg.template +1 -18
  181. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/requirements.server.txt +97 -68
  182. rucio-37.0.0.data/scripts/rucio +133 -0
  183. rucio-37.0.0.data/scripts/rucio-admin +97 -0
  184. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-atropos +2 -2
  185. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-auditor +2 -1
  186. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-automatix +2 -2
  187. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-cache-client +17 -10
  188. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-receiver +1 -0
  189. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-kronos +1 -0
  190. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-minos +2 -2
  191. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-minos-temporary-expiration +2 -2
  192. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-necromancer +2 -2
  193. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-reaper +6 -6
  194. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-transmogrifier +2 -2
  195. rucio-37.0.0.dist-info/METADATA +92 -0
  196. {rucio-35.7.0.dist-info → rucio-37.0.0.dist-info}/RECORD +237 -243
  197. {rucio-35.7.0.dist-info → rucio-37.0.0.dist-info}/licenses/AUTHORS.rst +3 -0
  198. rucio/common/schema/atlas.py +0 -413
  199. rucio/common/schema/belleii.py +0 -408
  200. rucio/common/schema/domatpc.py +0 -401
  201. rucio/common/schema/escape.py +0 -426
  202. rucio/common/schema/icecube.py +0 -406
  203. rucio/core/permission/atlas.py +0 -1348
  204. rucio/core/permission/belleii.py +0 -1077
  205. rucio/core/permission/escape.py +0 -1078
  206. rucio/daemons/c3po/algorithms/__init__.py +0 -13
  207. rucio/daemons/c3po/algorithms/simple.py +0 -134
  208. rucio/daemons/c3po/algorithms/t2_free_space.py +0 -128
  209. rucio/daemons/c3po/algorithms/t2_free_space_only_pop.py +0 -130
  210. rucio/daemons/c3po/algorithms/t2_free_space_only_pop_with_network.py +0 -294
  211. rucio/daemons/c3po/c3po.py +0 -371
  212. rucio/daemons/c3po/collectors/agis.py +0 -108
  213. rucio/daemons/c3po/collectors/free_space.py +0 -81
  214. rucio/daemons/c3po/collectors/jedi_did.py +0 -57
  215. rucio/daemons/c3po/collectors/mock_did.py +0 -51
  216. rucio/daemons/c3po/collectors/network_metrics.py +0 -71
  217. rucio/daemons/c3po/collectors/workload.py +0 -112
  218. rucio/daemons/c3po/utils/__init__.py +0 -13
  219. rucio/daemons/c3po/utils/dataset_cache.py +0 -50
  220. rucio/daemons/c3po/utils/expiring_dataset_cache.py +0 -56
  221. rucio/daemons/c3po/utils/expiring_list.py +0 -62
  222. rucio/daemons/c3po/utils/popularity.py +0 -85
  223. rucio/daemons/c3po/utils/timeseries.py +0 -89
  224. rucio/rse/protocols/gsiftp.py +0 -92
  225. rucio-35.7.0.data/scripts/rucio-c3po +0 -85
  226. rucio-35.7.0.dist-info/METADATA +0 -72
  227. /rucio/{daemons/c3po → cli/bin_legacy}/__init__.py +0 -0
  228. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/globus-config.yml.template +0 -0
  229. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/ldap.cfg.template +0 -0
  230. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/mail_templates/rule_approval_request.tmpl +0 -0
  231. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +0 -0
  232. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/mail_templates/rule_approved_user.tmpl +0 -0
  233. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +0 -0
  234. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/mail_templates/rule_denied_user.tmpl +0 -0
  235. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +0 -0
  236. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/etc/rse-accounts.cfg.template +0 -0
  237. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/tools/bootstrap.py +0 -0
  238. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/tools/merge_rucio_configs.py +0 -0
  239. {rucio-35.7.0.data → rucio-37.0.0.data}/data/rucio/tools/reset_database.py +0 -0
  240. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-abacus-account +0 -0
  241. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-abacus-collection-replica +0 -0
  242. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-abacus-rse +0 -0
  243. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-bb8 +0 -0
  244. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-cache-consumer +0 -0
  245. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-finisher +0 -0
  246. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-poller +0 -0
  247. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-preparer +0 -0
  248. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-stager +0 -0
  249. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-submitter +0 -0
  250. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-conveyor-throttler +0 -0
  251. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-dark-reaper +0 -0
  252. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-dumper +0 -0
  253. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-follower +0 -0
  254. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-hermes +0 -0
  255. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-judge-cleaner +0 -0
  256. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-judge-evaluator +0 -0
  257. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-judge-injector +0 -0
  258. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-judge-repairer +0 -0
  259. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-oauth-manager +0 -0
  260. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-replica-recoverer +0 -0
  261. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-rse-decommissioner +0 -0
  262. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-storage-consistency-actions +0 -0
  263. {rucio-35.7.0.data → rucio-37.0.0.data}/scripts/rucio-undertaker +0 -0
  264. {rucio-35.7.0.dist-info → rucio-37.0.0.dist-info}/WHEEL +0 -0
  265. {rucio-35.7.0.dist-info → rucio-37.0.0.dist-info}/licenses/LICENSE +0 -0
  266. {rucio-35.7.0.dist-info → rucio-37.0.0.dist-info}/top_level.txt +0 -0
@@ -1,1348 +0,0 @@
1
- # Copyright European Organization for Nuclear Research (CERN) since 2012
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from typing import TYPE_CHECKING
16
-
17
- import rucio.core.did
18
- import rucio.core.scope
19
- from rucio.common.constants import RseAttr
20
- from rucio.core.account import has_account_attribute, list_account_attributes
21
- from rucio.core.identity import exist_identity_account
22
- from rucio.core.rse import list_rse_attributes
23
- from rucio.core.rse_expression_parser import parse_expression
24
- from rucio.core.rule import get_rule
25
- from rucio.db.sqla.constants import BadPFNStatus, IdentityType
26
-
27
- if TYPE_CHECKING:
28
- from typing import Optional
29
-
30
- from sqlalchemy.orm import Session
31
-
32
- from rucio.common.types import InternalAccount
33
-
34
-
35
- def has_permission(issuer, action, kwargs, *, session: "Optional[Session]" = None):
36
- """
37
- Checks if an account has the specified permission to
38
- execute an action with parameters.
39
-
40
- :param issuer: Account identifier which issues the command..
41
- :param action: The action(API call) called by the account.
42
- :param kwargs: List of arguments for the action.
43
- :param session: The DB session to use
44
- :returns: True if account is allowed, otherwise False
45
- """
46
- perm = {'add_account': perm_add_account,
47
- 'del_account': perm_del_account,
48
- 'update_account': perm_update_account,
49
- 'add_rule': perm_add_rule,
50
- 'add_subscription': perm_add_subscription,
51
- 'add_scope': perm_add_scope,
52
- 'add_rse': perm_add_rse,
53
- 'update_rse': perm_update_rse,
54
- 'add_protocol': perm_add_protocol,
55
- 'del_protocol': perm_del_protocol,
56
- 'update_protocol': perm_update_protocol,
57
- 'add_qos_policy': perm_add_qos_policy,
58
- 'delete_qos_policy': perm_delete_qos_policy,
59
- 'declare_bad_file_replicas': perm_declare_bad_file_replicas,
60
- 'declare_suspicious_file_replicas': perm_declare_suspicious_file_replicas,
61
- 'add_replicas': perm_add_replicas,
62
- 'delete_replicas': perm_delete_replicas,
63
- 'skip_availability_check': perm_skip_availability_check,
64
- 'update_replicas_states': perm_update_replicas_states,
65
- 'add_rse_attribute': perm_add_rse_attribute,
66
- 'del_rse_attribute': perm_del_rse_attribute,
67
- 'del_rse': perm_del_rse,
68
- 'del_rule': perm_del_rule,
69
- 'update_rule': perm_update_rule,
70
- 'approve_rule': perm_approve_rule,
71
- 'update_subscription': perm_update_subscription,
72
- 'reduce_rule': perm_reduce_rule,
73
- 'move_rule': perm_move_rule,
74
- 'get_auth_token_user_pass': perm_get_auth_token_user_pass,
75
- 'get_auth_token_gss': perm_get_auth_token_gss,
76
- 'get_auth_token_x509': perm_get_auth_token_x509,
77
- 'get_auth_token_saml': perm_get_auth_token_saml,
78
- 'add_account_identity': perm_add_account_identity,
79
- 'add_did': perm_add_did,
80
- 'add_dids': perm_add_dids,
81
- 'attach_dids': perm_attach_dids,
82
- 'detach_dids': perm_detach_dids,
83
- 'attach_dids_to_dids': perm_attach_dids_to_dids,
84
- 'create_did_sample': perm_create_did_sample,
85
- 'set_metadata': perm_set_metadata,
86
- 'set_metadata_bulk': perm_set_metadata_bulk,
87
- 'set_status': perm_set_status,
88
- 'queue_requests': perm_queue_requests,
89
- 'set_rse_usage': perm_set_rse_usage,
90
- 'set_rse_limits': perm_set_rse_limits,
91
- 'get_request_by_did': perm_get_request_by_did,
92
- 'get_request_metrics': perm_get_request_metrics,
93
- 'cancel_request': perm_cancel_request,
94
- 'get_next': perm_get_next,
95
- 'set_local_account_limit': perm_set_local_account_limit,
96
- 'set_global_account_limit': perm_set_global_account_limit,
97
- 'delete_local_account_limit': perm_delete_local_account_limit,
98
- 'delete_global_account_limit': perm_delete_global_account_limit,
99
- 'config_sections': perm_config,
100
- 'config_add_section': perm_config,
101
- 'config_has_section': perm_config,
102
- 'config_options': perm_config,
103
- 'config_has_option': perm_config,
104
- 'config_get': perm_config,
105
- 'config_items': perm_config,
106
- 'config_set': perm_config,
107
- 'config_remove_section': perm_config,
108
- 'config_remove_option': perm_config,
109
- 'get_local_account_usage': perm_get_local_account_usage,
110
- 'get_global_account_usage': perm_get_global_account_usage,
111
- 'add_attribute': perm_add_account_attribute,
112
- 'del_attribute': perm_del_account_attribute,
113
- 'list_heartbeats': perm_list_heartbeats,
114
- 'send_heartbeats': perm_send_heartbeats,
115
- 'resurrect': perm_resurrect,
116
- 'update_lifetime_exceptions': perm_update_lifetime_exceptions,
117
- 'get_auth_token_ssh': perm_get_auth_token_ssh,
118
- 'get_signed_url': perm_get_signed_url,
119
- 'add_bad_pfns': perm_add_bad_pfns,
120
- 'del_account_identity': perm_del_account_identity,
121
- 'del_identity': perm_del_identity,
122
- 'remove_did_from_followed': perm_remove_did_from_followed,
123
- 'remove_dids_from_followed': perm_remove_dids_from_followed,
124
- 'add_vo': perm_add_vo,
125
- 'list_vos': perm_list_vos,
126
- 'recover_vo_root_identity': perm_recover_vo_root_identity,
127
- 'update_vo': perm_update_vo,
128
- 'access_rule_vo': perm_access_rule_vo,
129
- 'export': perm_export}
130
-
131
- return perm.get(action, perm_default)(issuer=issuer, kwargs=kwargs, session=session)
132
-
133
-
134
- def _is_root(issuer):
135
- return issuer.external == 'root' or issuer.external == 'ddmadmin'
136
-
137
-
138
- def perm_default(issuer, kwargs, *, session: "Optional[Session]" = None):
139
- """
140
- Default permission.
141
-
142
- :param issuer: Account identifier which issues the command.
143
- :param kwargs: List of arguments for the action.
144
- :param session: The DB session to use
145
- :returns: True if account is allowed, otherwise False
146
- """
147
- return _is_root(issuer)
148
-
149
-
150
- def perm_add_rse(issuer, kwargs, *, session: "Optional[Session]" = None):
151
- """
152
- Checks if an account can add a RSE.
153
-
154
- :param issuer: Account identifier which issues the command.
155
- :param kwargs: List of arguments for the action.
156
- :param session: The DB session to use
157
- :returns: True if account is allowed, otherwise False
158
- """
159
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
160
-
161
-
162
- def perm_update_rse(issuer, kwargs, *, session: "Optional[Session]" = None):
163
- """
164
- Checks if an account can update a RSE.
165
-
166
- :param issuer: Account identifier which issues the command.
167
- :param kwargs: List of arguments for the action.
168
- :param session: The DB session to use
169
- :returns: True if account is allowed, otherwise False
170
- """
171
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
172
-
173
-
174
- def perm_add_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
175
- """
176
- Checks if an account can add a replication rule.
177
-
178
- :param issuer: Account identifier which issues the command.
179
- :param kwargs: List of arguments for the action.
180
- :param session: The DB session to use
181
- :returns: True if account is allowed, otherwise False
182
- """
183
- if kwargs['account'] == issuer and not kwargs['locked']:
184
- return True
185
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
186
- return True
187
-
188
- return False
189
-
190
-
191
- def perm_add_subscription(issuer, kwargs, *, session: "Optional[Session]" = None):
192
- """
193
- Checks if an account can add a subscription.
194
-
195
- :param issuer: Account identifier which issues the command.
196
- :param kwargs: List of arguments for the action.
197
- :param session: The DB session to use
198
- :returns: True if account is allowed, otherwise False
199
- """
200
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
201
- return True
202
-
203
- return False
204
-
205
-
206
- def perm_add_rse_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
207
- """
208
- Checks if an account can add a RSE attribute.
209
-
210
- :param issuer: Account identifier which issues the command.
211
- :param kwargs: List of arguments for the action.
212
- :param session: The DB session to use
213
- :returns: True if account is allowed, otherwise False
214
- """
215
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
216
- return True
217
- if kwargs['key'] in [RseAttr.RULE_DELETERS, RseAttr.AUTO_APPROVE_BYTES, RseAttr.AUTO_APPROVE_FILES, RseAttr.RULE_APPROVERS, RseAttr.DEFAULT_ACCOUNT_LIMIT_BYTES, RseAttr.DEFAULT_LIMIT_FILES, RseAttr.BLOCK_MANUAL_APPROVE]:
218
- # Check if user is a country admin
219
- admin_in_country = []
220
- for kv in list_account_attributes(account=issuer, session=session):
221
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
222
- admin_in_country.append(kv['key'].partition('-')[2])
223
- if admin_in_country:
224
- if list_rse_attributes(rse_id=kwargs['rse_id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
225
- return True
226
- return False
227
-
228
-
229
- def perm_del_rse_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
230
- """
231
- Checks if an account can delete a RSE attribute.
232
-
233
- :param issuer: Account identifier which issues the command.
234
- :param kwargs: List of arguments for the action.
235
- :param session: The DB session to use
236
- :returns: True if account is allowed, otherwise False
237
- """
238
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
239
- return True
240
- if kwargs['key'] in [RseAttr.RULE_DELETERS, RseAttr.AUTO_APPROVE_BYTES, RseAttr.AUTO_APPROVE_FILES, RseAttr.RULE_APPROVERS, RseAttr.DEFAULT_ACCOUNT_LIMIT_BYTES, RseAttr.DEFAULT_LIMIT_FILES, RseAttr.BLOCK_MANUAL_APPROVE]:
241
- # Check if user is a country admin
242
- admin_in_country = []
243
- for kv in list_account_attributes(account=issuer, session=session):
244
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
245
- admin_in_country.append(kv['key'].partition('-')[2])
246
- if admin_in_country:
247
- if list_rse_attributes(rse_id=kwargs['rse_id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
248
- return True
249
- return False
250
-
251
-
252
- def perm_del_rse(issuer, kwargs, *, session: "Optional[Session]" = None):
253
- """
254
- Checks if an account can delete a RSE.
255
-
256
- :param issuer: Account identifier which issues the command.
257
- :param kwargs: List of arguments for the action.
258
- :param session: The DB session to use
259
- :returns: True if account is allowed, otherwise False
260
- """
261
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
262
-
263
-
264
- def perm_add_account(issuer, kwargs, *, session: "Optional[Session]" = None):
265
- """
266
- Checks if an account can add an account.
267
-
268
- :param issuer: Account identifier which issues the command.
269
- :param kwargs: List of arguments for the action.
270
- :param session: The DB session to use
271
- :returns: True if account is allowed, otherwise False
272
- """
273
- return _is_root(issuer)
274
-
275
-
276
- def perm_del_account(issuer, kwargs, *, session: "Optional[Session]" = None):
277
- """
278
- Checks if an account can del an account.
279
-
280
- :param issuer: Account identifier which issues the command.
281
- :param kwargs: List of arguments for the action.
282
- :param session: The DB session to use
283
- :returns: True if account is allowed, otherwise False
284
- """
285
- return _is_root(issuer)
286
-
287
-
288
- def perm_update_account(issuer, kwargs, *, session: "Optional[Session]" = None):
289
- """
290
- Checks if an account can update an account.
291
-
292
- :param issuer: Account identifier which issues the command.
293
- :param kwargs: List of arguments for the action.
294
- :param session: The DB session to use
295
- :returns: True if account is allowed, otherwise False
296
- """
297
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
298
-
299
-
300
- def perm_add_scope(issuer, kwargs, *, session: "Optional[Session]" = None):
301
- """
302
- Checks if an account can add a scop to a account.
303
-
304
- :param issuer: Account identifier which issues the command.
305
- :param kwargs: List of arguments for the action.
306
- :param session: The DB session to use
307
- :returns: True if account is allowed, otherwise False
308
- """
309
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
310
-
311
-
312
- def perm_get_auth_token_user_pass(issuer, kwargs, *, session: "Optional[Session]" = None):
313
- """
314
- Checks if a user can request a token with user_pass for an account.
315
-
316
- :param issuer: Account identifier which issues the command.
317
- :param kwargs: List of arguments for the action.
318
- :param session: The DB session to use
319
- :returns: True if account is allowed, otherwise False
320
- """
321
- if exist_identity_account(identity=kwargs['username'], type_=IdentityType.USERPASS, account=kwargs['account'], session=session):
322
- return True
323
- return False
324
-
325
-
326
- def perm_get_auth_token_gss(issuer, kwargs, *, session: "Optional[Session]" = None):
327
- """
328
- Checks if a user can request a token with user_pass for an account.
329
-
330
- :param issuer: Account identifier which issues the command.
331
- :param kwargs: List of arguments for the action.
332
- :param session: The DB session to use
333
- :returns: True if account is allowed, otherwise False
334
- """
335
- if exist_identity_account(identity=kwargs['gsscred'], type_=IdentityType.GSS, account=kwargs['account'], session=session):
336
- return True
337
- return False
338
-
339
-
340
- def perm_get_auth_token_x509(issuer, kwargs, *, session: "Optional[Session]" = None):
341
- """
342
- Checks if a user can request a token with user_pass for an account.
343
-
344
- :param issuer: Account identifier which issues the command.
345
- :param kwargs: List of arguments for the action.
346
- :param session: The DB session to use
347
- :returns: True if account is allowed, otherwise False
348
- """
349
- if exist_identity_account(identity=kwargs['dn'], type_=IdentityType.X509, account=kwargs['account'], session=session):
350
- return True
351
- return False
352
-
353
-
354
- def perm_get_auth_token_saml(issuer, kwargs, *, session: "Optional[Session]" = None):
355
- """
356
- Checks if a user can request a token with saml_nameid for an account.
357
-
358
- :param issuer: Account identifier which issues the command.
359
- :param kwargs: List of arguments for the action.
360
- :param session: The DB session to use
361
- :returns: True if account is allowed, otherwise False
362
- """
363
- if exist_identity_account(identity=kwargs['saml_nameid'], type_=IdentityType.SAML, account=kwargs['account'], session=session):
364
- return True
365
- return False
366
-
367
-
368
- def perm_add_account_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
369
- """
370
- Checks if an account can add an identity to an account.
371
-
372
- :param issuer: Account identifier which issues the command.
373
- :param kwargs: List of arguments for the action.
374
- :param session: The DB session to use
375
- :returns: True if account is allowed, otherwise False
376
- """
377
-
378
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
379
-
380
-
381
- def perm_del_account_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
382
- """
383
- Checks if an account can delete an identity to an account.
384
-
385
- :param issuer: Account identifier which issues the command.
386
- :param kwargs: List of arguments for the action.
387
- :param session: The DB session to use
388
- :returns: True if account is allowed, otherwise False
389
- """
390
-
391
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
392
-
393
-
394
- def perm_del_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
395
- """
396
- Checks if an account can delete an identity.
397
-
398
- :param issuer: Account identifier which issues the command.
399
- :param kwargs: List of arguments for the action.
400
- :param session: The DB session to use
401
- :returns: True if account is allowed, otherwise False
402
- """
403
-
404
- return _is_root(issuer) or issuer.external in kwargs.get('accounts')
405
-
406
-
407
- def perm_add_did(issuer, kwargs, *, session: "Optional[Session]" = None):
408
- """
409
- Checks if an account can add an data identifier to a scope.
410
-
411
- :param issuer: Account identifier which issues the command.
412
- :param kwargs: List of arguments for the action.
413
- :param session: The DB session to use
414
- :returns: True if account is allowed, otherwise False
415
- """
416
- # Check the accounts of the issued rules
417
- if not _is_root(issuer) and not has_account_attribute(account=issuer, key='admin', session=session):
418
- for rule in kwargs.get('rules', []):
419
- if rule['account'] != issuer:
420
- return False
421
-
422
- return _is_root(issuer)\
423
- or has_account_attribute(account=issuer, key='admin', session=session)\
424
- or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)\
425
- or kwargs['scope'].external == 'mock'
426
-
427
-
428
- def perm_add_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
429
- """
430
- Checks if an account can bulk add data identifiers.
431
-
432
- :param issuer: Account identifier which issues the command.
433
- :param kwargs: List of arguments for the action.
434
- :param session: The DB session to use
435
- :returns: True if account is allowed, otherwise False
436
- """
437
- # Check the accounts of the issued rules
438
- if not _is_root(issuer) and not has_account_attribute(account=issuer, key='admin', session=session):
439
- for did in kwargs['dids']:
440
- for rule in did.get('rules', []):
441
- if rule['account'] != issuer:
442
- return False
443
-
444
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
445
-
446
-
447
- def perm_attach_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
448
- """
449
- Checks if an account can append an data identifier to the other data identifier.
450
-
451
- :param issuer: Account identifier which issues the command.
452
- :param kwargs: List of arguments for the action.
453
- :param session: The DB session to use
454
- :returns: True if account is allowed, otherwise False
455
- """
456
- return _is_root(issuer)\
457
- or has_account_attribute(account=issuer, key='admin', session=session)\
458
- or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)\
459
- or kwargs['scope'].external == 'mock'
460
-
461
-
462
- def perm_attach_dids_to_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
463
- """
464
- Checks if an account can append an data identifier to the other data identifier.
465
-
466
- :param issuer: Account identifier which issues the command.
467
- :param kwargs: List of arguments for the action.
468
- :param session: The DB session to use
469
- :returns: True if account is allowed, otherwise False
470
- """
471
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
472
- return True
473
- attachments = kwargs['attachments']
474
- scopes = [did['scope'] for did in attachments]
475
- scopes = list(set(scopes))
476
- for scope in scopes:
477
- if not rucio.core.scope.is_scope_owner(scope, issuer, session=session):
478
- return False
479
- return True
480
-
481
-
482
- def perm_create_did_sample(issuer, kwargs, *, session: "Optional[Session]" = None):
483
- """
484
- Checks if an account can create a sample of a data identifier collection.
485
-
486
- :param issuer: Account identifier which issues the command.
487
- :param kwargs: List of arguments for the action.
488
- :param session: The DB session to use
489
- :returns: True if account is allowed, otherwise False
490
- """
491
- return _is_root(issuer)\
492
- or has_account_attribute(account=issuer, key='admin', session=session)\
493
- or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)\
494
- or kwargs['scope'].external == 'mock'
495
-
496
-
497
- def perm_del_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
498
- """
499
- Checks if an issuer can delete a replication rule.
500
-
501
- :param issuer: Account identifier which issues the command.
502
- :param kwargs: List of arguments for the action.
503
- :param session: The DB session to use
504
- :returns: True if account is allowed to call the API call, otherwise False
505
- """
506
- if _is_root(issuer):
507
- return True
508
- if get_rule(rule_id=kwargs['rule_id'], session=session)['account'] == issuer:
509
- return True
510
-
511
- # Check if user is a country admin
512
- admin_in_country = []
513
- for kv in list_account_attributes(account=issuer, session=session):
514
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
515
- admin_in_country.append(kv['key'].partition('-')[2])
516
-
517
- rule = get_rule(rule_id=kwargs['rule_id'], session=session)
518
- rses = parse_expression(rule['rse_expression'], filter_={'vo': issuer.vo}, session=session)
519
- if admin_in_country:
520
- for rse in rses:
521
- if list_rse_attributes(rse_id=rse['id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
522
- return True
523
-
524
- # DELETERS can approve the rule
525
- for rse in rses:
526
- rse_attr = list_rse_attributes(rse_id=rse['id'], session=session)
527
- if rse_attr.get(RseAttr.RULE_DELETERS):
528
- if issuer.external in rse_attr.get(RseAttr.RULE_DELETERS).split(','):
529
- return True
530
-
531
- return False
532
-
533
-
534
- def perm_update_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
535
- """
536
- Checks if an issuer can update a replication rule.
537
-
538
- :param issuer: Account identifier which issues the command.
539
- :param kwargs: List of arguments for the action.
540
- :param session: The DB session to use
541
- :returns: True if account is allowed to call the API call, otherwise False
542
- """
543
- # Admin accounts can do everything
544
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
545
- return True
546
-
547
- admin_reserved = {'account', 'state', 'priority', 'child_rule_id', 'meta', 'boost_rule'}
548
- if admin_reserved.intersection(kwargs['options'].keys()):
549
- return False # Only priv accounts are allowed to change that
550
-
551
- # Country admins are allowed to change the rest.
552
- admin_in_country = []
553
- for kv in list_account_attributes(account=issuer, session=session):
554
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
555
- admin_in_country.append(kv['key'].partition('-')[2])
556
-
557
- rule = get_rule(rule_id=kwargs['rule_id'], session=session)
558
- rses = parse_expression(rule['rse_expression'], filter_={'vo': issuer.vo}, session=session)
559
- if admin_in_country:
560
- for rse in rses:
561
- if list_rse_attributes(rse_id=rse['id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
562
- return True
563
-
564
- # Only admin and country-admin are allowed to change locked state of rule
565
- if 'locked' in kwargs['options']:
566
- return False
567
-
568
- # Owner can change the rest of a rule
569
- if get_rule(kwargs['rule_id'], session=session)['account'] == issuer:
570
- return True
571
-
572
- return False
573
-
574
-
575
- def perm_move_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
576
- """
577
- Checks if an issuer can move a replication rule.
578
-
579
- :param issuer: Account identifier which issues the command.
580
- :param kwargs: List of arguments for the action.
581
- :param session: The DB session to use
582
- :returns: True if account is allowed to call the API call, otherwise False
583
- """
584
- # Admin accounts can do everything
585
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
586
- return True
587
-
588
- # Country admins are allowed to change the but need to be admin for the original, as well as future rule
589
- admin_in_country = []
590
- for kv in list_account_attributes(account=issuer, session=session):
591
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
592
- admin_in_country.append(kv['key'].partition('-')[2])
593
-
594
- admin_source = False
595
- admin_destination = False
596
-
597
- if admin_in_country:
598
- rule = get_rule(rule_id=kwargs['rule_id'], session=session)
599
- rses = parse_expression(rule['rse_expression'], filter_={'vo': issuer.vo}, session=session)
600
- for rse in rses:
601
- if list_rse_attributes(rse_id=rse['id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
602
- admin_source = True
603
- break
604
-
605
- rses = parse_expression(kwargs['rse_expression'], filter_={'vo': issuer.vo}, session=session)
606
- for rse in rses:
607
- if list_rse_attributes(rse_id=rse['id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
608
- admin_destination = True
609
- break
610
-
611
- if admin_source and admin_destination:
612
- return True
613
-
614
- return False
615
-
616
-
617
- def perm_approve_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
618
- """
619
- Checks if an issuer can approve a replication rule.
620
-
621
- :param issuer: Account identifier which issues the command.
622
- :param kwargs: List of arguments for the action.
623
- :param session: The DB session to use
624
- :returns: True if account is allowed to call the API call, otherwise False
625
- """
626
- # Admin accounts can do everything
627
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
628
- return True
629
-
630
- rule = get_rule(rule_id=kwargs['rule_id'], session=session)
631
- rses = parse_expression(rule['rse_expression'], filter_={'vo': issuer.vo}, session=session)
632
-
633
- # APPROVERS can approve the rule
634
- for rse in rses:
635
- rse_attr = list_rse_attributes(rse_id=rse['id'], session=session)
636
- if rse_attr.get(RseAttr.RULE_APPROVERS):
637
- if issuer.external in rse_attr.get(RseAttr.RULE_APPROVERS).split(','):
638
- return True
639
-
640
- # LOCALGROUPDISK/LOCALGROUPTAPE admins can approve the rule
641
- admin_in_country = []
642
- for kv in list_account_attributes(account=issuer, session=session):
643
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
644
- admin_in_country.append(kv['key'].partition('-')[2])
645
- if admin_in_country:
646
- for rse in rses:
647
- rse_attr = list_rse_attributes(rse_id=rse['id'], session=session)
648
- if rse_attr.get(RseAttr.TYPE, '') in ('LOCALGROUPDISK', 'LOCALGROUPTAPE'):
649
- if rse_attr.get(RseAttr.COUNTRY, '') in admin_in_country:
650
- return True
651
-
652
- # GROUPDISK admins can approve the rule
653
- admin_for_phys_group = []
654
- for kv in list_account_attributes(account=issuer, session=session):
655
- if kv['key'].startswith('group-') and kv['value'] == 'admin':
656
- admin_for_phys_group.append(kv['key'].partition('-')[2])
657
- if admin_for_phys_group:
658
- for rse in rses:
659
- rse_attr = list_rse_attributes(rse_id=rse['id'], session=session)
660
- if rse_attr.get(RseAttr.TYPE, '') == 'GROUPDISK':
661
- if rse_attr.get(RseAttr.PHYSGROUP, '') in admin_for_phys_group:
662
- return True
663
-
664
- return False
665
-
666
-
667
- def perm_reduce_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
668
- """
669
- Checks if an issuer can reduce a replication rule.
670
-
671
- :param issuer: Account identifier which issues the command.
672
- :param kwargs: List of arguments for the action.
673
- :param session: The DB session to use
674
- :returns: True if account is allowed to call the API call, otherwise False
675
- """
676
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
677
- return True
678
- return False
679
-
680
-
681
- def perm_update_subscription(issuer, kwargs, *, session: "Optional[Session]" = None):
682
- """
683
- Checks if an account can update a subscription.
684
-
685
- :param issuer: Account identifier which issues the command.
686
- :param kwargs: List of arguments for the action.
687
- :param session: The DB session to use
688
- :returns: True if account is allowed, otherwise False
689
- """
690
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
691
- return True
692
-
693
- return False
694
-
695
-
696
- def perm_detach_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
697
- """
698
- Checks if an account can detach an data identifier from the other data identifier.
699
-
700
- :param issuer: Account identifier which issues the command.
701
- :param kwargs: List of arguments for the action.
702
- :param session: The DB session to use
703
- :returns: True if account is allowed, otherwise False
704
- """
705
- return perm_attach_dids(issuer, kwargs, session=session)
706
-
707
-
708
- def perm_set_metadata_bulk(issuer: "InternalAccount", kwargs: dict, *, session: "Optional[Session]" = None) -> bool:
709
- """
710
- Checks if an account can set a metadata on a data identifier.
711
-
712
- :param issuer: Account identifier which issues the command.
713
- :param kwargs: List of arguments for the action.
714
- :param session: The DB session to use
715
- :returns: True if account is allowed, otherwise False
716
- """
717
- return perm_set_metadata(issuer, kwargs, session=session)
718
-
719
-
720
- def perm_set_metadata(issuer, kwargs, *, session: "Optional[Session]" = None):
721
- """
722
- Checks if an account can set a metadata on a data identifier.
723
-
724
- :param issuer: Account identifier which issues the command.
725
- :param kwargs: List of arguments for the action.
726
- :param session: The DB session to use
727
- :returns: True if account is allowed, otherwise False
728
- """
729
- cond = _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
730
- if kwargs['scope'].external != 'archive':
731
- return cond or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)
732
- meta = rucio.core.did.get_metadata(scope=kwargs['scope'], name=kwargs['name'], session=session)
733
- return cond or meta.get('account', False) == issuer
734
-
735
-
736
- def perm_set_status(issuer, kwargs, *, session: "Optional[Session]" = None):
737
- """
738
- Checks if an account can set status on an data identifier.
739
-
740
- :param issuer: Account identifier which issues the command.
741
- :param kwargs: List of arguments for the action.
742
- :param session: The DB session to use
743
- :returns: True if account is allowed, otherwise False
744
- """
745
- if kwargs.get('open', False):
746
- if not _is_root(issuer) and not has_account_attribute(account=issuer, key='admin', session=session):
747
- return False
748
- cond = (_is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session))
749
- if kwargs['scope'].external != 'archive':
750
- return cond or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)
751
- meta = rucio.core.did.get_metadata(scope=kwargs['scope'], name=kwargs['name'], session=session)
752
- return cond or meta.get('account', False) == issuer
753
-
754
-
755
- def perm_add_protocol(issuer, kwargs, *, session: "Optional[Session]" = None):
756
- """
757
- Checks if an account can add a protocol to an RSE.
758
-
759
- :param issuer: Account identifier which issues the command.
760
- :param kwargs: List of arguments for the action.
761
- :param session: The DB session to use
762
- :returns: True if account is allowed, otherwise False
763
- """
764
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
765
-
766
-
767
- def perm_del_protocol(issuer, kwargs, *, session: "Optional[Session]" = None):
768
- """
769
- Checks if an account can delete protocols from an RSE.
770
-
771
- :param issuer: Account identifier which issues the command.
772
- :param kwargs: List of arguments for the action.
773
- :param session: The DB session to use
774
- :returns: True if account is allowed, otherwise False
775
- """
776
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
777
-
778
-
779
- def perm_update_protocol(issuer, kwargs, *, session: "Optional[Session]" = None):
780
- """
781
- Checks if an account can update protocols of an RSE.
782
-
783
- :param issuer: Account identifier which issues the command.
784
- :param kwargs: List of arguments for the action.
785
- :param session: The DB session to use
786
- :returns: True if account is allowed, otherwise False
787
- """
788
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
789
-
790
-
791
- def perm_add_qos_policy(issuer, kwargs, *, session: "Optional[Session]" = None):
792
- """
793
- Checks if an account can add QoS policies to an RSE.
794
-
795
- :param issuer: Account identifier which issues the command.
796
- :param kwargs: List of arguments for the action.
797
- :param session: The DB session to use
798
- :returns: True if account is allowed, otherwise False
799
- """
800
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
801
-
802
-
803
- def perm_delete_qos_policy(issuer, kwargs, *, session: "Optional[Session]" = None):
804
- """
805
- Checks if an account can delete QoS policies from an RSE.
806
-
807
- :param issuer: Account identifier which issues the command.
808
- :param kwargs: List of arguments for the action.
809
- :param session: The DB session to use
810
- :returns: True if account is allowed, otherwise False
811
- """
812
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
813
-
814
-
815
- def perm_declare_bad_file_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
816
- """
817
- Checks if an account can declare bad file replicas.
818
-
819
- :param issuer: Account identifier which issues the command.
820
- :param kwargs: List of arguments for the action.
821
- :param session: The DB session to use
822
- :returns: True if account is allowed, otherwise False
823
- """
824
- is_cloud_admin = bool([acc_attr for acc_attr in list_account_attributes(account=issuer, session=session) if (acc_attr['key'].startswith('cloud-')) and (acc_attr['value'] == 'admin')])
825
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or is_cloud_admin
826
-
827
-
828
- def perm_declare_suspicious_file_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
829
- """
830
- Checks if an account can declare suspicious file replicas.
831
-
832
- :param issuer: Account identifier which issues the command.
833
- :param kwargs: List of arguments for the action.
834
- :param session: The DB session to use
835
- :returns: True if account is allowed, otherwise False
836
- """
837
- return True
838
-
839
-
840
- def perm_add_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
841
- """
842
- Checks if an account can add replicas.
843
-
844
- :param issuer: Account identifier which issues the command.
845
- :param kwargs: List of arguments for the action.
846
- :param session: The DB session to use
847
- :returns: True if account is allowed, otherwise False
848
- """
849
- rse_id = str(kwargs.get('rse_id', ''))
850
- group = []
851
-
852
- for kv in list_account_attributes(account=issuer, session=session):
853
- if (kv['key'].startswith('group-') or kv['key'].startswith('country-')) and kv['value'] in ['admin', 'user']:
854
- group.append(kv['key'].partition('-')[2])
855
- rse_attr = list_rse_attributes(rse_id=rse_id, session=session)
856
- if group:
857
- if rse_attr.get(RseAttr.TYPE, '') == 'GROUPDISK':
858
- if rse_attr.get(RseAttr.PHYSGROUP, '') in group:
859
- return True
860
- if rse_attr.get(RseAttr.TYPE, '') == 'LOCALGROUPDISK':
861
- if rse_attr.get(RseAttr.COUNTRY, '') in group:
862
- return True
863
-
864
- return rse_attr.get(RseAttr.TYPE, '') in ['SCRATCHDISK', 'MOCK', 'TEST']\
865
- or _is_root(issuer)\
866
- or has_account_attribute(account=issuer, key='admin', session=session)
867
-
868
-
869
- def perm_skip_availability_check(issuer, kwargs, *, session: "Optional[Session]" = None):
870
- """
871
- Checks if an account can skip the availabity check to add/delete file replicas.
872
-
873
- :param issuer: Account identifier which issues the command.
874
- :param kwargs: List of arguments for the action.
875
- :param session: The DB session to use
876
- :returns: True if account is allowed, otherwise False
877
- """
878
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
879
-
880
-
881
- def perm_delete_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
882
- """
883
- Checks if an account can delete replicas.
884
-
885
- :param issuer: Account identifier which issues the command.
886
- :param kwargs: List of arguments for the action.
887
- :param session: The DB session to use
888
- :returns: True if account is allowed, otherwise False
889
- """
890
- return False
891
-
892
-
893
- def perm_update_replicas_states(issuer, kwargs, *, session: "Optional[Session]" = None):
894
- """
895
- Checks if an account can delete replicas.
896
-
897
- :param issuer: Account identifier which issues the command.
898
- :param kwargs: List of arguments for the action.
899
- :param session: The DB session to use
900
- :returns: True if account is allowed, otherwise False
901
- """
902
- rse_id = str(kwargs.get('rse_id', ''))
903
- group = []
904
-
905
- for kv in list_account_attributes(account=issuer, session=session):
906
- if (kv['key'].startswith('group-') or kv['key'].startswith('country-')) and kv['value'] in ['admin', 'user']:
907
- group.append(kv['key'].partition('-')[2])
908
- rse_attr = list_rse_attributes(rse_id=rse_id, session=session)
909
- if group:
910
- if rse_attr.get(RseAttr.TYPE, '') == 'GROUPDISK':
911
- if rse_attr.get(RseAttr.PHYSGROUP, '') in group:
912
- return True
913
- if rse_attr.get(RseAttr.TYPE, '') == 'LOCALGROUPDISK':
914
- if rse_attr.get(RseAttr.COUNTRY, '') in group:
915
- return True
916
-
917
- return rse_attr.get(RseAttr.TYPE, '') in ['SCRATCHDISK', 'MOCK', 'TEST']\
918
- or _is_root(issuer)\
919
- or has_account_attribute(account=issuer, key='admin', session=session)
920
-
921
-
922
- def perm_queue_requests(issuer, kwargs, *, session: "Optional[Session]" = None):
923
- """
924
- Checks if an account can submit transfer or deletion requests on destination RSEs for data identifiers.
925
-
926
- :param issuer: Account identifier which issues the command.
927
- :param kwargs: List of arguments for the action.
928
- :param session: The DB session to use
929
- :returns: True if account is allowed, otherwise False
930
- """
931
- return _is_root(issuer)
932
-
933
-
934
- def perm_get_request_by_did(issuer, kwargs, *, session: "Optional[Session]" = None):
935
- """
936
- Checks if an account can get a request by DID.
937
-
938
- :param issuer: Account identifier which issues the command.
939
- :param kwargs: List of arguments for the action.
940
- :param session: The DB session to use
941
- :returns: True if account is allowed, otherwise False
942
- """
943
- return True
944
-
945
-
946
- def perm_get_request_metrics(issuer, kwargs, *, session: "Optional[Session]" = None):
947
- """
948
- Checks if an account can get the request stats
949
-
950
- :param issuer: Account identifier which issues the command.
951
- :param kwargs: List of arguments for the action.
952
- :param session: The DB session to use
953
- :returns: True if account is allowed, otherwise False
954
- """
955
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
956
-
957
-
958
- def perm_cancel_request(issuer, kwargs, *, session: "Optional[Session]" = None):
959
- """
960
- Checks if an account can cancel a request.
961
-
962
- :param issuer: Account identifier which issues the command.
963
- :param kwargs: List of arguments for the action.
964
- :param session: The DB session to use
965
- :returns: True if account is allowed, otherwise False
966
- """
967
- return _is_root(issuer)
968
-
969
-
970
- def perm_get_next(issuer, kwargs, *, session: "Optional[Session]" = None):
971
- """
972
- Checks if an account can retrieve the next request matching the request type and state.
973
-
974
- :param issuer: Account identifier which issues the command.
975
- :param kwargs: List of arguments for the action.
976
- :param session: The DB session to use
977
- :returns: True if account is allowed, otherwise False
978
- """
979
- return _is_root(issuer)
980
-
981
-
982
- def perm_set_rse_usage(issuer, kwargs, *, session: "Optional[Session]" = None):
983
- """
984
- Checks if an account can set RSE usage information.
985
-
986
- :param issuer: Account identifier which issues the command.
987
- :param kwargs: List of arguments for the action.
988
- :param session: The DB session to use
989
- :returns: True if account is allowed to call the API call, otherwise False
990
- """
991
- return _is_root(issuer)
992
-
993
-
994
- def perm_set_rse_limits(issuer, kwargs, *, session: "Optional[Session]" = None):
995
- """
996
- Checks if an account can set RSE limits.
997
-
998
- :param issuer: Account identifier which issues the command.
999
- :param kwargs: List of arguments for the action.
1000
- :param session: The DB session to use
1001
- :returns: True if account is allowed to call the API call, otherwise False
1002
- """
1003
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
1004
-
1005
-
1006
- def perm_set_local_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
1007
- """
1008
- Checks if an account can set an account limit.
1009
-
1010
- :param account: Account identifier which issues the command.
1011
- :param kwargs: List of arguments for the action.
1012
- :param session: The DB session to use
1013
- :returns: True if account is allowed, otherwise False
1014
- """
1015
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
1016
- return True
1017
- # Check if user is a country admin
1018
- admin_in_country = []
1019
- for kv in list_account_attributes(account=issuer, session=session):
1020
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
1021
- admin_in_country.append(kv['key'].partition('-')[2])
1022
- rse_attr = list_rse_attributes(rse_id=kwargs['rse_id'], session=session)
1023
- if admin_in_country and rse_attr.get(RseAttr.COUNTRY) in admin_in_country:
1024
- return True
1025
- quota_approvers = rse_attr.get(RseAttr.QUOTA_APPROVERS, None)
1026
- if quota_approvers and issuer.external in quota_approvers.split(','):
1027
- return True
1028
- return False
1029
-
1030
-
1031
- def perm_set_global_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
1032
- """
1033
- Checks if an account can set a global account limit.
1034
-
1035
- :param account: Account identifier which issues the command.
1036
- :param kwargs: List of arguments for the action.
1037
- :param session: The DB session to use
1038
- :returns: True if account is allowed, otherwise False
1039
- """
1040
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
1041
- return True
1042
- # Check if user is a country admin
1043
- admin_in_country = set()
1044
- for kv in list_account_attributes(account=issuer, session=session):
1045
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
1046
- admin_in_country.add(kv['key'].partition('-')[2])
1047
- resolved_rse_countries = {list_rse_attributes(rse_id=rse['rse_id'], session=session).get(RseAttr.COUNTRY)
1048
- for rse in parse_expression(kwargs['rse_expression'], filter_={'vo': issuer.vo}, session=session)}
1049
- if resolved_rse_countries.issubset(admin_in_country):
1050
- return True
1051
- return False
1052
-
1053
-
1054
- def perm_delete_global_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
1055
- """
1056
- Checks if an account can delete a global account limit.
1057
-
1058
- :param issuer: Account identifier which issues the command.
1059
- :param kwargs: List of arguments for the action.
1060
- :param session: The DB session to use
1061
- :returns: True if account is allowed, otherwise False
1062
- """
1063
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
1064
- return True
1065
- # Check if user is a country admin
1066
- admin_in_country = set()
1067
- for kv in list_account_attributes(account=issuer, session=session):
1068
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
1069
- admin_in_country.add(kv['key'].partition('-')[2])
1070
- resolved_rse_countries = {list_rse_attributes(rse_id=rse['rse_id'], session=session).get(RseAttr.COUNTRY)
1071
- for rse in parse_expression(kwargs['rse_expression'], filter_={'vo': issuer.vo}, session=session)}
1072
- if resolved_rse_countries.issubset(admin_in_country):
1073
- return True
1074
- return False
1075
-
1076
-
1077
- def perm_delete_local_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
1078
- """
1079
- Checks if an account can delete an account limit.
1080
-
1081
- :param account: Account identifier which issues the command.
1082
- :param kwargs: List of arguments for the action.
1083
- :param session: The DB session to use
1084
- :returns: True if account is allowed, otherwise False
1085
- """
1086
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
1087
- return True
1088
- # Check if user is a country admin
1089
- admin_in_country = []
1090
- for kv in list_account_attributes(account=issuer, session=session):
1091
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
1092
- admin_in_country.append(kv['key'].partition('-')[2])
1093
- rse_attr = list_rse_attributes(rse_id=kwargs['rse_id'], session=session)
1094
- if admin_in_country and rse_attr.get(RseAttr.COUNTRY) in admin_in_country:
1095
- return True
1096
- quota_approvers = rse_attr.get(RseAttr.QUOTA_APPROVERS, None)
1097
- if quota_approvers and issuer.external in quota_approvers.split(','):
1098
- return True
1099
- return False
1100
-
1101
-
1102
- def perm_config(issuer, kwargs, *, session: "Optional[Session]" = None):
1103
- """
1104
- Checks if an account can read/write the configuration.
1105
-
1106
- :param issuer: Account identifier which issues the command.
1107
- :param kwargs: List of arguments for the action.
1108
- :param session: The DB session to use
1109
- :returns: True if account is allowed to call the API call, otherwise False
1110
- """
1111
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
1112
-
1113
-
1114
- def perm_get_local_account_usage(issuer, kwargs, *, session: "Optional[Session]" = None):
1115
- """
1116
- Checks if an account can get the account usage of an account.
1117
-
1118
- :param issuer: Account identifier which issues the command.
1119
- :param kwargs: List of arguments for the action.
1120
- :param session: The DB session to use
1121
- :returns: True if account is allowed, otherwise False
1122
- """
1123
- return True
1124
-
1125
-
1126
- def perm_get_global_account_usage(issuer: str, kwargs: dict[str, str], *, session: "Optional[Session]" = None) -> bool:
1127
- """
1128
- Checks if an account can get the account usage of an account.
1129
-
1130
- :param issuer: Account identifier which issues the command.
1131
- :param kwargs: List of arguments for the action.
1132
- :param session: The DB session to use
1133
- :returns: True if account is allowed, otherwise False
1134
- """
1135
- return True
1136
-
1137
-
1138
- def perm_add_account_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
1139
- """
1140
- Checks if an account can add attributes to accounts.
1141
-
1142
- :param issuer: Account identifier which issues the command.
1143
- :param kwargs: List of arguments for the action.
1144
- :param session: The DB session to use
1145
- :returns: True if account is allowed to call the API call, otherwise False
1146
- """
1147
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
1148
-
1149
-
1150
- def perm_del_account_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
1151
- """
1152
- Checks if an account can add attributes to accounts.
1153
-
1154
- :param issuer: Account identifier which issues the command.
1155
- :param kwargs: List of arguments for the action.
1156
- :param session: The DB session to use
1157
- :returns: True if account is allowed to call the API call, otherwise False
1158
- """
1159
- return perm_add_account_attribute(issuer, kwargs, session=session)
1160
-
1161
-
1162
- def perm_list_heartbeats(issuer, kwargs, *, session: "Optional[Session]" = None):
1163
- """
1164
- Checks if an account can list heartbeats.
1165
-
1166
- :param issuer: Account identifier which issues the command.
1167
- :param kwargs: List of arguments for the action.
1168
- :param session: The DB session to use
1169
- :returns: True if account is allowed to call the API call, otherwise False
1170
- """
1171
- return _is_root(issuer) or has_account_attribute(account=issuer, key='handle_heartbeats', session=session)
1172
-
1173
-
1174
- def perm_send_heartbeats(issuer, kwargs, *, session: "Optional[Session]" = None):
1175
- """
1176
- Checks if an account can send heartbeats.
1177
-
1178
- :param issuer: Account identifier which issues the command.
1179
- :param kwargs: List of arguments for the action.
1180
- :returns: True if account is allowed to call the API call, otherwise False
1181
- """
1182
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or has_account_attribute(account=issuer, key='handle_heartbeats', session=session)
1183
-
1184
-
1185
- def perm_resurrect(issuer, kwargs, *, session: "Optional[Session]" = None):
1186
- """
1187
- Checks if an account can resurrect DIDS.
1188
-
1189
- :param issuer: Account identifier which issues the command.
1190
- :param kwargs: List of arguments for the action.
1191
- :param session: The DB session to use
1192
- :returns: True if account is allowed to call the API call, otherwise False
1193
- """
1194
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
1195
-
1196
-
1197
- def perm_update_lifetime_exceptions(issuer, kwargs, *, session: "Optional[Session]" = None):
1198
- """
1199
- Checks if an account can approve/reject Lifetime Model exceptions.
1200
-
1201
- :param issuer: Account identifier which issues the command.
1202
- :param session: The DB session to use
1203
- :returns: True if account is allowed to call the API call, otherwise False
1204
- """
1205
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
1206
-
1207
-
1208
- def perm_get_auth_token_ssh(issuer: "InternalAccount", kwargs: dict, *, session: "Optional[Session]" = None) -> bool:
1209
- """
1210
- Checks if an account can request an ssh token.
1211
-
1212
- :param issuer: Account identifier which issues the command.
1213
- :param session: The DB session to use
1214
- :returns: True if account is allowed to call the API call, otherwise False
1215
- """
1216
- return True
1217
-
1218
-
1219
- def perm_get_signed_url(issuer, kwargs, *, session: "Optional[Session]" = None):
1220
- """
1221
- Checks if an account can request a signed URL.
1222
-
1223
- :param issuer: Account identifier which issues the command.
1224
- :param session: The DB session to use
1225
- :returns: True if account is allowed to call the API call, otherwise False
1226
- """
1227
- return _is_root(issuer) or has_account_attribute(account=issuer, key='sign-gcs', session=session)
1228
-
1229
-
1230
- def perm_add_bad_pfns(issuer, kwargs, *, session: "Optional[Session]" = None):
1231
- """
1232
- Checks if an account can declare bad PFNs.
1233
-
1234
- :param issuer: Account identifier which issues the command.
1235
- :param kwargs: List of arguments for the action.
1236
- :param session: The DB session to use
1237
- :returns: True if account is allowed, otherwise False
1238
- """
1239
- if kwargs['state'] in [BadPFNStatus.BAD.name, BadPFNStatus.TEMPORARY_UNAVAILABLE.name]:
1240
- is_cloud_admin = bool([acc_attr for acc_attr in list_account_attributes(account=issuer, session=session) if (acc_attr['key'].startswith('cloud-')) and (acc_attr['value'] == 'admin')])
1241
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or is_cloud_admin
1242
- elif kwargs['state'] == BadPFNStatus.SUSPICIOUS.name:
1243
- return True
1244
- return _is_root(issuer)
1245
-
1246
-
1247
- def perm_remove_did_from_followed(issuer, kwargs, *, session: "Optional[Session]" = None):
1248
- """
1249
- Checks if an account can remove did from followed table.
1250
-
1251
- :param issuer: Account identifier which issues the command.
1252
- :param kwargs: List of arguments for the action.
1253
- :param session: The DB session to use
1254
- :returns: True if account is allowed, otherwise False
1255
- """
1256
- return _is_root(issuer)\
1257
- or has_account_attribute(account=issuer, key='admin', session=session)\
1258
- or kwargs['account'] == issuer\
1259
- or kwargs['scope'].external == 'mock'
1260
-
1261
-
1262
- def perm_remove_dids_from_followed(issuer, kwargs, *, session: "Optional[Session]" = None):
1263
- """
1264
- Checks if an account can bulk remove dids from followed table.
1265
-
1266
- :param issuer: Account identifier which issues the command.
1267
- :param kwargs: List of arguments for the action.
1268
- :param session: The DB session to use
1269
- :returns: True if account is allowed, otherwise False
1270
- """
1271
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
1272
- return True
1273
- if not kwargs['account'] == issuer:
1274
- return False
1275
- return True
1276
-
1277
-
1278
- def perm_add_vo(issuer, kwargs, *, session: "Optional[Session]" = None):
1279
- """
1280
- Checks if an account can add a VO.
1281
-
1282
- :param issuer: Account identifier which issues the command.
1283
- :param kwargs: List of arguments for the action.
1284
- :param session: The DB session to use
1285
- :returns: True if account is allowed, otherwise False
1286
- """
1287
- return (issuer.internal == 'super_root')
1288
-
1289
-
1290
- def perm_list_vos(issuer, kwargs, *, session: "Optional[Session]" = None):
1291
- """
1292
- Checks if an account can list a VO.
1293
-
1294
- :param issuer: Account identifier which issues the command.
1295
- :param kwargs: List of arguments for the action.
1296
- :param session: The DB session to use
1297
- :returns: True if account is allowed, otherwise False
1298
- """
1299
- return (issuer.internal == 'super_root')
1300
-
1301
-
1302
- def perm_recover_vo_root_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
1303
- """
1304
- Checks if an account can recover identities for VOs.
1305
-
1306
- :param issuer: Account identifier which issues the command.
1307
- :param kwargs: List of arguments for the action.
1308
- :param session: The DB session to use
1309
- :returns: True if account is allowed, otherwise False
1310
- """
1311
- return (issuer.internal == 'super_root')
1312
-
1313
-
1314
- def perm_update_vo(issuer, kwargs, *, session: "Optional[Session]" = None):
1315
- """
1316
- Checks if an account can update a VO.
1317
-
1318
- :param issuer: Account identifier which issues the command.
1319
- :param kwargs: List of arguments for the action.
1320
- :param session: The DB session to use
1321
- :returns: True if account is allowed, otherwise False
1322
- """
1323
- return (issuer.internal == 'super_root')
1324
-
1325
-
1326
- def perm_access_rule_vo(issuer, kwargs, *, session: "Optional[Session]" = None):
1327
- """
1328
- Checks if we're at the same VO as the rule_id's
1329
-
1330
- :param issuer: Account identifier which issues the command.
1331
- :param kwargs: List of arguments for the action.
1332
- :param session: The DB session to use
1333
- :returns: True if account is allowed, otherwise False
1334
- """
1335
- return get_rule(kwargs['rule_id'], session=session)['scope'].vo == issuer.vo
1336
-
1337
-
1338
- def perm_export(issuer, kwargs, *, session: "Optional[Session]" = None):
1339
- """
1340
- Checks if an account can export the RSE info.
1341
-
1342
- :param issuer: Account identifier which issues the command.
1343
- :param kwargs: List of arguments for the action.
1344
- :param session: The DB session to use
1345
- :returns: True if account is allowed, otherwise False
1346
- """
1347
- is_cloud_admin = bool([acc_attr for acc_attr in list_account_attributes(account=issuer, session=session) if (acc_attr['key'].startswith('cloud-')) and (acc_attr['value'] == 'admin')])
1348
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or is_cloud_admin