mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-08-13 19:42:59 +00:00
wip3
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
"""Authentication helpers for FastAPI using Security()."""
|
"""Authentication helpers for FastAPI using Security()."""
|
||||||
|
|
||||||
from .base import AuthSource
|
from .abc import AuthSource
|
||||||
from .multi import MultiAuth
|
from .sources import BearerTokenAuth, CookieAuth, MultiAuth, OAuth2Auth, OpenIDAuth
|
||||||
from .sources import BearerTokenAuth, CookieAuth, OAuth2Auth, OpenIDAuth
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"AuthSource",
|
"AuthSource",
|
||||||
"BearerTokenAuth",
|
"BearerTokenAuth",
|
||||||
"CookieAuth",
|
"CookieAuth",
|
||||||
|
"MultiAuth",
|
||||||
"OAuth2Auth",
|
"OAuth2Auth",
|
||||||
"OpenIDAuth",
|
"OpenIDAuth",
|
||||||
"MultiAuth",
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
from .bearer import BearerTokenAuth
|
from .bearer import BearerTokenAuth
|
||||||
from .cookie import CookieAuth
|
from .cookie import CookieAuth
|
||||||
|
from .multi import MultiAuth
|
||||||
from .oauth2 import OAuth2Auth
|
from .oauth2 import OAuth2Auth
|
||||||
from .openid import OpenIDAuth
|
from .openid import OpenIDAuth
|
||||||
|
|
||||||
__all__ = ["BearerTokenAuth", "CookieAuth", "OAuth2Auth", "OpenIDAuth"]
|
__all__ = ["BearerTokenAuth", "CookieAuth", "MultiAuth", "OAuth2Auth", "OpenIDAuth"]
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer, SecurityS
|
|||||||
|
|
||||||
from fastapi_toolsets.exceptions import UnauthorizedError
|
from fastapi_toolsets.exceptions import UnauthorizedError
|
||||||
|
|
||||||
from ..base import AuthSource, _call_validator
|
from ..abc import AuthSource, _call_validator
|
||||||
|
|
||||||
|
|
||||||
class BearerTokenAuth(AuthSource):
|
class BearerTokenAuth(AuthSource):
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from fastapi.security import APIKeyCookie, SecurityScopes
|
|||||||
|
|
||||||
from fastapi_toolsets.exceptions import UnauthorizedError
|
from fastapi_toolsets.exceptions import UnauthorizedError
|
||||||
|
|
||||||
from ..base import AuthSource, _call_validator
|
from ..abc import AuthSource, _call_validator
|
||||||
|
|
||||||
|
|
||||||
class CookieAuth(AuthSource):
|
class CookieAuth(AuthSource):
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ from fastapi.security import SecurityScopes
|
|||||||
|
|
||||||
from fastapi_toolsets.exceptions import UnauthorizedError
|
from fastapi_toolsets.exceptions import UnauthorizedError
|
||||||
|
|
||||||
from .base import AuthSource
|
from ..abc import AuthSource
|
||||||
|
|
||||||
|
|
||||||
class MultiAuth:
|
class MultiAuth:
|
||||||
@@ -8,7 +8,7 @@ from fastapi.security import OAuth2PasswordBearer, SecurityScopes
|
|||||||
|
|
||||||
from fastapi_toolsets.exceptions import UnauthorizedError
|
from fastapi_toolsets.exceptions import UnauthorizedError
|
||||||
|
|
||||||
from ..base import AuthSource, _call_validator
|
from ..abc import AuthSource, _call_validator
|
||||||
|
|
||||||
|
|
||||||
class OAuth2Auth(AuthSource):
|
class OAuth2Auth(AuthSource):
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from fastapi.security import OpenIdConnect, SecurityScopes
|
|||||||
|
|
||||||
from fastapi_toolsets.exceptions import UnauthorizedError
|
from fastapi_toolsets.exceptions import UnauthorizedError
|
||||||
|
|
||||||
from ..base import AuthSource, _call_validator
|
from ..abc import AuthSource, _call_validator
|
||||||
|
|
||||||
|
|
||||||
class OpenIDAuth(AuthSource):
|
class OpenIDAuth(AuthSource):
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ class TestMultiAuth:
|
|||||||
assert org_calls == ["org_acme"]
|
assert org_calls == ["org_acme"]
|
||||||
|
|
||||||
def test_require_returns_new_multi_auth(self):
|
def test_require_returns_new_multi_auth(self):
|
||||||
from fastapi_toolsets.security.multi import MultiAuth as MultiAuthClass
|
from fastapi_toolsets.security.sources import MultiAuth as MultiAuthClass
|
||||||
|
|
||||||
bearer = BearerTokenAuth(role_validator)
|
bearer = BearerTokenAuth(role_validator)
|
||||||
multi = MultiAuth(bearer)
|
multi = MultiAuth(bearer)
|
||||||
|
|||||||
Reference in New Issue
Block a user