Documentation ¶
Overview ¶
Package auth defines the Authenticator interface and a registry for pluggable authentication providers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
func Authenticate(name string, credentials json.RawMessage) (json.RawMessage, error)
Authenticate uses the Authenticator registered as name to authenticate credentials. It panics if there is no Authenticator registered under name.
func DestroyEcdsaPrivateKey ¶
func DestroyEcdsaPrivateKey(key *ecdsa.PrivateKey)
DestroyEcdsaPrivateKey overwrites key's backing storage with zeroes.
func RegisterAuthenticator ¶
func RegisterAuthenticator(name string, implementation Authenticator)
RegisterAuthenticator registers an authenticator under the given name. It panics if there already is an Authenticator registered with the same name.
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate validates a JSON-encoded credential structure and returns a JSON-encoded bearer token. // If the credentials are either wrong or structurally invalid, Authenticate should return a non-nil error. Authenticate(credentials json.RawMessage) (token json.RawMessage, e error) // RenewToken exchanges an existing token (commonly the one returned by Authenticate) for a new token with a new life time. // The old token may or may not continue to be valid. Normally not. RenewToken(oldToken json.RawMessage) (newToken json.RawMessage, e error) // ExchangeToken validates a JSON-encoded token and exchanges it for a *Key if its valid. // Otherwise it should return a non-nil error. ExchangeToken(token json.RawMessage) (*Key, error) }
Authenticator is the interface implemented by authentication providers.
type Key ¶
type Key struct { Address common.Address PrivateKey *ecdsa.PrivateKey }
Key associates an ecdsa.PrivateKey with an Ethereum address.
func BytesToKey ¶
BytesToKey converts KeyBytes to a *Key and calls Destroy() on bs (only if successful). It returns a non-nil error for invalid KeyBytes.
func ExchangeToken ¶
func ExchangeToken(name string, token json.RawMessage) (*Key, error)
ExchangeToken uses the Authenticator registered as name to exchange token for a key. It panics if there is no Authenticator registered under name.
type KeyBytes ¶
type KeyBytes []byte
KeyBytes represents a byte-serialized Key
func KeyToBytes ¶
KeyToBytes converts a *Key to KeyBytes and calls Destroy() on key.
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore implements a quick-and-simple, in-memory encrypted key store. It utilizes a one-time pad scheme.