Skip to content

Commit c556453

Browse files
2 parents 8ff7c28 + 693a059 commit c556453

31 files changed

+3112
-7
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ lint:
2525

2626
.PHONY: do-gen-sync
2727
do-gen-sync:
28+
# cache client
2829
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_control_client.py src/momento/internal/synchronous/_scs_control_client.py
2930
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_data_client.py src/momento/internal/synchronous/_scs_data_client.py
3031
@poetry run python src/momento/internal/codegen.py src/momento/cache_client_async.py src/momento/cache_client.py
@@ -37,6 +38,10 @@ do-gen-sync:
3738
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_set_async.py tests/momento/cache_client/test_set.py
3839
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_sorted_set_async.py tests/momento/cache_client/test_sorted_set.py
3940
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_sorted_set_simple_async.py tests/momento/cache_client/test_sorted_set_simple.py
41+
# auth client
42+
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_token_client.py src/momento/internal/synchronous/_scs_token_client.py
43+
@poetry run python src/momento/internal/codegen.py src/momento/auth_client_async.py src/momento/auth_client.py
44+
@poetry run python src/momento/internal/codegen.py tests/momento/auth_client/test_auth_client_async.py tests/momento/auth_client/test_auth_client.py
4045

4146
.PHONY: gen-sync
4247
## Generate synchronous code and tests from asynchronous code.

src/momento/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from momento import logs
1111

1212
from .auth import CredentialProvider
13+
from .auth_client import AuthClient
14+
from .auth_client_async import AuthClientAsync
1315
from .cache_client import CacheClient
1416
from .cache_client_async import CacheClientAsync
1517
from .config import Configurations, TopicConfigurations
@@ -27,4 +29,6 @@
2729
"CacheClientAsync",
2830
"TopicClient",
2931
"TopicClientAsync",
32+
"AuthClient",
33+
"AuthClientAsync",
3034
]

src/momento/auth/access_control/__init__.py

Whitespace-only changes.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Disposable Token Scope.
2+
3+
Defines the data classes for specifying the permission scope of a disposable token.
4+
"""
5+
from dataclasses import dataclass
6+
from typing import List, Optional, Union
7+
8+
from momento.auth.access_control.permission_scope import (
9+
CachePermission,
10+
Permissions,
11+
)
12+
13+
14+
@dataclass
15+
class AllCacheItems:
16+
"""Indicates permission to access all items in a cache."""
17+
18+
pass
19+
20+
21+
@dataclass
22+
class CacheItemKey:
23+
"""The key of a cache item."""
24+
25+
key: str
26+
27+
28+
@dataclass
29+
class CacheItemKeyPrefix:
30+
"""The prefix of a cache item key."""
31+
32+
key_prefix: str
33+
34+
35+
@dataclass
36+
class CacheItemSelector:
37+
"""A selection of cache items to grant permissions to, either all cache items, a specific cache item, or a items that match a specified key prefix."""
38+
39+
cache_item: Union[CacheItemKey, CacheItemKeyPrefix, AllCacheItems, str]
40+
41+
def is_all_cache_items(self) -> bool:
42+
return isinstance(self.cache_item, AllCacheItems)
43+
44+
45+
@dataclass
46+
class DisposableTokenCachePermission(CachePermission):
47+
"""Encapsulates the information needed to grant permissions to a cache item."""
48+
49+
cache_item_selector: CacheItemSelector
50+
51+
52+
@dataclass
53+
class DisposableTokenCachePermissions:
54+
"""A list of permissions to grant to a disposable token."""
55+
56+
disposable_token_permissions: List[DisposableTokenCachePermission]
57+
58+
59+
@dataclass
60+
class DisposableTokenScope:
61+
"""A set of permissions to grant to a disposable token."""
62+
63+
disposable_token_scope: Union[Permissions, DisposableTokenCachePermissions]
64+
65+
66+
@dataclass
67+
class DisposableTokenProps:
68+
"""Additional properties for a disposable token, such as token_id, which can be used to identify the source of a token."""
69+
70+
token_id: Optional[str]

0 commit comments

Comments
 (0)