basic

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package basic implements a simple auth provider and backend that identifies a user via username & password combination.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
}

Config configures the basic auth provider

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements the auth.IdentityProvider interface.

func NewProvider

func NewProvider(ctx context.Context, store *Store) (*Provider, error)

NewProvider creates a new Provider with the associated config.

func (*Provider) ExtractIdentity

func (p *Provider) ExtractIdentity(route *auth.RouteInfo, w http.ResponseWriter, req *http.Request) (*auth.Identity, error)

ExtractIdentity implements the auth.IdentityProvider interface, providing identity based on the given username and password fields.

func (Provider) Info

Info implements the auth.Provider interface.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store can create new user/pass links and validate a username and password. bcrypt is used for password storage & verification.

func NewStore

func NewStore(ctx context.Context, db *sql.DB) (*Store, error)

NewStore creates a new DB. Error is returned if the prepared statements fail to register.

func (*Store) CreateTx

func (b *Store) CreateTx(ctx context.Context, tx *sql.Tx, userID, username, password string) error

CreateTx should add a new entry for the username/password combination linking to userID. An error is returned if the username is not unique or the userID is invalid. Must have same user or admin role.

func (*Store) Validate

func (b *Store) Validate(ctx context.Context, username, password string) (string, error)

Validate should return a userID if the username and password match.

Jump to

Keyboard shortcuts

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