FastAPI: how will you do authentication in FastAPI?
Asked in the round 1 stage.
Implement the framework-independent authentication dependency logic for a bearer token. Return the authenticated user details only when the Authorization header, token, expiration, and required scope are valid. Otherwise return None.
headers is a dictionary, token_store maps token strings to claim dictionaries, now is an integer timestamp, and required_scope is a string. Return {"user_id": ..., "scopes": [...]} for valid access, or None.
def authenticate_request(headers, token_store, now, required_scope):