monban

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongCredentials is returned when credentials do not match.
	ErrWrongCredentials = errors.New("wrong username or password")
	// ErrInvalidToken is returned when a refresh token is invalid.
	ErrInvalidToken = errors.New("invalid token")
	// ErrNotFound is returned whenever an item does not exist in the database.
	ErrNotFound = errors.New("item not found")
)

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	Login(username, password string) (*Grant, error)
	Refresh(refreshToken string) (*Grant, error)
}

AuthService specifies the operations needed for authentication.

func NewAuthService

func NewAuthService(
	userStore UserStore,
	shimmieDB shimmie.Store,
	wl Whitelist,
	accTokDur time.Duration,
	refTokDur time.Duration,
	issuer string,
	secret string,
) AuthService

NewAuthService should be used for creating a new AuthService by providing a shimmie Store and a secret.

type Grant

type Grant struct {
	Access  string
	Refresh string
}

Grant is the result of successful authentication and contains access and refresh tokens.

type User

type User struct {
	ID      int64
	Name    string
	Pass    string
	Email   string
	Class   string
	Admin   bool
	Created time.Time
	Joined  time.Time
}

type UserStore

type UserStore interface {
	CreateUser(u *User) error
	GetUser(name string) (*User, error)
}

UserStore specifies the operations needed for storing and retrieving Monban users.

type Whitelist

type Whitelist interface {
	GetToken(tokenID string) (*jwt.Token, error)
	PutToken(tokenID string, t *jwt.Token) error
}

Whitelist describes the operations needed to keep refresh tokens in a "whitelist" session storage. If a refresh token exists in the storage and assuming it is not expired then it is considered valid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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