Skip to content

Commit fed8cbf

Browse files
committed
WIP
1 parent eee7b99 commit fed8cbf

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

workos/session.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
from typing import Protocol, Union
3+
4+
from workos.types.user_management.session import AuthenticateWithSessionCookieSuccessResponse, AuthenticateWithSessionCookieErrorResponse
5+
6+
class SessionModule(Protocol):
7+
8+
def authenticate(self) -> Union[AuthenticateWithSessionCookieSuccessResponse, AuthenticateWithSessionCookieErrorResponse]:
9+
...
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import List, Optional
2+
from enum import Enum
3+
4+
from workos.types.user_management.impersonator import Impersonator
5+
from workos.types.user_management.user import User
6+
from workos.types.workos_model import WorkOSModel
7+
8+
class AuthenticateWithSessionCookieFailureReason(Enum):
9+
INVALID_JWT = 'invalid_jwt'
10+
INVALID_SESSION_COOKIE = 'invalid_session_cookie'
11+
NO_SESSION_COOKIE_PROVIDED = 'no_session_cookie_provided'
12+
13+
class AuthenticateWithSessionCookieSuccessResponse(WorkOSModel):
14+
authenticated: bool = True
15+
sessionId: str
16+
organizationId: Optional[str] = None
17+
role: Optional[str] = None
18+
permissions: Optional[List[str]] = None
19+
user: User
20+
impersonator: Optional[Impersonator] = None
21+
22+
class AuthenticateWithSessionCookieErrorResponse(WorkOSModel):
23+
authenticated: bool = False
24+
reason: AuthenticateWithSessionCookieFailureReason
25+

0 commit comments

Comments
 (0)