A13e

Git Source

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

  1. The user-facing app calls login() to generate the bearer token on-chain.
  2. Any smart contract method that requires authentication accept this token as an argument. Then, it passes the token to authMsgSender() to verify it and obtain the authenticated user address. This address can then serve as a user ID for authorization.

State Variables

_revokedBearers

A mapping of revoked bearers. Access it directly or use the checkRevokedBearer modifier.

mapping(bytes32 => bool) internal _revokedBearers;

Functions

checkRevokedBearer

Reverts if the given bearer was revoked

modifier checkRevokedBearer(bytes calldata bearer);

login

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

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

authMsgSender

Validate the bearer token and return authenticated msg.sender.

function authMsgSender(bytes calldata bearer) internal view virtual returns (address);

revokeBearer

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

function revokeBearer(bytes32 bearer) internal;

Errors

RevokedBearer

The bearer token was revoked

error RevokedBearer();