def endpoint(auth: Auth() = Depends()): return auth.token is not None
def endpoint(auth: Auth(required=True) = Depends()): return auth.token is not None
def test_check_has(): assert Auth()._check_has({'has1', 'has2'}, ['has1', ('has2', 'has3')]) assert not Auth()._check_has({'has1', 'has2'}, ['has1', ('has3', 'has4')]) assert not Auth()._check_has({'has1', 'has2'}, ['has1', 'has3']) assert not Auth()._check_has(set(), ['has1', 'has3'])
def endpoint(auth: Auth(token_type='refresh') = Depends()): return auth.token is not None
def endpoint(auth: Auth(required=True, abilities=['auth']) = Depends()) -> str: return True
def endpoint(auth: Auth(required=True, roles=['user']) = Depends()) -> str: return True
def endpoint(auth: Auth(required=True, abilities=['auth', ('read', 'write')]) = Depends()) -> str: return True
def endpoint(auth: Auth(required=True, roles=['user', ('admin', 'super-admin') ]) = Depends()) -> str: return True
def endpoint(request: Request) -> str: return Auth()._get_credential_cookie(request)
def endpoint(authorization: str = Header(None)) -> str: return Auth()._get_credential_header(authorization)
def endpoint(request: Request, authorization: str = Header(None)) -> str: return Auth()._get_credential(request, authorization)