authdb

package
v0.0.0-...-7fb72bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionOptions

type ConnectionOptions struct {
	Address string
}

type Db

type Db interface {
	// Connect actually connects to the database
	Connect(ctx context.Context) error

	// Ping pings the database to check connectivity
	Ping(ctx context.Context) error

	// CreateUser creates a user in the database
	CreateUser(ctx context.Context, entry UserEntry) error

	// GetIDByEmail returns the user's ID or empty string if not found.
	// Returns an error if something unexpected goes wrong.
	GetIDByEmail(ctx context.Context, email string) (string, error)

	// GetUserByID returns the user's entry or nil if not found.
	// Returns an error if something unexpected goes wrong.
	GetUserByID(ctx context.Context, id string) (*UserEntry, error)

	// GetSharedValue returns a stored value; if it does not exist,
	// it will atomically store the given value and return that.
	GetSharedValue(ctx context.Context, key string, ifNotExist string) (string, error)

	// WaitForCreateUser will wait for the user to be created
	// in the database before returning, or an error if the user
	// was not seen as added before the context cancels
	WaitForCreateUser(ctx context.Context, id string) error
}

Db is a persistent database that stores user information

func New

func New(opts ConnectionOptions) Db

type UserEntry

type UserEntry struct {
	// ID is some uniquely generated identifier attached to the user
	ID string

	// Email is the user's email address
	Email string

	// PasswordHash is the hashed/salted password that will be used
	// for comparison/validation
	PasswordHashWithSalt string
}

UserEntry is a single row in the database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL