Giter Club home page Giter Club logo

Comments (2)

kompotkot avatar kompotkot commented on June 16, 2024

Design doc: https://docs.google.com/document/d/1DVdzbXRBBkMCBZWB0BzS7AsRlCBSKJDaRkB294I_7T8/edit

from api.

kompotkot avatar kompotkot commented on June 16, 2024

Also there are different requrements for authorization changes.

Right now we are using class BroodAuthMiddleware(BaseHTTPMiddleware) with whitelist: Optional[Dict[str, str]] where you can specify what route Path could bypass middleware authentification check in FastAPI app. We found it not scalable, because it brings regexp logic if you need to apply it route Path like @app.get("/{leaderboard_id}/config") where leaderboard_id could uuid or number or any other string - depends on usecase.

Umfortunatly, FastAPI dunctionality does not provide this functionality and disscusion exists for 3 years already: tiangolo/fastapi#7691

After some investigation, there are some solutions:

  1. Continue modify BroodAuthMiddleware or APIRouter
  2. Split authentificated routes to apps
  3. Migrate from middlewares to Dependencies.

From my point of view 1st solution will bring to us overcomplicated authorization logic which better to avoid in such important parts of code. Another 2nd solution split pathes in documentation and could make application not friendly for other developers who use our code from outside.

Preferable solution to migrate from middlewares to FastAPI Dependencies, same approach we are using in bugout-dev/brood like user_authorization = Depends(request_user_authorization). It will requires additional checks that all routes correctly set and also brings some code duplication. But we will have more granular set up.

from api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.