Documentation
¶
Overview ¶
Package auth defines the authentication layer of the application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Auth ¶
Auth is a service that provides HTTP handlers and middlewares used for authentication.
It uses a time-based nonce. The nonce is encrypted with the private key.
func NewAuth ¶
func NewAuth(jwtSecret jwt.Secret, pk *ecdsa.PrivateKey) *Auth
NewAuth builds the Auth struct.
func (*Auth) CallBack ¶
func (a *Auth) CallBack() http.HandlerFunc
CallBack is the handler called after login.
It:
- Fetches the signed message
- Validate and wrap the address in a JWT token
- Store the JWT token in a cookie for the browser.
func (*Auth) Login ¶
func (a *Auth) Login() http.HandlerFunc
Login is the handler called after login.
It sends a challenge to the authenticator (Metamask).
func (*Auth) Logout ¶
func (a *Auth) Logout() http.HandlerFunc
Logout removes session cookies and redirect to home.
func (*Auth) Middleware ¶
Middleware is an authentication guard for HTTP servers.
Click to show internal directories.
Click to hide internal directories.