Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f03539f
commit 5e1c9d7
Showing
8 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
from .async_file_adapter import AsyncFileAdapter | ||
from .async_adapter import AsyncAdapter | ||
from .async_adapter_filtered import AsyncFilteredAdapter | ||
from .async_batch_adapter import AsyncBatchAdapter | ||
from .async_file_adapter import AsyncFileAdapter | ||
from .async_update_adapter import AsyncUpdateAdapter | ||
|
||
__all__ = [ | ||
"AsyncAdapter", | ||
"AsyncFilteredAdapter", | ||
"AsyncBatchAdapter", | ||
"AsyncFileAdapter", | ||
"AsyncUpdateAdapter", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class AsyncAdapter(metaclass=ABCMeta): | ||
"""The interface for async Casbin adapters.""" | ||
|
||
@abstractmethod | ||
async def load_policy(self, model): | ||
"""loads all policy rules from the storage.""" | ||
pass | ||
|
||
@abstractmethod | ||
async def save_policy(self, model): | ||
"""saves all policy rules to the storage.""" | ||
pass | ||
|
||
@abstractmethod | ||
async def add_policy(self, sec, ptype, rule): | ||
"""adds a policy rule to the storage.""" | ||
pass | ||
|
||
@abstractmethod | ||
async def remove_policy(self, sec, ptype, rule): | ||
"""removes a policy rule from the storage.""" | ||
pass | ||
|
||
@abstractmethod | ||
async def remove_filtered_policy(self, sec, ptype, field_index, *field_values): | ||
"""removes policy rules that match the filter from the storage. | ||
This is part of the Auto-Save feature. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class AsyncFilteredAdapter(metaclass=ABCMeta): | ||
"""AsyncFilteredAdapter is the interface for async Casbin adapters supporting filtered policies.""" | ||
|
||
@abstractmethod | ||
async def is_filtered(self): | ||
"""IsFiltered returns true if the loaded policy has been filtered | ||
Marks if the loaded policy is filtered or not | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
async def load_filtered_policy(self, model, filter): | ||
"""Loads policy rules that match the filter from the storage.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class AsyncBatchAdapter(metaclass=ABCMeta): | ||
"""AsyncBatchAdapter is the interface for async Casbin adapters with multiple add and remove policy functions.""" | ||
|
||
@abstractmethod | ||
async def add_policies(self, sec, ptype, rules): | ||
"""AddPolicies adds policy rules to the storage.""" | ||
pass | ||
|
||
@abstractmethod | ||
async def remove_policies(self, sec, ptype, rules): | ||
"""RemovePolicies removes policy rules from the storage.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class AsyncUpdateAdapter(metaclass=ABCMeta): | ||
"""AsyncUpdateAdapter is the interface for async Casbin adapters with add update policy function.""" | ||
|
||
@abstractmethod | ||
async def update_policy(self, sec, ptype, old_rule, new_policy): | ||
""" | ||
update_policy updates a policy rule from storage. | ||
This is part of the Auto-Save feature. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
async def update_policies(self, sec, ptype, old_rules, new_rules): | ||
""" | ||
UpdatePolicies updates some policy rules to storage, like db, redis. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
async def update_filtered_policies( | ||
self, sec, ptype, new_rules, field_index, *field_values | ||
): | ||
""" | ||
update_filtered_policies deletes old rules and adds new rules. | ||
""" | ||
pass |