Coverage for whole_app/auth.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-21 23:45 +0000

1import typing 

2 

3import fastapi 

4from fastapi.security.api_key import APIKeyHeader 

5 

6from .settings import SETTINGS 

7 

8 

9async def auth_via_api_key( 

10 user_provided_api_key: typing.Annotated[str, fastapi.Security(APIKeyHeader(name=SETTINGS.api_key_header_name))], 

11) -> str: 

12 if user_provided_api_key != SETTINGS.api_key: 

13 raise fastapi.HTTPException( 

14 status_code=401, 

15 detail="Could not validate api key", 

16 ) 

17 return user_provided_api_key