Skip to content

Commit

Permalink
Implement /auth/permissions endpoint
Browse files Browse the repository at this point in the history
Change `ClientPermissions` to extend pydantic class for OpenAPI compat.
Closes #29
  • Loading branch information
NeonDaniel committed Oct 17, 2024
1 parent c3e533e commit 988946b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions neon_hana/app/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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)
3 changes: 2 additions & 1 deletion neon_hana/auth/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions neon_hana/schema/auth_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 988946b

Please sign in to comment.