Base
The template comes with an abstract class for developing authentication mechanisms, such as signing and validating, or proof-of-stake authentication.
Authorizers can be unique to each protocol. In the example subnet, the PoS Authorizer is used for the DHT (via DHTProtocol), and the Signature Authorizer is used in the InferenceProtocol.
Authorizer Base
class AuthorizedRequestBase:
"""
Interface for protobufs with the ``RequestAuthInfo auth`` field. Used for type annotations only.
"""
auth: RequestAuthInfo
class AuthorizedResponseBase:
"""
Interface for protobufs with the ``ResponseAuthInfo auth`` field. Used for type annotations only.
"""
auth: ResponseAuthInfo
class AuthorizerBase(ABC):
@abstractmethod
async def sign_request(
self, request: AuthorizedRequestBase, service_public_key: Optional[RSAPublicKey]
) -> None: ...
@abstractmethod
async def validate_request(self, request: AuthorizedRequestBase) -> bool: ...
@abstractmethod
async def sign_response(self, response: AuthorizedResponseBase, request: AuthorizedRequestBase) -> None: ...
@abstractmethod
async def validate_response(self, response: AuthorizedResponseBase, request: AuthorizedRequestBase) -> bool: ...
Last updated