Skip to content

Commit

Permalink
fix: Add tenant id in global claim validators
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu committed Aug 10, 2023
1 parent 5287c18 commit a0ecabf
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions supertokens_python/recipe/session/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ async def validate_claims_for_session_handle(
global_claim_validators = await resolve(
recipe_impl.get_global_claim_validators(
session_info.user_id,
session_info.tenant_id,
claim_validators_added_by_other_recipes,
user_context,
)
Expand Down Expand Up @@ -188,6 +189,7 @@ async def validate_claims_for_session_handle(

async def validate_claims_in_jwt_payload(
user_id: str,
tenant_id: str,
jwt_payload: JSONObject,
override_global_claim_validators: Optional[
Callable[
Expand All @@ -212,6 +214,7 @@ async def validate_claims_in_jwt_payload(
global_claim_validators = await resolve(
recipe_impl.get_global_claim_validators(
user_id,
tenant_id,
claim_validators_added_by_other_recipes,
user_context,
)
Expand Down
1 change: 1 addition & 0 deletions supertokens_python/recipe/session/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ async def create_new_session(
def get_global_claim_validators(
self,
user_id: str,
tenant_id: str,
claim_validators_added_by_other_recipes: List[SessionClaimValidator],
user_context: Dict[str, Any],
) -> MaybeAwaitable[List[SessionClaimValidator]]:
Expand Down
1 change: 1 addition & 0 deletions supertokens_python/recipe/session/recipe_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ async def get_claim_value(
def get_global_claim_validators(
self,
user_id: str,
tenant_id: str,
claim_validators_added_by_other_recipes: List[SessionClaimValidator],
user_context: Dict[str, Any],
) -> MaybeAwaitable[List[SessionClaimValidator]]:
Expand Down
7 changes: 6 additions & 1 deletion supertokens_python/recipe/session/syncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def validate_claims_for_session_handle(

def validate_claims_in_jwt_payload(
user_id: str,
tenant_id: str,
jwt_payload: JSONObject,
override_global_claim_validators: Optional[
Callable[
Expand All @@ -401,6 +402,10 @@ def validate_claims_in_jwt_payload(

return sync(
async_validate_claims_in_jwt_payload(
user_id, jwt_payload, override_global_claim_validators, user_context
user_id,
tenant_id,
jwt_payload,
override_global_claim_validators,
user_context,
)
)
1 change: 1 addition & 0 deletions supertokens_python/recipe/session/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ async def get_required_claim_validators(
global_claim_validators = await resolve(
SessionRecipe.get_instance().recipe_implementation.get_global_claim_validators(
session.get_user_id(),
session.get_tenant_id(),
claim_validators_added_by_other_recipes,
user_context,
)
Expand Down
2 changes: 2 additions & 0 deletions tests/sessions/claims/test_verify_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def st_init_generator_with_overriden_global_validators(
def session_function_override(oi: RecipeInterface) -> RecipeInterface:
async def new_get_global_claim_validators(
_user_id: str,
_tenant_id: str,
_claim_validators_added_by_other_recipes: List[SessionClaimValidator],
_user_context: Dict[str, Any],
):
Expand All @@ -73,6 +74,7 @@ def st_init_generator_with_claim_validator(claim_validator: SessionClaimValidato
def session_function_override(oi: RecipeInterface) -> RecipeInterface:
async def new_get_global_claim_validators(
_user_id: str,
_tenant_id: str,
claim_validators_added_by_other_recipes: List[SessionClaimValidator],
_user_context: Dict[str, Any],
):
Expand Down

0 comments on commit a0ecabf

Please sign in to comment.