Skip to content

Commit aa5f1d8

Browse files
feat: update authorization module for fga (#581)
1 parent bb8d2f1 commit aa5f1d8

25 files changed

+4017
-116
lines changed

src/workos/authorization.py

Lines changed: 1106 additions & 100 deletions
Large diffs are not rendered by default.

src/workos/fga.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class WarrantQueryListResource(
5454

5555

5656
class FGAModule(Protocol):
57+
"""
58+
.. deprecated::
59+
Use :class:`workos.authorization.AuthorizationModule` instead.
60+
"""
61+
5762
def get_resource(
5863
self, *, resource_type: str, resource_id: str
5964
) -> AuthorizationResource:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1+
from workos.types.authorization.access_check_response import AccessCheckResponse
2+
from workos.types.authorization.assignment import Assignment
13
from workos.types.authorization.environment_role import (
24
EnvironmentRole,
35
EnvironmentRoleList,
46
)
7+
from workos.types.authorization.organization_membership import (
8+
AuthorizationOrganizationMembership,
9+
)
510
from workos.types.authorization.organization_role import (
611
OrganizationRole,
712
OrganizationRoleEvent,
813
OrganizationRoleList,
914
)
1015
from workos.types.authorization.permission import Permission
16+
from workos.types.authorization.parent_resource_identifier import (
17+
ParentResourceIdentifier,
18+
)
19+
from workos.types.authorization.authorization_resource import AuthorizationResource
20+
from workos.types.authorization.resource_identifier import (
21+
ResourceIdentifier,
22+
ResourceIdentifierByExternalId,
23+
ResourceIdentifierById,
24+
)
1125
from workos.types.authorization.role import (
1226
Role,
1327
RoleList,
1428
)
29+
from workos.types.authorization.role_assignment import (
30+
RoleAssignment,
31+
RoleAssignmentResource,
32+
RoleAssignmentRole,
33+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from workos.types.workos_model import WorkOSModel
2+
3+
4+
class AccessCheckResponse(WorkOSModel):
5+
authorized: bool
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Literal
2+
3+
Assignment = Literal["direct", "indirect"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Literal, Optional
2+
3+
from workos.types.workos_model import WorkOSModel
4+
5+
6+
class AuthorizationResource(WorkOSModel):
7+
"""Representation of an Authorization Resource."""
8+
9+
object: Literal["authorization_resource"]
10+
id: str
11+
external_id: str
12+
name: str
13+
description: Optional[str] = None
14+
resource_type_slug: str
15+
organization_id: str
16+
parent_resource_id: Optional[str] = None
17+
created_at: str
18+
updated_at: str
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from workos.types.user_management.organization_membership import (
2+
BaseOrganizationMembership,
3+
)
4+
5+
AuthorizationOrganizationMembership = BaseOrganizationMembership
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Union
2+
3+
from typing_extensions import TypedDict
4+
5+
6+
class ParentResourceById(TypedDict):
7+
parent_resource_id: str
8+
9+
10+
class ParentResourceByExternalId(TypedDict):
11+
parent_resource_external_id: str
12+
parent_resource_type_slug: str
13+
14+
15+
ParentResourceIdentifier = Union[ParentResourceById, ParentResourceByExternalId]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Union
2+
3+
from typing_extensions import TypedDict
4+
5+
6+
class ResourceIdentifierById(TypedDict):
7+
resource_id: str
8+
9+
10+
class ResourceIdentifierByExternalId(TypedDict):
11+
resource_external_id: str
12+
resource_type_slug: str
13+
14+
15+
ResourceIdentifier = Union[ResourceIdentifierById, ResourceIdentifierByExternalId]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import Literal
2+
3+
from workos.types.workos_model import WorkOSModel
4+
5+
6+
class RoleAssignmentRole(WorkOSModel):
7+
slug: str
8+
9+
10+
class RoleAssignmentResource(WorkOSModel):
11+
id: str
12+
external_id: str
13+
resource_type_slug: str
14+
15+
16+
class RoleAssignment(WorkOSModel):
17+
object: Literal["role_assignment"]
18+
id: str
19+
role: RoleAssignmentRole
20+
resource: RoleAssignmentResource
21+
created_at: str
22+
updated_at: str

0 commit comments

Comments
 (0)