rucio 35.7.0__py3-none-any.whl → 37.0.0rc2__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 (268) 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/stomp_utils.py +383 -119
  48. rucio/common/test_rucio_server.py +12 -6
  49. rucio/common/types.py +132 -52
  50. rucio/common/utils.py +93 -643
  51. rucio/core/account_limit.py +14 -12
  52. rucio/core/authentication.py +2 -2
  53. rucio/core/config.py +23 -42
  54. rucio/core/credential.py +14 -15
  55. rucio/core/did.py +5 -1
  56. rucio/core/did_meta_plugins/elasticsearch_meta.py +407 -0
  57. rucio/core/did_meta_plugins/filter_engine.py +62 -3
  58. rucio/core/did_meta_plugins/json_meta.py +2 -2
  59. rucio/core/did_meta_plugins/mongo_meta.py +43 -30
  60. rucio/core/did_meta_plugins/postgres_meta.py +75 -39
  61. rucio/core/identity.py +6 -5
  62. rucio/core/importer.py +4 -3
  63. rucio/core/lifetime_exception.py +2 -2
  64. rucio/core/lock.py +8 -7
  65. rucio/core/message.py +6 -0
  66. rucio/core/monitor.py +30 -29
  67. rucio/core/naming_convention.py +2 -2
  68. rucio/core/nongrid_trace.py +2 -2
  69. rucio/core/oidc.py +11 -9
  70. rucio/core/permission/__init__.py +79 -37
  71. rucio/core/permission/generic.py +1 -7
  72. rucio/core/permission/generic_multi_vo.py +1 -7
  73. rucio/core/quarantined_replica.py +4 -3
  74. rucio/core/replica.py +464 -139
  75. rucio/core/replica_sorter.py +55 -59
  76. rucio/core/request.py +34 -32
  77. rucio/core/rse.py +301 -97
  78. rucio/core/rse_counter.py +1 -2
  79. rucio/core/rse_expression_parser.py +7 -7
  80. rucio/core/rse_selector.py +9 -7
  81. rucio/core/rule.py +41 -40
  82. rucio/core/rule_grouping.py +42 -40
  83. rucio/core/scope.py +5 -4
  84. rucio/core/subscription.py +26 -28
  85. rucio/core/topology.py +11 -11
  86. rucio/core/trace.py +2 -2
  87. rucio/core/transfer.py +29 -15
  88. rucio/core/volatile_replica.py +4 -3
  89. rucio/daemons/atropos/atropos.py +1 -1
  90. rucio/daemons/auditor/__init__.py +2 -2
  91. rucio/daemons/auditor/srmdumps.py +6 -6
  92. rucio/daemons/automatix/automatix.py +32 -21
  93. rucio/daemons/badreplicas/necromancer.py +2 -2
  94. rucio/daemons/bb8/nuclei_background_rebalance.py +1 -1
  95. rucio/daemons/bb8/t2_background_rebalance.py +1 -1
  96. rucio/daemons/cache/consumer.py +26 -90
  97. rucio/daemons/common.py +15 -25
  98. rucio/daemons/conveyor/finisher.py +2 -2
  99. rucio/daemons/conveyor/poller.py +18 -28
  100. rucio/daemons/conveyor/receiver.py +53 -123
  101. rucio/daemons/conveyor/stager.py +1 -0
  102. rucio/daemons/conveyor/submitter.py +3 -3
  103. rucio/daemons/hermes/hermes.py +129 -369
  104. rucio/daemons/judge/evaluator.py +2 -2
  105. rucio/daemons/oauthmanager/oauthmanager.py +3 -3
  106. rucio/daemons/reaper/dark_reaper.py +7 -3
  107. rucio/daemons/reaper/reaper.py +12 -16
  108. rucio/daemons/rsedecommissioner/config.py +1 -1
  109. rucio/daemons/rsedecommissioner/profiles/generic.py +5 -4
  110. rucio/daemons/rsedecommissioner/profiles/types.py +7 -6
  111. rucio/daemons/rsedecommissioner/rse_decommissioner.py +1 -1
  112. rucio/daemons/storage/consistency/actions.py +8 -6
  113. rucio/daemons/tracer/kronos.py +117 -142
  114. rucio/db/sqla/constants.py +5 -0
  115. rucio/db/sqla/migrate_repo/versions/1677d4d803c8_split_rse_availability_into_multiple.py +4 -4
  116. rucio/db/sqla/migrate_repo/versions/30d5206e9cad_increase_oauthrequest_redirect_msg_.py +37 -0
  117. rucio/db/sqla/models.py +157 -154
  118. rucio/db/sqla/session.py +58 -27
  119. rucio/db/sqla/types.py +2 -2
  120. rucio/db/sqla/util.py +2 -2
  121. rucio/gateway/account.py +18 -12
  122. rucio/gateway/account_limit.py +137 -60
  123. rucio/gateway/authentication.py +18 -12
  124. rucio/gateway/config.py +30 -20
  125. rucio/gateway/credential.py +9 -10
  126. rucio/gateway/did.py +70 -53
  127. rucio/gateway/dirac.py +6 -4
  128. rucio/gateway/exporter.py +3 -2
  129. rucio/gateway/heartbeat.py +6 -4
  130. rucio/gateway/identity.py +36 -51
  131. rucio/gateway/importer.py +3 -2
  132. rucio/gateway/lifetime_exception.py +3 -2
  133. rucio/gateway/meta_conventions.py +17 -6
  134. rucio/gateway/permission.py +4 -1
  135. rucio/gateway/quarantined_replica.py +3 -2
  136. rucio/gateway/replica.py +31 -22
  137. rucio/gateway/request.py +27 -18
  138. rucio/gateway/rse.py +69 -37
  139. rucio/gateway/rule.py +46 -26
  140. rucio/gateway/scope.py +3 -2
  141. rucio/gateway/subscription.py +14 -11
  142. rucio/gateway/vo.py +12 -8
  143. rucio/rse/__init__.py +3 -3
  144. rucio/rse/protocols/bittorrent.py +11 -1
  145. rucio/rse/protocols/cache.py +0 -11
  146. rucio/rse/protocols/dummy.py +0 -11
  147. rucio/rse/protocols/gfal.py +14 -9
  148. rucio/rse/protocols/globus.py +1 -1
  149. rucio/rse/protocols/http_cache.py +1 -1
  150. rucio/rse/protocols/posix.py +2 -2
  151. rucio/rse/protocols/protocol.py +84 -317
  152. rucio/rse/protocols/rclone.py +2 -1
  153. rucio/rse/protocols/rfio.py +10 -1
  154. rucio/rse/protocols/ssh.py +2 -1
  155. rucio/rse/protocols/storm.py +2 -13
  156. rucio/rse/protocols/webdav.py +74 -30
  157. rucio/rse/protocols/xrootd.py +2 -1
  158. rucio/rse/rsemanager.py +170 -53
  159. rucio/rse/translation.py +260 -0
  160. rucio/tests/common.py +23 -13
  161. rucio/tests/common_server.py +26 -9
  162. rucio/transfertool/bittorrent.py +15 -14
  163. rucio/transfertool/bittorrent_driver.py +5 -7
  164. rucio/transfertool/bittorrent_driver_qbittorrent.py +9 -8
  165. rucio/transfertool/fts3.py +20 -16
  166. rucio/transfertool/mock.py +2 -3
  167. rucio/vcsversion.py +4 -4
  168. rucio/version.py +7 -0
  169. rucio/web/rest/flaskapi/v1/accounts.py +17 -3
  170. rucio/web/rest/flaskapi/v1/auth.py +5 -5
  171. rucio/web/rest/flaskapi/v1/credentials.py +3 -2
  172. rucio/web/rest/flaskapi/v1/dids.py +21 -15
  173. rucio/web/rest/flaskapi/v1/identities.py +33 -9
  174. rucio/web/rest/flaskapi/v1/redirect.py +5 -4
  175. rucio/web/rest/flaskapi/v1/replicas.py +12 -8
  176. rucio/web/rest/flaskapi/v1/rses.py +15 -4
  177. rucio/web/rest/flaskapi/v1/traces.py +56 -19
  178. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/alembic.ini.template +1 -1
  179. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/alembic_offline.ini.template +1 -1
  180. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/rucio.cfg.atlas.client.template +3 -2
  181. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/rucio.cfg.template +3 -19
  182. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/rucio_multi_vo.cfg.template +1 -18
  183. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/requirements.server.txt +97 -68
  184. rucio-37.0.0rc2.data/scripts/rucio +133 -0
  185. rucio-37.0.0rc2.data/scripts/rucio-admin +97 -0
  186. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-atropos +2 -2
  187. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-auditor +2 -1
  188. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-automatix +2 -2
  189. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-cache-client +17 -10
  190. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-receiver +1 -0
  191. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-kronos +1 -0
  192. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-minos +2 -2
  193. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-minos-temporary-expiration +2 -2
  194. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-necromancer +2 -2
  195. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-reaper +6 -6
  196. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-transmogrifier +2 -2
  197. rucio-37.0.0rc2.dist-info/METADATA +92 -0
  198. {rucio-35.7.0.dist-info → rucio-37.0.0rc2.dist-info}/RECORD +239 -245
  199. {rucio-35.7.0.dist-info → rucio-37.0.0rc2.dist-info}/licenses/AUTHORS.rst +3 -0
  200. rucio/common/schema/atlas.py +0 -413
  201. rucio/common/schema/belleii.py +0 -408
  202. rucio/common/schema/domatpc.py +0 -401
  203. rucio/common/schema/escape.py +0 -426
  204. rucio/common/schema/icecube.py +0 -406
  205. rucio/core/permission/atlas.py +0 -1348
  206. rucio/core/permission/belleii.py +0 -1077
  207. rucio/core/permission/escape.py +0 -1078
  208. rucio/daemons/c3po/algorithms/__init__.py +0 -13
  209. rucio/daemons/c3po/algorithms/simple.py +0 -134
  210. rucio/daemons/c3po/algorithms/t2_free_space.py +0 -128
  211. rucio/daemons/c3po/algorithms/t2_free_space_only_pop.py +0 -130
  212. rucio/daemons/c3po/algorithms/t2_free_space_only_pop_with_network.py +0 -294
  213. rucio/daemons/c3po/c3po.py +0 -371
  214. rucio/daemons/c3po/collectors/agis.py +0 -108
  215. rucio/daemons/c3po/collectors/free_space.py +0 -81
  216. rucio/daemons/c3po/collectors/jedi_did.py +0 -57
  217. rucio/daemons/c3po/collectors/mock_did.py +0 -51
  218. rucio/daemons/c3po/collectors/network_metrics.py +0 -71
  219. rucio/daemons/c3po/collectors/workload.py +0 -112
  220. rucio/daemons/c3po/utils/__init__.py +0 -13
  221. rucio/daemons/c3po/utils/dataset_cache.py +0 -50
  222. rucio/daemons/c3po/utils/expiring_dataset_cache.py +0 -56
  223. rucio/daemons/c3po/utils/expiring_list.py +0 -62
  224. rucio/daemons/c3po/utils/popularity.py +0 -85
  225. rucio/daemons/c3po/utils/timeseries.py +0 -89
  226. rucio/rse/protocols/gsiftp.py +0 -92
  227. rucio-35.7.0.data/scripts/rucio-c3po +0 -85
  228. rucio-35.7.0.dist-info/METADATA +0 -72
  229. /rucio/{daemons/c3po → cli/bin_legacy}/__init__.py +0 -0
  230. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/globus-config.yml.template +0 -0
  231. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/ldap.cfg.template +0 -0
  232. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/mail_templates/rule_approval_request.tmpl +0 -0
  233. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +0 -0
  234. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/mail_templates/rule_approved_user.tmpl +0 -0
  235. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +0 -0
  236. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/mail_templates/rule_denied_user.tmpl +0 -0
  237. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +0 -0
  238. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/etc/rse-accounts.cfg.template +0 -0
  239. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/tools/bootstrap.py +0 -0
  240. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/tools/merge_rucio_configs.py +0 -0
  241. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/data/rucio/tools/reset_database.py +0 -0
  242. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-abacus-account +0 -0
  243. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-abacus-collection-replica +0 -0
  244. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-abacus-rse +0 -0
  245. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-bb8 +0 -0
  246. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-cache-consumer +0 -0
  247. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-finisher +0 -0
  248. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-poller +0 -0
  249. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-preparer +0 -0
  250. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-stager +0 -0
  251. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-submitter +0 -0
  252. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-conveyor-throttler +0 -0
  253. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-dark-reaper +0 -0
  254. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-dumper +0 -0
  255. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-follower +0 -0
  256. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-hermes +0 -0
  257. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-judge-cleaner +0 -0
  258. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-judge-evaluator +0 -0
  259. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-judge-injector +0 -0
  260. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-judge-repairer +0 -0
  261. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-oauth-manager +0 -0
  262. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-replica-recoverer +0 -0
  263. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-rse-decommissioner +0 -0
  264. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-storage-consistency-actions +0 -0
  265. {rucio-35.7.0.data → rucio-37.0.0rc2.data}/scripts/rucio-undertaker +0 -0
  266. {rucio-35.7.0.dist-info → rucio-37.0.0rc2.dist-info}/WHEEL +0 -0
  267. {rucio-35.7.0.dist-info → rucio-37.0.0rc2.dist-info}/licenses/LICENSE +0 -0
  268. {rucio-35.7.0.dist-info → rucio-37.0.0rc2.dist-info}/top_level.txt +0 -0
