Beispiel #1
0
 def endpoint(auth: Auth() = Depends()):
     return auth.token is not None
Beispiel #2
0
 def endpoint(auth: Auth(required=True) = Depends()):
     return auth.token is not None
Beispiel #3
0
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'])
Beispiel #4
0
 def endpoint(auth: Auth(token_type='refresh') = Depends()):
     return auth.token is not None
Beispiel #5
0
 def endpoint(auth: Auth(required=True,
                         abilities=['auth']) = Depends()) -> str:
     return True
Beispiel #6
0
 def endpoint(auth: Auth(required=True, roles=['user']) = Depends()) -> str:
     return True
Beispiel #7
0
 def endpoint(auth: Auth(required=True,
                         abilities=['auth',
                                    ('read', 'write')]) = Depends()) -> str:
     return True
Beispiel #8
0
 def endpoint(auth: Auth(required=True,
                         roles=['user', ('admin', 'super-admin')
                                ]) = Depends()) -> str:
     return True
Beispiel #9
0
 def endpoint(request: Request) -> str:
     return Auth()._get_credential_cookie(request)
Beispiel #10
0
 def endpoint(authorization: str = Header(None)) -> str:
     return Auth()._get_credential_header(authorization)
Beispiel #11
0
 def endpoint(request: Request, authorization: str = Header(None)) -> str:
     return Auth()._get_credential(request, authorization)