fakecspace 0.1.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.
- fakecspace/__init__.py +5 -0
- fakecspace/accounts.py +73 -0
- fakecspace/app.py +598 -0
- fakecspace/bands.py +100 -0
- fakecspace/context.py +31 -0
- fakecspace/hooks.py +303 -0
- fakecspace/samples.py +41 -0
- fakecspace/seeds.py +63 -0
- fakecspace/store.py +233 -0
- fakecspace/vocab.py +94 -0
- fakecspace-0.1.0.dist-info/METADATA +137 -0
- fakecspace-0.1.0.dist-info/RECORD +15 -0
- fakecspace-0.1.0.dist-info/WHEEL +5 -0
- fakecspace-0.1.0.dist-info/licenses/LICENSE +22 -0
- fakecspace-0.1.0.dist-info/top_level.txt +1 -0
fakecspace/__init__.py
ADDED
fakecspace/accounts.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""The simulator's accounts, their permissions and their roles. All synthetic: each password is its user name, which
|
|
2
|
+
is fine only because the simulator never holds real data.
|
|
3
|
+
|
|
4
|
+
The BMU's users (staff and interns, design doc "Roles") and Serena's (its read-only service account, and admins
|
|
5
|
+
for the admin app) are merged; `admin` is in both and has both apps' roles (F0b).
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from .store import TENANT_IDS, Store
|
|
10
|
+
|
|
11
|
+
# user -> password
|
|
12
|
+
USERS = {
|
|
13
|
+
"admin": "admin", # BMU staff with every permission; a Serena admin of every museum
|
|
14
|
+
"limited": "limited", # BMU staff who can't create Objects or groups
|
|
15
|
+
"reader": "reader", # can read everything but has neither BMU role, so the BMU refuses the sign-in
|
|
16
|
+
"intern": "intern", # a BMU intern: the BMU_Intern role and no permissions at all
|
|
17
|
+
"newstaff": "newstaff", # has the BMU_Staff role but can only read, so the BMU refuses the sign-in
|
|
18
|
+
"bmureader": "bmureader", # the BMU's own read-only account (BMU_Reader role); not a person
|
|
19
|
+
"serena": "serena", # Serena's read-only service account
|
|
20
|
+
"pahma-admin": "pahma-admin", # a Serena admin of PAHMA only
|
|
21
|
+
"viewer": "viewer", # can sign in to Serena's admin app but is no museum's admin
|
|
22
|
+
}
|
|
23
|
+
# Serena's admin app accounts, and the museums each is an admin of (the role Serena_Admin in that museum's tenant).
|
|
24
|
+
ADMINS = {user: USERS[user] for user in ("admin", "pahma-admin", "viewer")}
|
|
25
|
+
ADMIN_MUSEUMS: dict[str, set[str]] = {"admin": set(TENANT_IDS), "pahma-admin": {"pahma"}, "viewer": set()}
|
|
26
|
+
|
|
27
|
+
RESOURCES = ("media", "relations", "collectionobjects", "groups", "personauthorities", "orgauthorities",
|
|
28
|
+
"vocabularies", "structureddates")
|
|
29
|
+
_ACTIONS = {"admin": "CRUDL", "limited": "CRUDL", "reader": "RL", "intern": "", "newstaff": "RL",
|
|
30
|
+
"bmureader": "RL", "serena": "RL", "pahma-admin": "RL", "viewer": "RL"}
|
|
31
|
+
|
|
32
|
+
# Role names without the ROLE_<tenant id>_ prefix.
|
|
33
|
+
_ROLES = {
|
|
34
|
+
"admin": ["TENANT_ADMINISTRATOR", "TENANT_READER", "BMU_STAFF"],
|
|
35
|
+
"limited": ["TENANT_READER", "BMU_STAFF"],
|
|
36
|
+
"reader": ["TENANT_READER"],
|
|
37
|
+
"intern": ["BMU_INTERN"],
|
|
38
|
+
"newstaff": ["TENANT_READER", "BMU_STAFF"],
|
|
39
|
+
"bmureader": ["BMU_READER"],
|
|
40
|
+
"serena": ["TENANT_READER"],
|
|
41
|
+
"pahma-admin": ["TENANT_READER"],
|
|
42
|
+
"viewer": ["TENANT_READER"],
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# What each person is for, shown by the BMU's Demo tools ("Sign in as"); not the service accounts.
|
|
46
|
+
USER_NOTES = {
|
|
47
|
+
"admin": "Staff with every permission",
|
|
48
|
+
"limited": "Staff who can't create Objects or groups",
|
|
49
|
+
"intern": "Intern: no CollectionSpace permissions",
|
|
50
|
+
"newstaff": "Staff role without the permissions: sign-in refused",
|
|
51
|
+
"reader": "Neither BMU role: sign-in refused",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def perms_for(store: Store, user: str) -> dict[str, str]:
|
|
56
|
+
"""The user's actions on each resource, as accountperms answers (C, R, U, D, L)."""
|
|
57
|
+
perms = {resource: _ACTIONS[user] for resource in RESOURCES}
|
|
58
|
+
if user == "limited":
|
|
59
|
+
perms["collectionobjects"] = "RL"
|
|
60
|
+
perms["groups"] = "RL"
|
|
61
|
+
perms.update(store.perm_overrides.get(user, {}))
|
|
62
|
+
return perms
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def roles_for(store: Store, user: str) -> list[str]:
|
|
66
|
+
"""The user's role names in the store's museum's tenant, e.g. ROLE_14_BMU_STAFF."""
|
|
67
|
+
if user in store.role_overrides:
|
|
68
|
+
return list(store.role_overrides[user])
|
|
69
|
+
tenant = TENANT_IDS[store.museum]
|
|
70
|
+
names = list(_ROLES[user])
|
|
71
|
+
if store.museum in ADMIN_MUSEUMS.get(user, set()):
|
|
72
|
+
names.append("SERENA_ADMIN")
|
|
73
|
+
return [f"ROLE_{tenant}_{name}" for name in names]
|