@@ -1,1078 +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.scope
18
- from rucio.common.constants import RseAttr
19
- from rucio.core.account import has_account_attribute, list_account_attributes
20
- from rucio.core.identity import exist_identity_account
21
- from rucio.core.lifetime_exception import list_exceptions
22
- from rucio.core.rse import list_rse_attributes
23
- from rucio.core.rse_expression_parser import parse_expression
24
- from rucio.db.sqla.constants import IdentityType
25
-
26
- if TYPE_CHECKING:
27
- from typing import Optional
28
-
29
- from sqlalchemy.orm import Session
30
-
31
- from rucio.common.types import InternalAccount
32
-
33
-
34
- def has_permission(issuer, action, kwargs, *, session: "Optional[Session]" = None):
35
- """
36
- Checks if an account has the specified permission to
37
- execute an action with parameters.
38
-
39
- :param issuer: Account identifier which issues the command..
40
- :param action: The action(API call) called by the account.
41
- :param kwargs: List of arguments for the action.
42
- :param session: The DB session to use
43
- :returns: True if account is allowed, otherwise False
44
- """
45
- perm = {'add_account': perm_add_account,
46
- 'del_account': perm_del_account,
47
- 'update_account': perm_update_account,
48
- 'add_rule': perm_add_rule,
49
- 'add_subscription': perm_add_subscription,
50
- 'add_scope': perm_add_scope,
51
- 'add_rse': perm_add_rse,
52
- 'update_rse': perm_update_rse,
53
- 'add_protocol': perm_add_protocol,
54
- 'del_protocol': perm_del_protocol,
55
- 'update_protocol': perm_update_protocol,
56
- 'add_qos_policy': perm_add_qos_policy,
57
- 'delete_qos_policy': perm_delete_qos_policy,
58
- 'declare_bad_file_replicas': perm_declare_bad_file_replicas,
59
- 'declare_suspicious_file_replicas': perm_declare_suspicious_file_replicas,
60
- 'add_replicas': perm_add_replicas,
61
- 'delete_replicas': perm_delete_replicas,
62
- 'skip_availability_check': perm_skip_availability_check,
63
- 'update_replicas_states': perm_update_replicas_states,
64
- 'add_rse_attribute': perm_add_rse_attribute,
65
- 'del_rse_attribute': perm_del_rse_attribute,
66
- 'del_rse': perm_del_rse,
67
- 'del_rule': perm_del_rule,
68
- 'update_rule': perm_update_rule,
69
- 'approve_rule': perm_approve_rule,
70
- 'update_subscription': perm_update_subscription,
71
- 'reduce_rule': perm_reduce_rule,
72
- 'move_rule': perm_move_rule,
73
- 'get_auth_token_user_pass': perm_get_auth_token_user_pass,
74
- 'get_auth_token_gss': perm_get_auth_token_gss,
75
- 'get_auth_token_x509': perm_get_auth_token_x509,
76
- 'get_auth_token_saml': perm_get_auth_token_saml,
77
- 'add_account_identity': perm_add_account_identity,
78
- 'add_did': perm_add_did,
79
- 'add_dids': perm_add_dids,
80
- 'attach_dids': perm_attach_dids,
81
- 'detach_dids': perm_detach_dids,
82
- 'attach_dids_to_dids': perm_attach_dids_to_dids,
83
- 'create_did_sample': perm_create_did_sample,
84
- 'set_metadata': perm_set_metadata,
85
- 'set_status': perm_set_status,
86
- 'queue_requests': perm_queue_requests,
87
- 'set_rse_usage': perm_set_rse_usage,
88
- 'set_rse_limits': perm_set_rse_limits,
89
- 'get_request_by_did': perm_get_request_by_did,
90
- 'cancel_request': perm_cancel_request,
91
- 'get_next': perm_get_next,
92
- 'set_local_account_limit': perm_set_local_account_limit,
93
- 'set_global_account_limit': perm_set_global_account_limit,
94
- 'delete_local_account_limit': perm_delete_local_account_limit,
95
- 'delete_global_account_limit': perm_delete_global_account_limit,
96
- 'config_sections': perm_config,
97
- 'config_add_section': perm_config,
98
- 'config_has_section': perm_config,
99
- 'config_options': perm_config,
100
- 'config_has_option': perm_config,
101
- 'config_get': perm_config,
102
- 'config_items': perm_config,
103
- 'config_set': perm_config,
104
- 'config_remove_section': perm_config,
105
- 'config_remove_option': perm_config,
106
- 'get_local_account_usage': perm_get_local_account_usage,
107
- 'get_global_account_usage': perm_get_global_account_usage,
108
- 'add_attribute': perm_add_account_attribute,
109
- 'del_attribute': perm_del_account_attribute,
110
- 'list_heartbeats': perm_list_heartbeats,
111
- 'resurrect': perm_resurrect,
112
- 'update_lifetime_exceptions': perm_update_lifetime_exceptions,
113
- 'get_auth_token_ssh': perm_get_auth_token_ssh,
114
- 'get_signed_url': perm_get_signed_url,
115
- 'add_bad_pfns': perm_add_bad_pfns,
116
- 'del_account_identity': perm_del_account_identity,
117
- 'del_identity': perm_del_identity,
118
- 'remove_did_from_followed': perm_remove_did_from_followed,
119
- 'remove_dids_from_followed': perm_remove_dids_from_followed,
120
- 'export': perm_export}
121
-
122
- return perm.get(action, perm_default)(issuer=issuer, kwargs=kwargs, session=session)
123
-
124
-
125
- def _is_root(issuer):
126
- return issuer.external == 'root'
127
-
128
-
129
- def perm_default(issuer, kwargs, *, session: "Optional[Session]" = None):
130
- """
131
- Default permission.
132
-
133
- :param issuer: Account identifier which issues the command.
134
- :param kwargs: List of arguments for the action.
135
- :param session: The DB session to use
136
- :returns: True if account is allowed, otherwise False
137
- """
138
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
139
-
140
-
141
- def perm_add_rse(issuer, kwargs, *, session: "Optional[Session]" = None):
142
- """
143
- Checks if an account can add a RSE.
144
-
145
- :param issuer: Account identifier which issues the command.
146
- :param kwargs: List of arguments for the action.
147
- :param session: The DB session to use
148
- :returns: True if account is allowed, otherwise False
149
- """
150
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
151
-
152
-
153
- def perm_update_rse(issuer, kwargs, *, session: "Optional[Session]" = None):
154
- """
155
- Checks if an account can update a RSE.
156
-
157
- :param issuer: Account identifier which issues the command.
158
- :param kwargs: List of arguments for the action.
159
- :param session: The DB session to use
160
- :returns: True if account is allowed, otherwise False
161
- """
162
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
163
-
164
-
165
- def perm_add_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
166
- """
167
- Checks if an account can add a replication rule.
168
-
169
- :param issuer: Account identifier which issues the command.
170
- :param kwargs: List of arguments for the action.
171
- :param session: The DB session to use
172
- :returns: True if account is allowed, otherwise False
173
- """
174
- if kwargs['account'] == issuer and not kwargs['locked']:
175
- return True
176
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
177
- return True
178
- return False
179
-
180
-
181
- def perm_add_subscription(issuer, kwargs, *, session: "Optional[Session]" = None):
182
- """
183
- Checks if an account can add a subscription.
184
-
185
- :param issuer: Account identifier which issues the command.
186
- :param kwargs: List of arguments for the action.
187
- :param session: The DB session to use
188
- :returns: True if account is allowed, otherwise False
189
- """
190
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
191
- return True
192
- return False
193
-
194
-
195
- def perm_add_rse_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
196
- """
197
- Checks if an account can add a RSE attribute.
198
-
199
- :param issuer: Account identifier which issues the command.
200
- :param kwargs: List of arguments for the action.
201
- :param session: The DB session to use
202
- :returns: True if account is allowed, otherwise False
203
- """
204
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
205
- return True
206
- return False
207
-
208
-
209
- def perm_del_rse_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
210
- """
211
- Checks if an account can delete a RSE attribute.
212
-
213
- :param issuer: Account identifier which issues the command.
214
- :param kwargs: List of arguments for the action.
215
- :param session: The DB session to use
216
- :returns: True if account is allowed, otherwise False
217
- """
218
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
219
- return True
220
- return False
221
-
222
-
223
- def perm_del_rse(issuer, kwargs, *, session: "Optional[Session]" = None):
224
- """
225
- Checks if an account can delete a RSE.
226
-
227
- :param issuer: Account identifier which issues the command.
228
- :param kwargs: List of arguments for the action.
229
- :param session: The DB session to use
230
- :returns: True if account is allowed, otherwise False
231
- """
232
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
233
-
234
-
235
- def perm_add_account(issuer, kwargs, *, session: "Optional[Session]" = None):
236
- """
237
- Checks if an account can add an account.
238
-
239
- :param issuer: Account identifier which issues the command.
240
- :param kwargs: List of arguments for the action.
241
- :param session: The DB session to use
242
- :returns: True if account is allowed, otherwise False
243
- """
244
- return _is_root(issuer)
245
-
246
-
247
- def perm_del_account(issuer, kwargs, *, session: "Optional[Session]" = None):
248
- """
249
- Checks if an account can del an account.
250
-
251
- :param issuer: Account identifier which issues the command.
252
- :param kwargs: List of arguments for the action.
253
- :param session: The DB session to use
254
- :returns: True if account is allowed, otherwise False
255
- """
256
- return _is_root(issuer)
257
-
258
-
259
- def perm_update_account(issuer, kwargs, *, session: "Optional[Session]" = None):
260
- """
261
- Checks if an account can update an account.
262
-
263
- :param issuer: Account identifier which issues the command.
264
- :param kwargs: List of arguments for the action.
265
- :param session: The DB session to use
266
- :returns: True if account is allowed, otherwise False
267
- """
268
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
269
-
270
-
271
- def perm_add_scope(issuer, kwargs, *, session: "Optional[Session]" = None):
272
- """
273
- Checks if an account can add a scop to a account.
274
-
275
- :param issuer: Account identifier which issues the command.
276
- :param kwargs: List of arguments for the action.
277
- :param session: The DB session to use
278
- :returns: True if account is allowed, otherwise False
279
- """
280
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
281
-
282
-
283
- def perm_get_auth_token_user_pass(issuer, kwargs, *, session: "Optional[Session]" = None):
284
- """
285
- Checks if a user can request a token with user_pass for an account.
286
-
287
- :param issuer: Account identifier which issues the command.
288
- :param kwargs: List of arguments for the action.
289
- :param session: The DB session to use
290
- :returns: True if account is allowed, otherwise False
291
- """
292
- if exist_identity_account(identity=kwargs['username'], type_=IdentityType.USERPASS, account=kwargs['account'], session=session):
293
- return True
294
- return False
295
-
296
-
297
- def perm_get_auth_token_gss(issuer, kwargs, *, session: "Optional[Session]" = None):
298
- """
299
- Checks if a user can request a token with user_pass for an account.
300
-
301
- :param issuer: Account identifier which issues the command.
302
- :param kwargs: List of arguments for the action.
303
- :param session: The DB session to use
304
- :returns: True if account is allowed, otherwise False
305
- """
306
- if exist_identity_account(identity=kwargs['gsscred'], type_=IdentityType.GSS, account=kwargs['account'], session=session):
307
- return True
308
- return False
309
-
310
-
311
- def perm_get_auth_token_x509(issuer, kwargs, *, session: "Optional[Session]" = None):
312
- """
313
- Checks if a user can request a token with user_pass for an account.
314
-
315
- :param issuer: Account identifier which issues the command.
316
- :param kwargs: List of arguments for the action.
317
- :param session: The DB session to use
318
- :returns: True if account is allowed, otherwise False
319
- """
320
- if exist_identity_account(identity=kwargs['dn'], type_=IdentityType.X509, account=kwargs['account'], session=session):
321
- return True
322
- return False
323
-
324
-
325
- def perm_get_auth_token_saml(issuer, kwargs, *, session: "Optional[Session]" = None):
326
- """
327
- Checks if a user can request a token with user_pass for an account.
328
-
329
- :param issuer: Account identifier which issues the command.
330
- :param kwargs: List of arguments for the action.
331
- :param session: The DB session to use
332
- :returns: True if account is allowed, otherwise False
333
- """
334
- if exist_identity_account(identity=kwargs['saml_nameid'], type_=IdentityType.SAML, account=kwargs['account'], session=session):
335
- return True
336
- return False
337
-
338
-
339
- def perm_add_account_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
340
- """
341
- Checks if an account can add an identity to an account.
342
-
343
- :param issuer: Account identifier which issues the command.
344
- :param kwargs: List of arguments for the action.
345
- :param session: The DB session to use
346
- :returns: True if account is allowed, otherwise False
347
- """
348
-
349
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
350
-
351
-
352
- def perm_del_account_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
353
- """
354
- Checks if an account can delete an identity to an account.
355
-
356
- :param issuer: Account identifier which issues the command.
357
- :param kwargs: List of arguments for the action.
358
- :param session: The DB session to use
359
- :returns: True if account is allowed, otherwise False
360
- """
361
-
362
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
363
-
364
-
365
- def perm_del_identity(issuer, kwargs, *, session: "Optional[Session]" = None):
366
- """
367
- Checks if an account can delete an identity.
368
-
369
- :param issuer: Account identifier which issues the command.
370
- :param kwargs: List of arguments for the action.
371
- :param session: The DB session to use
372
- :returns: True if account is allowed, otherwise False
373
- """
374
-
375
- return _is_root(issuer) or issuer.external in kwargs.get('accounts')
376
-
377
-
378
- def perm_add_did(issuer, kwargs, *, session: "Optional[Session]" = None):
379
- """
380
- Checks if an account can add an data identifier to a scope.
381
-
382
- :param issuer: Account identifier which issues the command.
383
- :param kwargs: List of arguments for the action.
384
- :param session: The DB session to use
385
- :returns: True if account is allowed, otherwise False
386
- """
387
- # Check the accounts of the issued rules
388
- if not _is_root(issuer) and not has_account_attribute(account=issuer, key='admin', session=session):
389
- for rule in kwargs.get('rules', []):
390
- if rule['account'] != issuer:
391
- return False
392
-
393
- return _is_root(issuer)\
394
- or has_account_attribute(account=issuer, key='admin', session=session)\
395
- or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)\
396
- or kwargs['scope'].external == 'mock'
397
-
398
-
399
- def perm_add_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
400
- """
401
- Checks if an account can bulk add data identifiers.
402
-
403
- :param issuer: Account identifier which issues the command.
404
- :param kwargs: List of arguments for the action.
405
- :param session: The DB session to use
406
- :returns: True if account is allowed, otherwise False
407
- """
408
- # Check the accounts of the issued rules
409
- if not _is_root(issuer) and not has_account_attribute(account=issuer, key='admin', session=session):
410
- for did in kwargs['dids']:
411
- for rule in did.get('rules', []):
412
- if rule['account'] != issuer:
413
- return False
414
-
415
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
416
-
417
-
418
- def perm_attach_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
419
- """
420
- Checks if an account can append an data identifier to the other data identifier.
421
-
422
- :param issuer: Account identifier which issues the command.
423
- :param kwargs: List of arguments for the action.
424
- :param session: The DB session to use
425
- :returns: True if account is allowed, otherwise False
426
- """
427
- return _is_root(issuer)\
428
- or has_account_attribute(account=issuer, key='admin', session=session)\
429
- or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)\
430
- or kwargs['scope'].external == 'mock'
431
-
432
-
433
- def perm_attach_dids_to_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
434
- """
435
- Checks if an account can append an data identifier to the other data identifier.
436
-
437
- :param issuer: Account identifier which issues the command.
438
- :param kwargs: List of arguments for the action.
439
- :param session: The DB session to use
440
- :returns: True if account is allowed, otherwise False
441
- """
442
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
443
- return True
444
- else:
445
- attachments = kwargs['attachments']
446
- scopes = [did['scope'] for did in attachments]
447
- scopes = list(set(scopes))
448
- for scope in scopes:
449
- if not rucio.core.scope.is_scope_owner(scope, issuer, session=session):
450
- return False
451
- return True
452
-
453
-
454
- def perm_create_did_sample(issuer, kwargs, *, session: "Optional[Session]" = None):
455
- """
456
- Checks if an account can create a sample of a data identifier collection.
457
-
458
- :param issuer: Account identifier which issues the command.
459
- :param kwargs: List of arguments for the action.
460
- :param session: The DB session to use
461
- :returns: True if account is allowed, otherwise False
462
- """
463
- return _is_root(issuer)\
464
- or has_account_attribute(account=issuer, key='admin', session=session)\
465
- or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)\
466
- or kwargs['scope'].external == 'mock'
467
-
468
-
469
- def perm_del_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
470
- """
471
- Checks if an issuer can delete a replication rule.
472
-
473
- :param issuer: Account identifier which issues the command.
474
- :param kwargs: List of arguments for the action.
475
- :param session: The DB session to use
476
- :returns: True if account is allowed to call the API call, otherwise False
477
- """
478
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
479
- return True
480
- return False
481
-
482
-
483
- def perm_update_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
484
- """
485
- Checks if an issuer can update a replication rule.
486
-
487
- :param issuer: Account identifier which issues the command.
488
- :param kwargs: List of arguments for the action.
489
- :param session: The DB session to use
490
- :returns: True if account is allowed to call the API call, otherwise False
491
- """
492
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
493
- return True
494
- return False
495
-
496
-
497
- def perm_approve_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
498
- """
499
- Checks if an issuer can approve 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) or has_account_attribute(account=issuer, key='admin', session=session):
507
- return True
508
- return False
509
-
510
-
511
- def perm_reduce_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
512
- """
513
- Checks if an issuer can reduce a replication rule.
514
-
515
- :param issuer: Account identifier which issues the command.
516
- :param kwargs: List of arguments for the action.
517
- :param session: The DB session to use
518
- :returns: True if account is allowed to call the API call, otherwise False
519
- """
520
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
521
- return True
522
- return False
523
-
524
-
525
- def perm_move_rule(issuer, kwargs, *, session: "Optional[Session]" = None):
526
- """
527
- Checks if an issuer can move a replication rule.
528
-
529
- :param issuer: Account identifier which issues the command.
530
- :param kwargs: List of arguments for the action.
531
- :param session: The DB session to use
532
- :returns: True if account is allowed to call the API call, otherwise False
533
- """
534
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
535
- return True
536
- return False
537
-
538
-
539
- def perm_update_subscription(issuer, kwargs, *, session: "Optional[Session]" = None):
540
- """
541
- Checks if an account can update a subscription.
542
-
543
- :param issuer: Account identifier which issues the command.
544
- :param kwargs: List of arguments for the action.
545
- :param session: The DB session to use
546
- :returns: True if account is allowed, otherwise False
547
- """
548
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
549
- return True
550
-
551
- return False
552
-
553
-
554
- def perm_detach_dids(issuer, kwargs, *, session: "Optional[Session]" = None):
555
- """
556
- Checks if an account can detach an data identifier from the other data identifier.
557
-
558
- :param issuer: Account identifier which issues the command.
559
- :param kwargs: List of arguments for the action.
560
- :param session: The DB session to use
561
- :returns: True if account is allowed, otherwise False
562
- """
563
- return perm_attach_dids(issuer, kwargs, session=session)
564
-
565
-
566
- def perm_set_metadata(issuer, kwargs, *, session: "Optional[Session]" = None):
567
- """
568
- Checks if an account can set a metadata on a data identifier.
569
-
570
- :param issuer: Account identifier which issues the command.
571
- :param kwargs: List of arguments for the action.
572
- :param session: The DB session to use
573
- :returns: True if account is allowed, otherwise False
574
- """
575
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)
576
-
577
-
578
- def perm_set_status(issuer, kwargs, *, session: "Optional[Session]" = None):
579
- """
580
- Checks if an account can set status on an data identifier.
581
-
582
- :param issuer: Account identifier which issues the command.
583
- :param kwargs: List of arguments for the action.
584
- :param session: The DB session to use
585
- :returns: True if account is allowed, otherwise False
586
- """
587
- if kwargs.get('open', False):
588
- if not _is_root(issuer) and not has_account_attribute(account=issuer, key='admin', session=session):
589
- return False
590
-
591
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or rucio.core.scope.is_scope_owner(scope=kwargs['scope'], account=issuer, session=session)
592
-
593
-
594
- def perm_add_protocol(issuer, kwargs, *, session: "Optional[Session]" = None):
595
- """
596
- Checks if an account can add a protocol to an RSE.
597
-
598
- :param issuer: Account identifier which issues the command.
599
- :param kwargs: List of arguments for the action.
600
- :param session: The DB session to use
601
- :returns: True if account is allowed, otherwise False
602
- """
603
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
604
-
605
-
606
- def perm_del_protocol(issuer, kwargs, *, session: "Optional[Session]" = None):
607
- """
608
- Checks if an account can delete protocols from an RSE.
609
-
610
- :param issuer: Account identifier which issues the command.
611
- :param kwargs: List of arguments for the action.
612
- :param session: The DB session to use
613
- :returns: True if account is allowed, otherwise False
614
- """
615
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
616
-
617
-
618
- def perm_update_protocol(issuer, kwargs, *, session: "Optional[Session]" = None):
619
- """
620
- Checks if an account can update protocols of an RSE.
621
-
622
- :param issuer: Account identifier which issues the command.
623
- :param kwargs: List of arguments for the action.
624
- :param session: The DB session to use
625
- :returns: True if account is allowed, otherwise False
626
- """
627
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
628
-
629
-
630
- def perm_add_qos_policy(issuer, kwargs, *, session: "Optional[Session]" = None):
631
- """
632
- Checks if an account can add QoS policies to an RSE.
633
-
634
- :param issuer: Account identifier which issues the command.
635
- :param kwargs: List of arguments for the action.
636
- :param session: The DB session to use
637
- :returns: True if account is allowed, otherwise False
638
- """
639
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
640
-
641
-
642
- def perm_delete_qos_policy(issuer, kwargs, *, session: "Optional[Session]" = None):
643
- """
644
- Checks if an account can delete QoS policies from an RSE.
645
-
646
- :param issuer: Account identifier which issues the command.
647
- :param kwargs: List of arguments for the action.
648
- :param session: The DB session to use
649
- :returns: True if account is allowed, otherwise False
650
- """
651
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
652
-
653
-
654
- def perm_declare_bad_file_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
655
- """
656
- Checks if an account can declare bad file replicas.
657
-
658
- :param issuer: Account identifier which issues the command.
659
- :param kwargs: List of arguments for the action.
660
- :param session: The DB session to use
661
- :returns: True if account is allowed, otherwise False
662
- """
663
- return _is_root(issuer)
664
-
665
-
666
- def perm_declare_suspicious_file_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
667
- """
668
- Checks if an account can declare suspicious file replicas.
669
-
670
- :param issuer: Account identifier which issues the command.
671
- :param kwargs: List of arguments for the action.
672
- :param session: The DB session to use
673
- :returns: True if account is allowed, otherwise False
674
- """
675
- return True
676
-
677
-
678
- def perm_add_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
679
- """
680
- Checks if an account can add replicas.
681
-
682
- :param issuer: Account identifier which issues the command.
683
- :param kwargs: List of arguments for the action.
684
- :param session: The DB session to use
685
- :returns: True if account is allowed, otherwise False
686
- """
687
- return str(kwargs.get('rse', '')).endswith('SCRATCHDISK')\
688
- or str(kwargs.get('rse', '')).endswith('USERDISK')\
689
- or str(kwargs.get('rse', '')).endswith('MOCK')\
690
- or str(kwargs.get('rse', '')).endswith('LOCALGROUPDISK')\
691
- or _is_root(issuer)\
692
- or has_account_attribute(account=issuer, key='admin', session=session)
693
-
694
-
695
- def perm_skip_availability_check(issuer, kwargs, *, session: "Optional[Session]" = None):
696
- """
697
- Checks if an account can skip the availabity check to add/delete file replicas.
698
-
699
- :param issuer: Account identifier which issues the command.
700
- :param kwargs: List of arguments for the action.
701
- :param session: The DB session to use
702
- :returns: True if account is allowed, otherwise False
703
- """
704
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
705
-
706
-
707
- def perm_delete_replicas(issuer, kwargs, *, session: "Optional[Session]" = None):
708
- """
709
- Checks if an account can delete replicas.
710
-
711
- :param issuer: Account identifier which issues the command.
712
- :param kwargs: List of arguments for the action.
713
- :param session: The DB session to use
714
- :returns: True if account is allowed, otherwise False
715
- """
716
- return False
717
-
718
-
719
- def perm_update_replicas_states(issuer, kwargs, *, session: "Optional[Session]" = None):
720
- """
721
- Checks if an account can delete replicas.
722
-
723
- :param issuer: Account identifier which issues the command.
724
- :param kwargs: List of arguments for the action.
725
- :param session: The DB session to use
726
- :returns: True if account is allowed, otherwise False
727
- """
728
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
729
-
730
-
731
- def perm_queue_requests(issuer, kwargs, *, session: "Optional[Session]" = None):
732
- """
733
- Checks if an account can submit transfer or deletion requests on destination RSEs for data identifiers.
734
-
735
- :param issuer: Account identifier which issues the command.
736
- :param kwargs: List of arguments for the action.
737
- :param session: The DB session to use
738
- :returns: True if account is allowed, otherwise False
739
- """
740
- return _is_root(issuer)
741
-
742
-
743
- def perm_get_request_by_did(issuer, kwargs, *, session: "Optional[Session]" = None):
744
- """
745
- Checks if an account can get a request by DID.
746
-
747
- :param issuer: Account identifier which issues the command.
748
- :param kwargs: List of arguments for the action.
749
- :param session: The DB session to use
750
- :returns: True if account is allowed, otherwise False
751
- """
752
- return True
753
-
754
-
755
- def perm_cancel_request(issuer, kwargs, *, session: "Optional[Session]" = None):
756
- """
757
- Checks if an account can cancel a request.
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)
765
-
766
-
767
- def perm_get_next(issuer, kwargs, *, session: "Optional[Session]" = None):
768
- """
769
- Checks if an account can retrieve the next request matching the request type and state.
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)
777
-
778
-
779
- def perm_set_rse_usage(issuer, kwargs, *, session: "Optional[Session]" = None):
780
- """
781
- Checks if an account can set RSE usage information.
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 to call the API call, otherwise False
787
- """
788
- return _is_root(issuer)
789
-
790
-
791
- def perm_set_rse_limits(issuer, kwargs, *, session: "Optional[Session]" = None):
792
- """
793
- Checks if an account can set RSE limits.
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 to call the API call, otherwise False
799
- """
800
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
801
-
802
-
803
- def perm_set_local_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
804
- """
805
- Checks if an account can set an account limit.
806
-
807
- :param account: 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
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
813
- return True
814
- # Check if user is a country admin
815
- admin_in_country = []
816
- for kv in list_account_attributes(account=issuer, session=session):
817
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
818
- admin_in_country.append(kv['key'].partition('-')[2])
819
- if admin_in_country and list_rse_attributes(rse_id=kwargs['rse_id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
820
- return True
821
- return False
822
-
823
-
824
- def perm_set_global_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
825
- """
826
- Checks if an account can set a global account limit.
827
-
828
- :param account: Account identifier which issues the command.
829
- :param kwargs: List of arguments for the action.
830
- :param session: The DB session to use
831
- :returns: True if account is allowed, otherwise False
832
- """
833
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
834
- return True
835
- # Check if user is a country admin
836
- admin_in_country = set()
837
- for kv in list_account_attributes(account=issuer, session=session):
838
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
839
- admin_in_country.add(kv['key'].partition('-')[2])
840
- resolved_rse_countries = {list_rse_attributes(rse_id=rse['rse_id'], session=session).get(RseAttr.COUNTRY)
841
- for rse in parse_expression(kwargs['rse_expression'], filter_={'vo': issuer.vo}, session=session)}
842
- if resolved_rse_countries.issubset(admin_in_country):
843
- return True
844
- return False
845
-
846
-
847
- def perm_delete_local_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
848
- """
849
- Checks if an account can delete an account limit.
850
-
851
- :param account: Account identifier which issues the command.
852
- :param kwargs: List of arguments for the action.
853
- :param session: The DB session to use
854
- :returns: True if account is allowed, otherwise False
855
- """
856
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
857
- return True
858
- # Check if user is a country admin
859
- admin_in_country = []
860
- for kv in list_account_attributes(account=issuer, session=session):
861
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
862
- admin_in_country.append(kv['key'].partition('-')[2])
863
- if admin_in_country and list_rse_attributes(rse_id=kwargs['rse_id'], session=session).get(RseAttr.COUNTRY) in admin_in_country:
864
- return True
865
- return False
866
-
867
-
868
- def perm_delete_global_account_limit(issuer, kwargs, *, session: "Optional[Session]" = None):
869
- """
870
- Checks if an account can delete a global account limit.
871
-
872
- :param issuer: Account identifier which issues the command.
873
- :param kwargs: List of arguments for the action.
874
- :param session: The DB session to use
875
- :returns: True if account is allowed, otherwise False
876
- """
877
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
878
- return True
879
- # Check if user is a country admin
880
- admin_in_country = set()
881
- for kv in list_account_attributes(account=issuer, session=session):
882
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
883
- admin_in_country.add(kv['key'].partition('-')[2])
884
- if admin_in_country:
885
- resolved_rse_countries = {list_rse_attributes(rse_id=rse['rse_id'], session=session).get(RseAttr.COUNTRY)
886
- for rse in parse_expression(kwargs['rse_expression'], filter_={'vo': issuer.vo}, session=session)}
887
- if resolved_rse_countries.issubset(admin_in_country):
888
- return True
889
- return False
890
-
891
-
892
- def perm_config(issuer, kwargs, *, session: "Optional[Session]" = None):
893
- """
894
- Checks if an account can read/write the configuration.
895
-
896
- :param issuer: Account identifier which issues the command.
897
- :param kwargs: List of arguments for the action.
898
- :param session: The DB session to use
899
- :returns: True if account is allowed to call the API call, otherwise False
900
- """
901
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
902
-
903
-
904
- def perm_get_local_account_usage(issuer, kwargs, *, session: "Optional[Session]" = None):
905
- """
906
- Checks if an account can get the account usage of an account.
907
-
908
- :param issuer: Account identifier which issues the command.
909
- :param kwargs: List of arguments for the action.
910
- :param session: The DB session to use
911
- :returns: True if account is allowed, otherwise False
912
- """
913
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or kwargs.get('account') == issuer:
914
- return True
915
- # Check if user is a country admin
916
- for kv in list_account_attributes(account=issuer, session=session):
917
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
918
- return True
919
- return False
920
-
921
-
922
- def perm_get_global_account_usage(issuer, kwargs, *, session: "Optional[Session]" = None):
923
- """
924
- Checks if an account can get the account usage of an account.
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
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session) or kwargs.get('account') == issuer:
932
- return True
933
-
934
- # Check if user is a country admin for all involved countries
935
- for kv in list_account_attributes(account=issuer, session=session):
936
- if kv['key'].startswith('country-') and kv['value'] == 'admin':
937
- return True
938
- return False
939
-
940
-
941
- def perm_add_account_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
942
- """
943
- Checks if an account can add attributes to accounts.
944
-
945
- :param issuer: Account identifier which issues the command.
946
- :param kwargs: List of arguments for the action.
947
- :param session: The DB session to use
948
- :returns: True if account is allowed to call the API call, otherwise False
949
- """
950
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
951
-
952
-
953
- def perm_del_account_attribute(issuer, kwargs, *, session: "Optional[Session]" = None):
954
- """
955
- Checks if an account can add attributes to accounts.
956
-
957
- :param issuer: Account identifier which issues the command.
958
- :param kwargs: List of arguments for the action.
959
- :param session: The DB session to use
960
- :returns: True if account is allowed to call the API call, otherwise False
961
- """
962
- return perm_add_account_attribute(issuer, kwargs, session=session)
963
-
964
-
965
- def perm_list_heartbeats(issuer, kwargs, *, session: "Optional[Session]" = None):
966
- """
967
- Checks if an account can list heartbeats.
968
-
969
- :param issuer: Account identifier which issues the command.
970
- :param kwargs: List of arguments for the action.
971
- :param session: The DB session to use
972
- :returns: True if account is allowed to call the API call, otherwise False
973
- """
974
- return _is_root(issuer)
975
-
976
-
977
- def perm_resurrect(issuer, kwargs, *, session: "Optional[Session]" = None):
978
- """
979
- Checks if an account can resurrect DIDS.
980
-
981
- :param issuer: Account identifier which issues the command.
982
- :param kwargs: List of arguments for the action.
983
- :param session: The DB session to use
984
- :returns: True if account is allowed to call the API call, otherwise False
985
- """
986
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
987
-
988
-
989
- def perm_update_lifetime_exceptions(issuer, kwargs, *, session: "Optional[Session]" = None):
990
- """
991
- Checks if an account can approve/reject Lifetime Model exceptions.
992
-
993
- :param issuer: Account identifier which issues the command.
994
- :param session: The DB session to use
995
- :returns: True if account is allowed to call the API call, otherwise False
996
- """
997
- if kwargs['vo'] is not None:
998
- exceptions = next(list_exceptions(exception_id=kwargs['exception_id'], states=False, session=session))
999
- if exceptions['scope'].vo != kwargs['vo']:
1000
- return False
1001
- return _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session)
1002
-
1003
-
1004
- def perm_get_auth_token_ssh(issuer: "InternalAccount", kwargs: dict, *, session: "Optional[Session]" = None) -> bool:
1005
- """
1006
- Checks if an account can request a challenge token.
1007
-
1008
- :param issuer: Account identifier which issues the command.
1009
- :param session: The DB session to use
1010
- :returns: True if account is allowed to call the API call, otherwise False
1011
- """
1012
- return True
1013
-
1014
-
1015
- def perm_get_signed_url(issuer, kwargs, *, session: "Optional[Session]" = None):
1016
- """
1017
- Checks if an account can request a signed URL.
1018
-
1019
- :param issuer: Account identifier which issues the command.
1020
- :param session: The DB session to use
1021
- :returns: True if account is allowed to call the API call, otherwise False
1022
- """
1023
- return _is_root(issuer) or has_account_attribute(account=issuer, key='sign-gcs', session=session)
1024
-
1025
-
1026
- def perm_add_bad_pfns(issuer, kwargs, *, session: "Optional[Session]" = None):
1027
- """
1028
- Checks if an account can declare bad PFNs.
1029
-
1030
- :param issuer: Account identifier which issues the command.
1031
- :param kwargs: List of arguments for the action.
1032
- :param session: The DB session to use
1033
- :returns: True if account is allowed, otherwise False
1034
- """
1035
- return _is_root(issuer)
1036
-
1037
-
1038
- def perm_remove_did_from_followed(issuer, kwargs, *, session: "Optional[Session]" = None):
1039
- """
1040
- Checks if an account can remove did from followed table.
1041
-
1042
- :param issuer: Account identifier which issues the command.
1043
- :param kwargs: List of arguments for the action.
1044
- :param session: The DB session to use
1045
- :returns: True if account is allowed, otherwise False
1046
- """
1047
- return _is_root(issuer)\
1048
- or has_account_attribute(account=issuer, key='admin', session=session)\
1049
- or kwargs['account'] == issuer\
1050
- or kwargs['scope'].external == 'mock'
1051
-
1052
-
1053
- def perm_remove_dids_from_followed(issuer, kwargs, *, session: "Optional[Session]" = None):
1054
- """
1055
- Checks if an account can bulk remove dids from followed table.
1056
-
1057
- :param issuer: Account identifier which issues the command.
1058
- :param kwargs: List of arguments for the action.
1059
- :param session: The DB session to use
1060
- :returns: True if account is allowed, otherwise False
1061
- """
1062
- if _is_root(issuer) or has_account_attribute(account=issuer, key='admin', session=session):
1063
- return True
1064
- if not kwargs['account'] == issuer:
1065
- return False
1066
- return True
1067
-
1068
-
1069
- def perm_export(issuer, kwargs, *, session: "Optional[Session]" = None):
1070
- """
1071
- Checks if an account can export the RSE info.
1072
-
1073
- :param issuer: Account identifier which issues the command.
1074
- :param kwargs: List of arguments for the action.
1075
- :param session: The DB session to use
1076
- :returns: True if account is allowed, otherwise False
1077
- """
1078
- return _is_root(issuer)