Skip to content

Commit

Permalink
Merge pull request #342 from betagouv/dependabot/pip/fastapi-0.110.1
Browse files Browse the repository at this point in the history
chore(deps): Bump fastapi from 0.100.0 to 0.110.1
  • Loading branch information
github-actions[bot] authored Apr 15, 2024
2 parents e8b833d + fbb62cf commit fd00a77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
15 changes: 0 additions & 15 deletions exceptions.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
from fastapi import Request, status
from fastapi.responses import JSONResponse


class NoProjectMembershipException(Exception):
pass


# pylint: disable=unused-argument
async def no_project_membership_exception_handler(
request: Request,
exc: NoProjectMembershipException,
):
return JSONResponse(
status_code=status.HTTP_403_FORBIDDEN,
content={"detail": "User does not have access to this project"},
)
25 changes: 16 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os

import sentry_sdk
from fastapi import FastAPI
from fastapi import FastAPI, Request, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse

from api import config, connect, data, deployments, hdf5, infra, vms
from exceptions import (
NoProjectMembershipException,
no_project_membership_exception_handler,
)
from exceptions import NoProjectMembershipException


sentry_sdk.init(
dsn=os.getenv("SENTRY_DSN"),
Expand All @@ -18,10 +17,6 @@

app = FastAPI()

app.add_exception_handler(
NoProjectMembershipException, no_project_membership_exception_handler
)

app.add_middleware(
CORSMiddleware,
allow_origins=os.getenv("CORS_ALLOWED_ORIGIN", "").split(" "),
Expand All @@ -37,3 +32,15 @@
app.include_router(config.router)
app.include_router(infra.router)
app.include_router(hdf5.router)


@app.exception_handler(NoProjectMembershipException)
# pylint: disable=unused-argument
async def no_project_membership_exception_handler(
request: Request,
exc: NoProjectMembershipException,
):
return JSONResponse(
status_code=status.HTTP_403_FORBIDDEN,
content={"detail": "User does not have access to this project"},
)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ azure-storage-file==2.1.0
black==23.12.1
h5grove @ git+https://github.com/wiwski/h5grove.git@feature/filepath-resolver
httpx==0.27.0
fastapi==0.100.0
fastapi==0.110.1
isort==5.13.2
mypy==1.0.1
pydantic-settings==2.2.1
Expand Down

0 comments on commit fd00a77

Please sign in to comment.