Coder Social home page Coder Social logo

Clean the access control code about mailu HOT 5 CLOSED

mailu avatar mailu commented on April 28, 2024
Clean the access control code

from mailu.

Comments (5)

kaiyou avatar kaiyou commented on April 28, 2024

After some discussion with pulser on IRC, it sounds like we have two choices: a full RBAC system (maybe based Flask-Principal for instance) or homemade decorators.

A proposed API would be a permissions module, exposing multiple decorators that would look like:

@permissions.global_admin
@permissions.domain_admin
@permissions.owner

Still, the permissions checks would require that the manipulated object is requested from database. So permissions checks would raise 404 errors, which sounds like an unrelated responsibility. Still no idea on how to fix this while still using decorators.

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

Permissions and confirmation forms were merged in a module named access. Current permissions API exposes:

# Enforces global administration privileges
@access.global_admin

# Model must be an Email subclass or Domain, the key must be a URI key
# Makes sure that the domain or the email's domain is managed by the current user
@access.domain_admin(model, key)

# Model must be a User or any model featuring a field named 'user' (Fetch and maybe some other user-specific resources later)
# Makes sure that the user belongs to a domain managed by the current user or is the current user itself
@access.owner(model, key)

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

I finished migrating all access-control features to the access module, removed the utils module and created a simple permissions audit script to avoid any surprise in the future.

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

And the audit script revealed a permission issue with domain deletion, which is great.

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

I just opened #55 for review before I merge anything into master due to the depth of some changes involved.

from mailu.

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.