A13e

Git Source

This is the interface for universal authentication mechanism (e.g. SIWE):

  1. The user-facing app calls login() which generates the authentication token on-chain.
  2. Any smart contract method that requires authentication can take this token as an argument. Passing this token to authMsgSender() verifies it and returns the authenticated user address. This verified address can then serve as a user ID for authorization.

State Variables

_revokedAuthTokens

A mapping of revoked authentication tokens. Access it directly or use the checkRevokedAuthToken modifier.

mapping(bytes32 => bool) internal _revokedAuthTokens;

Functions

checkRevokedAuthToken

Reverts if the given token was revoked

modifier checkRevokedAuthToken(bytes memory token);

login

Verify the login message and its signature and generate the token.

function login(string calldata message, SignatureRSV calldata sig) external view virtual returns (bytes memory);

authMsgSender

Validate the token and return authenticated msg.sender.

function authMsgSender(bytes memory token) internal view virtual returns (address);

revokeAuthToken

Revoke the authentication token with the corresponding hash. e.g. In case when the token is leaked or for extra-secure apps on every logout.

function revokeAuthToken(bytes32 token) internal;

Errors

A13e_RevokedAuthToken

The authentication token was revoked

error A13e_RevokedAuthToken();