Versions in this module Expand all Collapse all v1 v1.2.0 Jun 4, 2016 Changes in this version + const DefaultACRedisIDKey + type ACRedisStore struct + func NewACRedisStore(cfg *RedisConfig, key string) (*ACRedisStore, error) + func (ar *ACRedisStore) Put(item ACInfo) (id int64, err error) + func (ar *ACRedisStore) TakeByID(id int64) (info *ACInfo, err error) type OAuthManager + func NewDefaultOAuthManager(cfg *OAuthConfig, mcfg *MongoConfig, ccName, tcName string) (*OAuthManager, error) + func NewOAuthManager(cfg *OAuthConfig) *OAuthManager + func (om *OAuthManager) SetClientStore(store ClientStore) + func (om *OAuthManager) SetConfig(cfg *OAuthConfig) + func (om *OAuthManager) SetTokenGenerate(generate TokenGenerate) + func (om *OAuthManager) SetTokenStore(store TokenStore) + type RedisConfig struct + Addr string + DB int64 + DialTimeout time.Duration + MaxRetries int + Network string + Password string + PoolSize int + PoolTimeout time.Duration + ReadTimeout time.Duration + WriteTimeout time.Duration v1.1.1 May 30, 2016 v1.1.0 May 29, 2016 Changes in this version type OAuthManager + func (om *OAuthManager) GenerateToken(cli Client, userID, scopes string, atExpireIn, rtExpireIn int64, ...) (token *Token, err error) type Token + ATID string + RTID string type TokenBasicInfo + TokenID string v1.0.0 May 26, 2016 Changes in this version + const DefaultACExpiresIn + const DefaultATExpiresIn + const DefaultCCATExpiresIn + const DefaultClientCollectionName + const DefaultIATExpiresIn + const DefaultRTExpiresIn + const DefaultRandomCodeLen + const DefaultTokenCollectionName + var ErrACInvalid = errors.New("The authorization code is invalid.") + var ErrACNotFound = errors.New("The authorization code is not found.") + var ErrATExpire = errors.New("The access token is expire.") + var ErrATInvalid = errors.New("The access token is invalid.") + var ErrATNotFound = errors.New("The access token is not found.") + var ErrCSInvalid = errors.New("The client secret is invalid.") + var ErrClientNotFound = errors.New("The client is not found.") + var ErrRTExpire = errors.New("The refresh token is expire.") + var ErrRTInvalid = errors.New("The refresh token is invalid.") + var ErrRTNotFound = errors.New("The refresh token is not found.") + func ValidateURI(baseURI string, redirectURI string) error + type ACConfig struct + ACExpiresIn int64 + ATExpiresIn int64 + RTExpiresIn int64 + RandomCodeLen int + type ACGenerate interface + Code func(info *ACInfo) (string, error) + Parse func(code string) (int64, error) + Verify func(code string, info *ACInfo) (bool, error) + func NewDefaultACGenerate() ACGenerate + type ACGenerateDefault struct + func (ag *ACGenerateDefault) Code(info *ACInfo) (string, error) + func (ag *ACGenerateDefault) Parse(code string) (id int64, err error) + func (ag *ACGenerateDefault) Verify(code string, info *ACInfo) (valid bool, err error) + type ACInfo struct + ClientID string + Code string + CreateAt int64 + ExpiresIn time.Duration + ID int64 + RedirectURI string + Scope string + UserID string + type ACManager struct + func NewACManager(oaManager *OAuthManager, config *ACConfig) *ACManager + func (am *ACManager) GenerateCode(clientID, userID, redirectURI, scopes string) (code string, err error) + func (am *ACManager) GenerateToken(code, redirectURI, clientID, clientSecret string, isGenerateRefresh bool) (token *Token, err error) + type ACMemoryStore struct + func (am *ACMemoryStore) Put(item ACInfo) (int64, error) + func (am *ACMemoryStore) TakeByID(id int64) (*ACInfo, error) + type ACStore interface + Put func(item ACInfo) (int64, error) + TakeByID func(id int64) (*ACInfo, error) + func NewACMemoryStore(gcInterval int64) ACStore + type CCConfig struct + ATExpiresIn int64 + type CCManager struct + func NewCCManager(oaManager *OAuthManager, config *CCConfig) *CCManager + func (cm *CCManager) GenerateToken(clientID, clientSecret, scopes string) (token *Token, err error) + type Client interface + Domain func() string + ID func() string + RetainData func() interface{} + Secret func() string + type ClientMongoStore struct + func (dcm *ClientMongoStore) GetByID(id string) (client Client, err error) + type ClientStore interface + GetByID func(id string) (Client, error) + func NewClientMongoStore(mongoConfig *MongoConfig, cName string) (ClientStore, error) + type DefaultClient struct + ClientDomain string + ClientID string + ClientSecret string + func (dc DefaultClient) Domain() string + func (dc DefaultClient) ID() string + func (dc DefaultClient) RetainData() interface{} + func (dc DefaultClient) Secret() string + type ImplicitConfig struct + ATExpiresIn int64 + type ImplicitManager struct + func NewImplicitManager(oaManager *OAuthManager, config *ImplicitConfig) *ImplicitManager + func (im *ImplicitManager) GenerateToken(clientID, userID, redirectURI, scopes string) (token *Token, err error) + type MongoConfig struct + DBName string + URL string + func NewMongoConfig(url, dbName string) *MongoConfig + type OAuthConfig struct + ACConfig *ACConfig + CCConfig *CCConfig + ImplicitConfig *ImplicitConfig + PasswordConfig *PasswordConfig + type OAuthManager struct + ACGenerate ACGenerate + ACStore ACStore + ClientStore ClientStore + Config *OAuthConfig + TokenGenerate TokenGenerate + TokenStore TokenStore + func CreateDefaultOAuthManager(mongoConfig *MongoConfig, tokenCollectionName, clientCollectionName string, ...) (*OAuthManager, error) + func (om *OAuthManager) CheckAccessToken(accessToken string) (token *Token, err error) + func (om *OAuthManager) GetACManager() *ACManager + func (om *OAuthManager) GetCCManager() *CCManager + func (om *OAuthManager) GetClient(clientID string) (cli Client, err error) + func (om *OAuthManager) GetImplicitManager() *ImplicitManager + func (om *OAuthManager) GetPasswordManager() *PasswordManager + func (om *OAuthManager) RefreshAccessToken(refreshToken, scopes string) (token *Token, err error) + func (om *OAuthManager) RevokeAccessToken(accessToken string) (err error) + func (om *OAuthManager) SetACGenerate(generate ACGenerate) + func (om *OAuthManager) SetACStore(store ACStore) + func (om *OAuthManager) ValidateClient(clientID, redirectURI string) (cli Client, err error) + type PasswordConfig struct + ATExpiresIn int64 + RTExpiresIn int64 + type PasswordManager struct + func NewPasswordManager(oaManager *OAuthManager, config *PasswordConfig) *PasswordManager + func (pm *PasswordManager) GenerateToken(clientID, userID, clientSecret, scopes string, isGenerateRefresh bool) (token *Token, err error) + type STATUS byte + const Actived + const Blocked + const Deleted + const Expired + type Token struct + ATCreateAt int64 + ATExpiresIn time.Duration + AccessToken string + ClientID string + CreateAt int64 + ID int64 + RTCreateAt int64 + RTExpiresIn time.Duration + RefreshToken string + Scope string + Status STATUS + UserID string + type TokenBasicInfo struct + Client Client + CreateAt int64 + UserID string + func NewTokenBasicInfo(cli Client, userID string, createAt int64) TokenBasicInfo + type TokenGenerate interface + AccessToken func(basicInfo TokenBasicInfo) (string, error) + RefreshToken func(basicInfo TokenBasicInfo) (string, error) + func NewDefaultTokenGenerate() TokenGenerate + type TokenGenerateDefault struct + func (tg *TokenGenerateDefault) AccessToken(basicInfo TokenBasicInfo) (string, error) + func (tg *TokenGenerateDefault) RefreshToken(basicInfo TokenBasicInfo) (string, error) + type TokenMongoStore struct + func (tm *TokenMongoStore) Create(item Token) (id int64, err error) + func (tm *TokenMongoStore) GetByAccessToken(accessToken string) (*Token, error) + func (tm *TokenMongoStore) GetByRefreshToken(refreshToken string) (*Token, error) + func (tm *TokenMongoStore) Update(id int64, info map[string]interface{}) (err error) + type TokenStore interface + Create func(item Token) (int64, error) + GetByAccessToken func(accessToken string) (*Token, error) + GetByRefreshToken func(refreshToken string) (*Token, error) + Update func(id int64, info map[string]interface{}) error + func NewTokenMongoStore(mongoConfig *MongoConfig, cName string) (TokenStore, error) Incompatible versions in this module v2.1.0+incompatible Jul 12, 2016 v2.0.0+incompatible Jul 9, 2016