Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint to get client permissions #32

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions neon_hana/app/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from fastapi import APIRouter, Request
from fastapi import APIRouter, Request, Depends

from neon_hana.app.dependencies import client_manager
from neon_hana.app.dependencies import client_manager, jwt_bearer
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", dependencies=[Depends(jwt_bearer)])
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
4 changes: 4 additions & 0 deletions neon_hana/schema/auth_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ class RefreshRequest(BaseModel):
access_token: str
refresh_token: str
client_id: str


class PermissionsRequest(BaseModel):
client_id: str
Loading