Skip to content

Support a filter_by option in Gaurd #17

Open
@ketgo

Description

@ketgo

I am not sure if the following fits with the future vision of the package, but wanted to see if it can help resolve the issue -- all policy retrieval from Storage for Regex and Rule based checker.

Provide a filter_by option in Guard initialization, or the Guard.is_allowed method. This value can be then used by the Storage to filter policies on DB. In fact, if MongoEngine back-end is used to implement the MongoStorage, the structure of filter_by can be the same as that used in MongoEngine package. The other option is to just let it be a MongoDB query json.

Since the filter_by is DB dependent, a unified interface to create these filters that can be used for all storage types might be useful and part of a future feature. Some indexing strategy will also be useful.

Overall the approach has the following pros and cons:

Pros:
DB level filtering of policies before evaluation resulting in faster performance.

Cons:
It is possible for a user to use a filter that may result in some policies to be missed for evaluation.

I don't think the con is a big issue since the filter_by option can be left for advance usage with a user warning in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions