tba-storage-tenancy 0.4.0.dev2__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.
- tba_storage_tenancy/__init__.py +7 -0
- tba_storage_tenancy/component.toml +23 -0
- tba_storage_tenancy/manifest.py +9 -0
- tba_storage_tenancy/migrations/__init__.py +0 -0
- tba_storage_tenancy/migrations/versions/69854e73_52d3_53ec_9542_6737159e42d6_initial_schema.py +23 -0
- tba_storage_tenancy/migrations/versions/__init__.py +0 -0
- tba_storage_tenancy/py.typed +0 -0
- tba_storage_tenancy/tables/__init__.py +14 -0
- tba_storage_tenancy/tables/realm/__init__.py +13 -0
- tba_storage_tenancy/tables/realm/_table.py +87 -0
- tba_storage_tenancy/tables/tenant/__init__.py +13 -0
- tba_storage_tenancy/tables/tenant/_table.py +83 -0
- tba_storage_tenancy-0.4.0.dev2.dist-info/METADATA +22 -0
- tba_storage_tenancy-0.4.0.dev2.dist-info/RECORD +15 -0
- tba_storage_tenancy-0.4.0.dev2.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Standalone identity storage component."""
|
|
2
|
+
|
|
3
|
+
from .manifest import MANIFEST, load_manifest
|
|
4
|
+
from .tables import * # noqa: F401,F403
|
|
5
|
+
from .tables import TABLE_MODEL_BY_NAME, TABLE_MODEL_BY_TABLENAME, TABLE_MODELS
|
|
6
|
+
|
|
7
|
+
__all__ = ["MANIFEST", "load_manifest", "TABLE_MODELS", "TABLE_MODEL_BY_NAME", "TABLE_MODEL_BY_TABLENAME"] + [model.__name__ for model in TABLE_MODELS]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
manifest_version = "1.0.0"
|
|
2
|
+
|
|
3
|
+
[component]
|
|
4
|
+
id = "tigrbl.identity.storage.tenancy"
|
|
5
|
+
distribution = "tba-storage-tenancy"
|
|
6
|
+
import_root = "tba_storage_tenancy"
|
|
7
|
+
|
|
8
|
+
[schema]
|
|
9
|
+
contract = "1.0.0"
|
|
10
|
+
migration_head = "69854e73-52d3-53ec-9542-6737159e42d6"
|
|
11
|
+
migrations_package = "tba_storage_tenancy.migrations.versions"
|
|
12
|
+
|
|
13
|
+
[[schema.objects]]
|
|
14
|
+
id = "tigrbl.identity.storage.tenancy:table:realms"
|
|
15
|
+
kind = "table"
|
|
16
|
+
physical_name = "authn.realms"
|
|
17
|
+
model = "tba_storage_tenancy.tables:Realm"
|
|
18
|
+
|
|
19
|
+
[[schema.objects]]
|
|
20
|
+
id = "tigrbl.identity.storage.tenancy:table:tenants"
|
|
21
|
+
kind = "table"
|
|
22
|
+
physical_name = "authn.tenants"
|
|
23
|
+
model = "tba_storage_tenancy.tables:Tenant"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Installed component manifest access."""
|
|
2
|
+
from importlib.resources import as_file, files
|
|
3
|
+
from tigrbl_migrations import StorageManifest
|
|
4
|
+
|
|
5
|
+
def load_manifest() -> StorageManifest:
|
|
6
|
+
with as_file(files(__package__).joinpath("component.toml")) as path:
|
|
7
|
+
return StorageManifest.from_toml(path)
|
|
8
|
+
|
|
9
|
+
MANIFEST = load_manifest()
|
|
File without changes
|
tba_storage_tenancy/migrations/versions/69854e73_52d3_53ec_9542_6737159e42d6_initial_schema.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Initial owned schema for tigrbl.identity.storage.tenancy."""
|
|
2
|
+
from tigrbl_migrations import Migration
|
|
3
|
+
from tba_storage_tenancy.tables import TABLE_MODELS
|
|
4
|
+
|
|
5
|
+
REVISION = "69854e73-52d3-53ec-9542-6737159e42d6"
|
|
6
|
+
|
|
7
|
+
def upgrade(connection):
|
|
8
|
+
for model in TABLE_MODELS:
|
|
9
|
+
model.__table__.create(bind=connection, checkfirst=True)
|
|
10
|
+
|
|
11
|
+
def downgrade(connection):
|
|
12
|
+
for model in reversed(TABLE_MODELS):
|
|
13
|
+
model.__table__.drop(bind=connection, checkfirst=True)
|
|
14
|
+
|
|
15
|
+
MIGRATION = Migration(
|
|
16
|
+
component="tigrbl.identity.storage.tenancy",
|
|
17
|
+
revision=REVISION,
|
|
18
|
+
parents=(),
|
|
19
|
+
kind="standard",
|
|
20
|
+
reversible=True,
|
|
21
|
+
upgrade=upgrade,
|
|
22
|
+
downgrade=downgrade,
|
|
23
|
+
)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Owned mapped-table inventory."""
|
|
2
|
+
|
|
3
|
+
from .realm import Realm
|
|
4
|
+
from .tenant import Tenant
|
|
5
|
+
|
|
6
|
+
TABLE_MODELS = (
|
|
7
|
+
Realm,
|
|
8
|
+
Tenant,
|
|
9
|
+
)
|
|
10
|
+
TABLE_MODEL_BY_NAME = {model.__name__: model for model in TABLE_MODELS}
|
|
11
|
+
TABLE_MODEL_BY_TABLENAME = {model.__tablename__: model for model in TABLE_MODELS}
|
|
12
|
+
__all__ = [model.__name__ for model in TABLE_MODELS] + [
|
|
13
|
+
"TABLE_MODELS", "TABLE_MODEL_BY_NAME", "TABLE_MODEL_BY_TABLENAME",
|
|
14
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from . import _table as _table
|
|
4
|
+
from ._table import *
|
|
5
|
+
|
|
6
|
+
for _name in dir(_table):
|
|
7
|
+
if not _name.startswith("__"):
|
|
8
|
+
globals().setdefault(_name, getattr(_table, _name))
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__all__ = list(_table.__all__)
|
|
12
|
+
except AttributeError:
|
|
13
|
+
__all__ = [name for name in globals() if not name.startswith("_")]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Realm mapped record for issuer and namespace boundaries."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import uuid
|
|
6
|
+
|
|
7
|
+
from tba_primitives_identity.orm import (
|
|
8
|
+
Bootstrappable,
|
|
9
|
+
ColumnSpec,
|
|
10
|
+
F,
|
|
11
|
+
GUIDPk,
|
|
12
|
+
IO,
|
|
13
|
+
Mapped,
|
|
14
|
+
RestOltpTable,
|
|
15
|
+
S,
|
|
16
|
+
String,
|
|
17
|
+
Timestamped,
|
|
18
|
+
acol,
|
|
19
|
+
relationship,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Realm(RestOltpTable, GUIDPk, Timestamped, Bootstrappable):
|
|
24
|
+
__tablename__ = "realms"
|
|
25
|
+
__table_args__ = ({"schema": "authn"},)
|
|
26
|
+
|
|
27
|
+
slug: Mapped[str] = acol(
|
|
28
|
+
spec=ColumnSpec(
|
|
29
|
+
storage=S(String(120), nullable=False, unique=True, index=True),
|
|
30
|
+
field=F(constraints={"max_length": 120}, required_in=("create",)),
|
|
31
|
+
io=IO(
|
|
32
|
+
in_verbs=("create", "update", "replace"),
|
|
33
|
+
out_verbs=("read", "list"),
|
|
34
|
+
filter_ops=("eq", "ilike"),
|
|
35
|
+
sortable=True,
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
name: Mapped[str] = acol(
|
|
40
|
+
spec=ColumnSpec(
|
|
41
|
+
storage=S(String(120), nullable=False, unique=True),
|
|
42
|
+
field=F(constraints={"max_length": 120}, required_in=("create",)),
|
|
43
|
+
io=IO(
|
|
44
|
+
in_verbs=("create", "update", "replace"),
|
|
45
|
+
out_verbs=("read", "list"),
|
|
46
|
+
filter_ops=("eq", "ilike"),
|
|
47
|
+
sortable=True,
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
issuer_path: Mapped[str] = acol(
|
|
52
|
+
spec=ColumnSpec(
|
|
53
|
+
storage=S(String(255), nullable=False, unique=True),
|
|
54
|
+
field=F(constraints={"max_length": 255}, required_in=("create",)),
|
|
55
|
+
io=IO(
|
|
56
|
+
in_verbs=("create", "update", "replace"),
|
|
57
|
+
out_verbs=("read", "list"),
|
|
58
|
+
filter_ops=("eq", "ilike"),
|
|
59
|
+
sortable=True,
|
|
60
|
+
),
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
description: Mapped[str | None] = acol(
|
|
64
|
+
spec=ColumnSpec(
|
|
65
|
+
storage=S(String(255), nullable=True),
|
|
66
|
+
field=F(constraints={"max_length": 255}),
|
|
67
|
+
io=IO(
|
|
68
|
+
in_verbs=("create", "update", "replace"),
|
|
69
|
+
out_verbs=("read", "list"),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
tenants = relationship("Tenant", back_populates="realm")
|
|
75
|
+
|
|
76
|
+
DEFAULT_ROWS = [
|
|
77
|
+
{
|
|
78
|
+
"id": uuid.UUID("FFFFFFFF-1000-0000-0000-000000000000"),
|
|
79
|
+
"slug": "default",
|
|
80
|
+
"name": "Default",
|
|
81
|
+
"issuer_path": "",
|
|
82
|
+
"description": "Default compatibility realm",
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
__all__ = ["Realm"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from . import _table as _table
|
|
4
|
+
from ._table import *
|
|
5
|
+
|
|
6
|
+
for _name in dir(_table):
|
|
7
|
+
if not _name.startswith("__"):
|
|
8
|
+
globals().setdefault(_name, getattr(_table, _name))
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
__all__ = list(_table.__all__)
|
|
12
|
+
except AttributeError:
|
|
13
|
+
__all__ = [name for name in globals() if not name.startswith("_")]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Tenant model for the authentication service."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import uuid
|
|
6
|
+
|
|
7
|
+
from tba_primitives_identity.orm import (
|
|
8
|
+
Bootstrappable,
|
|
9
|
+
F,
|
|
10
|
+
IO,
|
|
11
|
+
S,
|
|
12
|
+
ColumnSpec,
|
|
13
|
+
ForeignKeySpec,
|
|
14
|
+
Mapped,
|
|
15
|
+
PgUUID,
|
|
16
|
+
String,
|
|
17
|
+
TenantBase,
|
|
18
|
+
acol,
|
|
19
|
+
relationship,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Tenant(TenantBase, Bootstrappable):
|
|
24
|
+
__table_args__ = ({"extend_existing": True, "schema": "authn"},)
|
|
25
|
+
|
|
26
|
+
name: Mapped[str] = acol(
|
|
27
|
+
spec=ColumnSpec(
|
|
28
|
+
storage=S(String, nullable=False, unique=True),
|
|
29
|
+
field=F(constraints={"max_length": 120}, required_in=("create",)),
|
|
30
|
+
io=IO(
|
|
31
|
+
in_verbs=("create", "update", "replace"),
|
|
32
|
+
out_verbs=("read", "list"),
|
|
33
|
+
filter_ops=("eq", "ilike"),
|
|
34
|
+
sortable=True,
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
email: Mapped[str] = acol(
|
|
39
|
+
spec=ColumnSpec(
|
|
40
|
+
storage=S(String, nullable=False, unique=True),
|
|
41
|
+
field=F(constraints={"max_length": 120}, required_in=("create",)),
|
|
42
|
+
io=IO(
|
|
43
|
+
in_verbs=("create", "update", "replace"),
|
|
44
|
+
out_verbs=("read", "list"),
|
|
45
|
+
filter_ops=("eq", "ilike"),
|
|
46
|
+
sortable=True,
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
realm_id: Mapped[uuid.UUID | None] = acol(
|
|
51
|
+
spec=ColumnSpec(
|
|
52
|
+
storage=S(
|
|
53
|
+
PgUUID(as_uuid=True),
|
|
54
|
+
fk=ForeignKeySpec(target="authn.realms.id"),
|
|
55
|
+
nullable=True,
|
|
56
|
+
index=True,
|
|
57
|
+
),
|
|
58
|
+
field=F(),
|
|
59
|
+
io=IO(
|
|
60
|
+
in_verbs=("create", "update", "replace"),
|
|
61
|
+
out_verbs=("read", "list"),
|
|
62
|
+
filter_ops=("eq",),
|
|
63
|
+
sortable=True,
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
realm = relationship("Realm", back_populates="tenants")
|
|
69
|
+
users = relationship("User", back_populates="tenant", cascade="all, delete-orphan")
|
|
70
|
+
clients = relationship("Client", back_populates="tenant", cascade="all, delete-orphan")
|
|
71
|
+
|
|
72
|
+
DEFAULT_ROWS = [
|
|
73
|
+
{
|
|
74
|
+
"id": uuid.UUID("FFFFFFFF-0000-0000-0000-000000000000"),
|
|
75
|
+
"realm_id": uuid.UUID("FFFFFFFF-1000-0000-0000-000000000000"),
|
|
76
|
+
"email": "tenant@example.com",
|
|
77
|
+
"name": "Public",
|
|
78
|
+
"slug": "public",
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
__all__ = ["Tenant"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-storage-tenancy
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Owned tenancy identity database tables and migrations.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10,<3.15
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Dist: tba-primitives-identity[storage] (>=0.4.0.dev2)
|
|
15
|
+
Requires-Dist: tigrbl (>=0.4.4.dev1,<0.5)
|
|
16
|
+
Requires-Dist: tigrbl-migrations (>=0.4.5.dev4)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# tba-storage-tenancy
|
|
20
|
+
|
|
21
|
+
Owns the `tigrbl.identity.storage.tenancy` schema component.
|
|
22
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
tba_storage_tenancy/__init__.py,sha256=HoJ8HOyxQOG9vvo4LEJPfEUW3IDGqZF6ZIgJQ59tK6Q,366
|
|
2
|
+
tba_storage_tenancy/component.toml,sha256=FJa_18x_yws3kw0V0C0HNFJrv3a8cu1AbhYRyvKOBA4,625
|
|
3
|
+
tba_storage_tenancy/manifest.py,sha256=bYZmb6ItB8bRxtuCspB1us5eTvB1RqlTedISJZbws_w,325
|
|
4
|
+
tba_storage_tenancy/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
tba_storage_tenancy/migrations/versions/69854e73_52d3_53ec_9542_6737159e42d6_initial_schema.py,sha256=Csoo6LnQ96OB8k4CaND9thvOrdpT8TCU9eja1chhkv0,663
|
|
6
|
+
tba_storage_tenancy/migrations/versions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
tba_storage_tenancy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
tba_storage_tenancy/tables/__init__.py,sha256=VE0N2NPaoTslIBHGXp46Z2BYnQviKVhgWcXKuCAg-SU,416
|
|
9
|
+
tba_storage_tenancy/tables/realm/__init__.py,sha256=HhsTOBU15BFjxi3aParPuTeyvj0SAcK1GNvxNwinlXE,346
|
|
10
|
+
tba_storage_tenancy/tables/realm/_table.py,sha256=7Mzkuzxh1xoBHYriPtX3dy4-VYOHSMNQSr6A_WGod5g,2431
|
|
11
|
+
tba_storage_tenancy/tables/tenant/__init__.py,sha256=HhsTOBU15BFjxi3aParPuTeyvj0SAcK1GNvxNwinlXE,346
|
|
12
|
+
tba_storage_tenancy/tables/tenant/_table.py,sha256=0MTXmmRMJl3LL-LgOu7kI7CogOHB1rzdVok0nbkoiVo,2329
|
|
13
|
+
tba_storage_tenancy-0.4.0.dev2.dist-info/METADATA,sha256=mwVv_kixPOMVJ_tx_LENGoWKZqotZCk5XiE5KpL1ncE,827
|
|
14
|
+
tba_storage_tenancy-0.4.0.dev2.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
15
|
+
tba_storage_tenancy-0.4.0.dev2.dist-info/RECORD,,
|