fastapi-permissions icon indicating copy to clipboard operation
fastapi-permissions copied to clipboard

Polymorphic principals

Open eddsalkield opened this issue 4 years ago • 0 comments

Firstly, thanks so much for your work on this project!

Just a feature request: that principals are not expected to have a specific type (currently, they are typed as str), but could instead be represented by an object of any type.

I would also suggest that we supply the default principals as namedtuples instead of colon-delimited strings, separating the semantics of the method (e.g. the role, user, etc.) from the values (e.g. create, read, update, delete,). Flask-Principal currently does this, making for a nicer user interface, in my opinion. They even supply partially-filled namedtuple principals for common methods: id, role, type, action.

Of course, since we're generalising the type of the principal, those wanting to use the string-based approach could still do so, with the default implementation being just a suggestion.

eddsalkield avatar Dec 15 '20 19:12 eddsalkield