Initial commit

This commit is contained in:
shahzeydyfah
2024-02-15 00:17:51 +03:30
commit 4b0396466d
111 changed files with 6296 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
from fastapi import Depends
from starlette.authentication import AuthenticationBackend, AuthCredentials
from starlette.middleware.authentication import AuthenticationMiddleware
from core.utils.auth import get_current_user
class OAuth2Backend(AuthenticationBackend):
async def authenticate(self, request, user=Depends(get_current_user)):
return AuthCredentials(["authenticated"]), user
def setup_auth_middleware(app):
app.add_middleware(
AuthenticationMiddleware,
backend=OAuth2Backend(),
)