db

package
v0.0.0-...-ffa2c18 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2018 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")

	// we tick on this basis and kill anything older than this period
	RequestExpiry = time.Minute * 10
	RefreshExpiry = time.Hour * 24 * 14
)

Functions

func Code

func Code() string

Request Code

func Create

func Create(ch *account.Record, salt, secret string) error

func CreateRequest

func CreateRequest(id string, req *oauth2.AuthorizeRequest) error

oauth2

func CreateToken

func CreateToken(t *oauth2.Token, clientId, code string) error

func Delete

func Delete(id string) error

func DeleteRequest

func DeleteRequest(id string) error

func DeleteToken

func DeleteToken(accessToken string) error

func Init

func Init() error

func Read

func Read(id string) (*account.Record, error)

account

func ReadRefresh

func ReadRefresh(refreshToken string) (*oauth2.Token, string, error)

func ReadRequest

func ReadRequest(id string) (*oauth2.AuthorizeRequest, error)

func ReadToken

func ReadToken(accessToken string) (*oauth2.Token, string, error)

func Register

func Register(backend DB)

func Salt

func Salt() string

Some random salt bcrypt gives us one but we want ours too plus in binary fixed value so you need password, salt and binary to even begin hacking this.

func SaltAndSecret

func SaltAndSecret(id string) (string, string, error)
func Search(clientId, typ string, limit, offset int64) ([]*account.Record, error)

func Token

func Token() string

func Update

func Update(ch *account.Record, salt, secret string) error

func UpdateToken

func UpdateToken(accessToken string, t *oauth2.Token) error

Types

type Account

type Account interface {
	Read(id string) (*account.Record, error)
	Delete(id string) error
	Create(acc *account.Record, salt, secret string) error
	Update(acc *account.Record, salt, secret string) error
	Search(clientId, typ string, limit, offset int64) ([]*account.Record, error)
	SaltAndSecret(id string) (string, string, error)
}

type DB

type DB interface {
	Init() error
	Account
	Oauth2
}

type Oauth2

type Oauth2 interface {
	ReadRequest(id string) (*oauth2.AuthorizeRequest, error)
	CreateRequest(id string, req *oauth2.AuthorizeRequest) error
	DeleteRequest(id string) error

	ReadToken(accessToken string) (*oauth2.Token, string, error)
	ReadRefresh(refreshToken string) (*oauth2.Token, string, error)
	CreateToken(token *oauth2.Token, clientId string, code string) error
	UpdateToken(accessToken string, token *oauth2.Token) error
	DeleteToken(accessToken string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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