-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Session recipe multitenancy changes #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
bff0cbd
96234e1
a53aeb0
c2c85b7
5c483cb
06a2da3
81cb3fd
fbcd035
e7fccfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,6 +307,7 @@ async def consume_code_post( | |
user.user_id, | ||
{}, | ||
{}, | ||
tenant_id, | ||
user_context=user_context, | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,17 @@ | |
|
||
|
||
class SessionObj: | ||
def __init__(self, handle: str, user_id: str, user_data_in_jwt: Dict[str, Any]): | ||
def __init__( | ||
self, | ||
handle: str, | ||
user_id: str, | ||
user_data_in_jwt: Dict[str, Any], | ||
tenant_id: str, | ||
): | ||
self.handle = handle | ||
self.user_id = user_id | ||
self.user_data_in_jwt = user_data_in_jwt | ||
self.tenant_id = tenant_id | ||
|
||
|
||
class AccessTokenObj: | ||
|
@@ -69,15 +76,17 @@ def __init__( | |
expiry: int, | ||
custom_claims_in_access_token_payload: Dict[str, Any], | ||
time_created: int, | ||
tenant_id: str, | ||
): | ||
self.session_handle: str = session_handle | ||
self.user_id: str = user_id | ||
self.session_data_in_database: Dict[str, Any] = session_data_in_database | ||
self.expiry: int = expiry | ||
self.custom_claims_in_access_token_payload: Dict[ | ||
str, Any | ||
] = custom_claims_in_access_token_payload | ||
self.time_created: int = time_created | ||
self.session_handle = session_handle | ||
self.user_id = user_id | ||
self.session_data_in_database = session_data_in_database | ||
self.expiry = expiry | ||
self.custom_claims_in_access_token_payload = ( | ||
custom_claims_in_access_token_payload | ||
) | ||
self.time_created = time_created | ||
self.tenant_id = tenant_id | ||
|
||
|
||
class ReqResInfo: | ||
|
@@ -137,6 +146,7 @@ async def create_new_session( | |
access_token_payload: Optional[Dict[str, Any]], | ||
session_data_in_database: Optional[Dict[str, Any]], | ||
disable_anti_csrf: Optional[bool], | ||
tenant_id: str, | ||
user_context: Dict[str, Any], | ||
) -> SessionContainer: | ||
pass | ||
|
@@ -206,13 +216,21 @@ async def revoke_session( | |
|
||
@abstractmethod | ||
async def revoke_all_sessions_for_user( | ||
self, user_id: str, user_context: Dict[str, Any] | ||
self, | ||
user_id: str, | ||
tenant_id: str, | ||
revoke_across_all_tenants: Optional[bool], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not be optional in recipe interface There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
user_context: Dict[str, Any], | ||
) -> List[str]: | ||
pass | ||
|
||
@abstractmethod | ||
async def get_all_session_handles_for_user( | ||
self, user_id: str, user_context: Dict[str, Any] | ||
self, | ||
user_id: str, | ||
tenant_id: str, | ||
fetch_across_all_tenants: Optional[bool], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not be optional in recipe interface There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
user_context: Dict[str, Any], | ||
) -> List[str]: | ||
pass | ||
|
||
|
@@ -383,6 +401,7 @@ def __init__( | |
user_data_in_access_token: Optional[Dict[str, Any]], | ||
req_res_info: Optional[ReqResInfo], | ||
access_token_updated: bool, | ||
tenant_id: str, | ||
): | ||
self.recipe_implementation = recipe_implementation | ||
self.config = config | ||
|
@@ -395,6 +414,7 @@ def __init__( | |
self.user_data_in_access_token = user_data_in_access_token | ||
self.req_res_info: Optional[ReqResInfo] = req_res_info | ||
self.access_token_updated = access_token_updated | ||
self.tenant_id = tenant_id | ||
|
||
self.response_mutators: List[ResponseMutator] = [] | ||
|
||
|
@@ -436,6 +456,10 @@ async def merge_into_access_token_payload( | |
def get_user_id(self, user_context: Optional[Dict[str, Any]] = None) -> str: | ||
pass | ||
|
||
@abstractmethod | ||
def get_tenant_id(self, user_context: Optional[Dict[str, Any]] = None) -> str: | ||
pass | ||
|
||
@abstractmethod | ||
def get_access_token_payload( | ||
self, user_context: Optional[Dict[str, Any]] = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't have tenant id passed to it. You need to pass
None
to it instead so that it gets all session's for the user across all the tenants. See node PRThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.