From 988946b42260b8ce5066c08369d2b0e67039b87d Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Thu, 17 Oct 2024 09:13:26 -0700 Subject: [PATCH] Implement /auth/permissions endpoint Change `ClientPermissions` to extend pydantic class for OpenAPI compat. Closes #29 --- neon_hana/app/routers/auth.py | 6 ++++++ neon_hana/auth/permissions.py | 3 ++- neon_hana/schema/auth_requests.py | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/neon_hana/app/routers/auth.py b/neon_hana/app/routers/auth.py index 4cf78e2..09d7551 100644 --- a/neon_hana/app/routers/auth.py +++ b/neon_hana/app/routers/auth.py @@ -27,6 +27,7 @@ from fastapi import APIRouter, Request from neon_hana.app.dependencies import client_manager +from neon_hana.auth.permissions import ClientPermissions from neon_hana.schema.auth_requests import * auth_route = APIRouter(prefix="/auth", tags=["authentication"]) @@ -42,3 +43,8 @@ async def check_login(auth_request: AuthenticationRequest, @auth_route.post("/refresh") async def check_refresh(request: RefreshRequest) -> AuthenticationResponse: return client_manager.check_refresh_request(**dict(request)) + + +@auth_route.post("/permissions") +async def check_permissions(request: PermissionsRequest) -> ClientPermissions: + return client_manager.get_permissions(request.client_id) \ No newline at end of file diff --git a/neon_hana/auth/permissions.py b/neon_hana/auth/permissions.py index 287cc38..c89477b 100644 --- a/neon_hana/auth/permissions.py +++ b/neon_hana/auth/permissions.py @@ -24,7 +24,8 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from dataclasses import dataclass, asdict +from dataclasses import asdict +from pydantic.dataclasses import dataclass @dataclass diff --git a/neon_hana/schema/auth_requests.py b/neon_hana/schema/auth_requests.py index d02724d..e86b7cd 100644 --- a/neon_hana/schema/auth_requests.py +++ b/neon_hana/schema/auth_requests.py @@ -65,3 +65,8 @@ class RefreshRequest(BaseModel): access_token: str refresh_token: str client_id: str + + +class PermissionsRequest(BaseModel): + access_token: str + client_id: str