backends

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const TokenBucketName = "tokenbucket"

TokenBucketName

View Source
const UserBucketName = "authbucket"

UserBucketName - default name for BoltDB bucket that stores user info

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication added in v0.5.17

type Authentication interface {
	AddUser(username, password string, admin bool) (err error)
	GetUser(username string) (user *User, err error)
	GetAllUsers() (users []User, err error)
	InvalidateToken(token string) (err error)
	IsTokenBlacklisted(token string) (blacklisted bool, err error)
}

Authentication - generic interface for authentication backend

type CacheAuthBackend added in v0.5.17

type CacheAuthBackend struct {
	TokenCache cache.Cache
	// contains filtered or unexported fields
}

CacheAuthBackend - container to implement Cache instance with i.e. BoltDB backend for storage

func NewCacheBasedAuthBackend added in v0.5.17

func NewCacheBasedAuthBackend(tokenCache, userCache cache.Cache) *CacheAuthBackend

NewCacheBasedAuthBackend - takes two caches - one for token and one for users

func (*CacheAuthBackend) AddUser added in v0.5.17

func (b *CacheAuthBackend) AddUser(username, password string, admin bool) error

AddUser - adds user with provided username, password and admin parameters

func (*CacheAuthBackend) GetAllUsers added in v0.5.17

func (b *CacheAuthBackend) GetAllUsers() (users []User, err error)

func (*CacheAuthBackend) GetUser added in v0.5.17

func (b *CacheAuthBackend) GetUser(username string) (user *User, err error)

func (*CacheAuthBackend) InvalidateToken added in v0.5.17

func (b *CacheAuthBackend) InvalidateToken(token string) error

func (*CacheAuthBackend) IsTokenBlacklisted added in v0.5.17

func (b *CacheAuthBackend) IsTokenBlacklisted(token string) (bool, error)

IsTokenBlacklisted - checks if token is blacklisted.

type User

type User struct {
	UUID     string `json:"uuid" form:"-"`
	Username string `json:"username" form:"username"`
	Password string `json:"password" form:"password"`
	IsAdmin  bool   `json:"is_admin" form:"is_admin"`
}

func DecodeUser

func DecodeUser(user []byte) (*User, error)

func (*User) Encode

func (u *User) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

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