models

package
v0.0.0-...-a011022 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2018 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PrefixToken is the prefix for the token in redis
	PrefixToken = "token"
	// PrefixCode is the prefix for the code in redis
	PrefixCode = "code"
	// PrefixAccessToken is the prefix for the access token in redis
	PrefixAccessToken = "access_token"
)

Variables

This section is empty.

Functions

func NewClientStorage

func NewClientStorage(dep ginject.Injector) (oauth2.ClientStore, error)

NewClientStorage creates and returns a new client storage including all dependencies

func NewManager

func NewManager(dep ginject.Injector) *manage.Manager

NewManager returns a new manager for the server

func NewTokenStorage

func NewTokenStorage(dep ginject.Injector) (oauth2.TokenStore, error)

NewTokenStorage creates and returns a new token storage including all dependencies set

Types

type Client

type Client struct {
	Ident   string
	Secret  string
	Scopes  []string
	Domains []string
}

Client eventually represents one client

func (*Client) GetDomain

func (cli *Client) GetDomain() string

GetDomain returns the first domain (mostly enaugh)

func (*Client) GetID

func (cli *Client) GetID() string

GetID returns the client ID

func (*Client) GetSecret

func (cli *Client) GetSecret() string

GetSecret returns the client secret

func (*Client) GetUserID

func (cli *Client) GetUserID() string

GetUserID returns the userid which we do not support

type ClientStorage

type ClientStorage struct {
	Db *wrappers.MySQL `inject:"db"`
}

ClientStorage represents the actual storage handler

func (*ClientStorage) GetByID

func (cs *ClientStorage) GetByID(id string) (oauth2.ClientInfo, error)

GetByID returns this object loaded with the given id (ClientStore Interface)

type Err

type Err struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

Err is the error struct

type JWTGen

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

JWTGen is the dummy helper for the oauth2 Manager

func NewToken

func NewToken() *JWTGen

NewToken returns a brand new token generator

func (*JWTGen) New

func (ag *JWTGen) New() oauth2.TokenInfo

New returns a brand new token

type KeyProvider

type KeyProvider interface {
	GetPrivateKey() *rsa.PrivateKey
	GetPublicKey() *rsa.PublicKey
	GetJWK() *gojwk.Key
}

KeyProvider is the interface for a key provider

func NewKeyProvider

func NewKeyProvider(dep ginject.Injector) (KeyProvider, error)

NewKeyProvider creates a new key provider

type Session

type Session interface {
	New() Session
	FromSessionID(sessID string) error
	Store(sessID ...string) error
	GetSessionID() string
	GetUserID() string
	AssignUserID(userID string)
	Assemble() (string, error)
}

Session interface

func NewSession

func NewSession(deps ginject.Injector) Session

NewSession creates a new session item

type TokenGenerator

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

TokenGenerator is the struct for the token generator

func NewTokenGenerator

func NewTokenGenerator(dep ginject.Injector) *TokenGenerator

NewTokenGenerator creates a new token gen including all deps

func (*TokenGenerator) Token

func (tg *TokenGenerator) Token(data *oauth2.GenerateBasic, isGenRefresh bool) (access, refresh string, err error)

Token generates the actual token

type TokenStorage

type TokenStorage struct {
	Db    *wrappers.MySQL `inject:"db"`
	Redis *redis.Client   `inject:"redis"`
	// contains filtered or unexported fields
}

TokenStorage implements oauth2.TokenStore

func (TokenStorage) Create

func (m TokenStorage) Create(info oauth2.TokenInfo) error

Create creates all records of tokens after issuing

func (TokenStorage) GetByAccess

func (m TokenStorage) GetByAccess(access string) (ti oauth2.TokenInfo, err error)

GetByAccess uses the access token for token information data

func (TokenStorage) GetByCode

func (m TokenStorage) GetByCode(code string) (ti oauth2.TokenInfo, err error)

GetByCode uses the authorization code for token information data

func (TokenStorage) GetByRefresh

func (m TokenStorage) GetByRefresh(refresh string) (ti oauth2.TokenInfo, err error)

GetByRefresh uses the refresh token for token information data

func (TokenStorage) RemoveByAccess

func (m TokenStorage) RemoveByAccess(access string) error

RemoveByAccess uses the access token to delete the token information

func (TokenStorage) RemoveByCode

func (m TokenStorage) RemoveByCode(code string) error

RemoveByCode deletes the authorization code

func (TokenStorage) RemoveByRefresh

func (m TokenStorage) RemoveByRefresh(refresh string) error

RemoveByRefresh uses the refresh token to delete the token information

type UserLogin

type UserLogin struct {
	UserID    string
	SessionID string `form:"sess" binding:"required"`
	Email     string `form:"eml" binding:"required"`
	Password  string `form:"pwd" binding:"required"`

	Db *wrappers.MySQL `inject:"db"`
	// contains filtered or unexported fields
}

UserLogin is the user login handler

func NewUserLogin

func NewUserLogin(deps ginject.Injector) *UserLogin

NewUserLogin returns a brand new user login model

func (*UserLogin) CheckLogin

func (ul *UserLogin) CheckLogin() []Err

CheckLogin checks if eml/pwd is valid and assigns the userID if so

Jump to

Keyboard shortcuts

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