MCPcopy
hub / github.com/feast-dev/feast / inject_user_details

Function inject_user_details

sdk/python/feast/permissions/server/rest.py:16–46  ·  view source on GitHub ↗

A function to extract the authorization token from a user request, extract the user details and propagate them to the current security manager, if any.

(request: Request)

Source from the content-addressed store, hash-verified

14
15
16async def inject_user_details(request: Request) -> Any:
17 """
18 A function to extract the authorization token from a user request, extract the user details and propagate them to the
19 current security manager, if any.
20 """
21 sm = get_security_manager()
22 current_user = None
23 if sm is not None:
24 try:
25 auth_manager = get_auth_manager()
26 access_token = auth_manager.token_extractor.extract_access_token(
27 request=request
28 )
29 if not access_token:
30 raise HTTPException(
31 status_code=401, detail="Missing authentication token"
32 )
33
34 current_user = (
35 await auth_manager.token_parser.user_details_from_access_token(
36 access_token=access_token
37 )
38 )
39
40 sm.set_current_user(current_user)
41 except Exception:
42 raise HTTPException(
43 status_code=401, detail="Invalid or expired access token"
44 )
45
46 return current_user

Callers

nothing calls this directly

Calls 5

get_security_managerFunction · 0.90
get_auth_managerFunction · 0.90
set_current_userMethod · 0.80
extract_access_tokenMethod · 0.45

Tested by

no test coverage detected