1313# under the License.
1414from __future__ import annotations
1515
16- from typing import TYPE_CHECKING , Callable , Optional , Awaitable
16+ from typing import TYPE_CHECKING , Callable , Optional , Awaitable , Dict , Any
1717
1818from supertokens_python .framework import BaseResponse
1919
2525 from supertokens_python .types import APIResponse
2626
2727from supertokens_python .utils import (
28- default_user_context ,
2928 send_200_response ,
3029 send_non_200_response_with_message ,
3130)
3433async def api_key_protector (
3534 api_implementation : APIInterface ,
3635 api_options : APIOptions ,
37- api_function : Callable [[APIInterface , APIOptions ], Awaitable [APIResponse ]],
36+ api_function : Callable [
37+ [APIInterface , APIOptions , Dict [str , Any ]], Awaitable [APIResponse ]
38+ ],
39+ user_context : Dict [str , Any ],
3840) -> Optional [BaseResponse ]:
39- user_context = default_user_context (api_options .request )
4041 should_allow_access = await api_options .recipe_implementation .should_allow_access (
4142 api_options .request , api_options .config , user_context
4243 )
@@ -46,5 +47,5 @@ async def api_key_protector(
4647 "Unauthorised access" , 401 , api_options .response
4748 )
4849
49- response = await api_function (api_implementation , api_options )
50+ response = await api_function (api_implementation , api_options , user_context )
5051 return send_200_response (response .to_json (), api_options .response )
0 commit comments