backends

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2016 License: Apache-2.0 Imports: 7 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 AuthBackend

type AuthBackend interface {
	SetValue(key, value []byte) error
	GetValue(key []byte) ([]byte, error)

	DeleteUser(username []byte) error

	AddUser(username, password []byte, admin bool) error
	GetUser(username []byte) (*User, error)
	GetAllUsers() ([]User, error)
}

type BoltAuth

type BoltAuth struct {
	DS          *bolt.DB
	TokenBucket []byte
	UserBucket  []byte
}

BoltCache - container to implement Cache instance with BoltDB backend for storage

func NewBoltDBAuthBackend

func NewBoltDBAuthBackend(db *bolt.DB, tokenBucket, userBucket []byte) *BoltAuth

func (*BoltAuth) AddUser

func (b *BoltAuth) AddUser(username, password []byte, admin bool) error

func (*BoltAuth) DeleteUser

func (b *BoltAuth) DeleteUser(username []byte) error

func (*BoltAuth) GetAllUsers

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

GetAllUsers return all users

func (*BoltAuth) GetUser

func (b *BoltAuth) GetUser(username []byte) (user *User, err error)

func (*BoltAuth) GetValue

func (b *BoltAuth) GetValue(key []byte) (value []byte, err error)

func (*BoltAuth) SetValue

func (b *BoltAuth) SetValue(key, value []byte) error

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