Documentation ¶
Index ¶
- Constants
- func NewClientStorage(dep ginject.Injector) (oauth2.ClientStore, error)
- func NewManager(dep ginject.Injector) *manage.Manager
- func NewTokenStorage(dep ginject.Injector) (oauth2.TokenStore, error)
- type Client
- type ClientStorage
- type Err
- type JWTGen
- type KeyProvider
- type Session
- type TokenGenerator
- type TokenStorage
- func (m TokenStorage) Create(info oauth2.TokenInfo) error
- func (m TokenStorage) GetByAccess(access string) (ti oauth2.TokenInfo, err error)
- func (m TokenStorage) GetByCode(code string) (ti oauth2.TokenInfo, err error)
- func (m TokenStorage) GetByRefresh(refresh string) (ti oauth2.TokenInfo, err error)
- func (m TokenStorage) RemoveByAccess(access string) error
- func (m TokenStorage) RemoveByCode(code string) error
- func (m TokenStorage) RemoveByRefresh(refresh string) error
- type UserLogin
Constants ¶
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 ¶
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 ¶
Client eventually represents one client
type ClientStorage ¶
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 JWTGen ¶
type JWTGen struct {
// contains filtered or unexported fields
}
JWTGen is the dummy helper for the oauth2 Manager
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
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 ¶
CheckLogin checks if eml/pwd is valid and assigns the userID if so