Auth mechanism added
Closed this issue · 1 comments
Bishwas-py commented
core/auth
contains the mechanism for auth.
class BaseAuthMechanism:
def __init__(self, permissions: list[str] = None, message_response: dict = None, *args, **kwargs):
self.message_response = message_response or {"message": "Unauthorized"}
self.permissions = permissions
def authenticate(self, request: HttpRequest, *args, **kwargs):
pass
def authorize(self, request: HttpRequest, *args, **kwargs):
pass
def schema(self):
return {}
def app_schema(self):
return {}
def set_message_response(self, message_response: dict):
self.message_response = message_response
BaseAuthMechanism
can be inherited and new auth mechanism can be written.
Bishwas-py commented
schema
is for the overall OpenAPI details, and app_schema
is for the specific endpoint, to apply that schema.