Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthDatabase ¶
type AuthDatabase interface { AddUser(username, fullName, passwordHash, passwordSalt string, isDisabled bool) (userRow, error) GetUser(username string) (userRow, error) GetUserByID(userID UserID) (userRow, error) CreateUserSession(token string, userID UserID, loginTime time.Time, lastSeenTime time.Time) error GetUserSession(token string) (UserSession, error) UpdateUserSessionLastSeenTime(token string, lastSeenTime time.Time) error RemoveUserSession(token string) error }
func NewInMemoryAuthDatabase ¶
func NewInMemoryAuthDatabase() AuthDatabase
func NewPSQLAuthDatabase ¶
func NewPSQLAuthDatabase(db *sql.DB) (AuthDatabase, error)
type Authenticator ¶
type Authenticator interface { Signup(fullname, username, password string) (string, error) Signin(username, password string) (string, error) Signout(token string) error Authenticate(token string) (User, error) }
Authenticator is an interface for authentication functions.
Authenticator is an interface to be used for critical authentication functionality; registering, logging in and out, and authenticating a user's token. Under the hood, it uses a database dependency to store user data and session information.
func NewInMemoryAuthenticator ¶
func NewInMemoryAuthenticator() (Authenticator, error)
func NewPSQLAuthenticator ¶
func NewPSQLAuthenticator(sqldb *sql.DB) (Authenticator, error)
NewAuthenticator returns an implementation of Authenticator.
This function takes a `sql.DB` and returns an Authenticator using that instance.
type User ¶
type User struct { ID UserID `json:"id"` Username string `json:"username"` FullName string `json:"fullname"` }
User is the basic user information returned to the caller on authentication.
Click to show internal directories.
Click to hide internal directories.