Documentation ¶
Index ¶
- Constants
- Variables
- func IsUserType(t reflect.Type) bool
- func ScopeArrContains(scopes []string, str string) bool
- func ScopeContains(scope string, test string) bool
- func ScopeIn(scopes []string, test string) bool
- func ScopesIn(scopes []string, test []string) bool
- func UserIdString(uid interface{}) (id string, err error)
- type Auth
- type AuthModel
- type AuthStore
- type CaptchaStore
- type CodeError
- type Hexer
- type MemoryAuthStore
- type MemoryCaptchaStore
- type MemoryUserStore
- func (cs *MemoryUserStore) Find(id interface{}) (u User, err error)
- func (cs *MemoryUserStore) FindMobile(mobile string) (u User, err error)
- func (cs *MemoryUserStore) Remove(id interface{}) (err error)
- func (cs *MemoryUserStore) Save(u User) (err error)
- func (cs *MemoryUserStore) UpdatePwd(id interface{}, password string) (err error)
- func (cs *MemoryUserStore) UpdateScope(id interface{}, clientId, scope string) (err error)
- type O2ClientInfo
- type O2ClientStore
- type O2TokenStore
- type OauthError
- type SimpleUser
- func (u *SimpleUser) GetID() string
- func (u *SimpleUser) GetMobile() string
- func (u *SimpleUser) GetPassword() []byte
- func (u *SimpleUser) GetSalt() []byte
- func (u *SimpleUser) GetScopes() map[string]string
- func (u *SimpleUser) GetUserID() interface{}
- func (u *SimpleUser) Match(password string) bool
- func (u *SimpleUser) SetRawPassword(password string)
- func (u *SimpleUser) SetUserID(userID interface{})
- type User
- type UserStore
- type ValidResponse
Constants ¶
View Source
const ( ErrCodeInternalError = 100 ErrCodeInvalidCredential = 101 ErrCodeInvalidCaptcha = 102 ErrCodeValueRequired = 200 ErrCodeNotFound = 201 ErrCodeDuplicated = 202 )
View Source
const (
CaptchaCredentials oauth2.GrantType = "captcha"
)
Variables ¶
View Source
var ( ErrInternalError = NewOauthError(http.StatusInternalServerError, ErrCodeInternalError, "internal error") ErrInvalidCredential = NewOauthError(http.StatusUnauthorized, ErrCodeInvalidCredential, "invalid credential") ErrInvalidCaptcha = NewOauthError(http.StatusUnauthorized, ErrCodeInvalidCaptcha, "invalid captcha") ErrValueRequired = NewOauthError(http.StatusBadRequest, ErrCodeValueRequired, "value required") ErrNotFound = NewOauthError(http.StatusNotFound, ErrCodeNotFound, "not found") ErrDuplicated = NewOauthError(http.StatusConflict, ErrCodeDuplicated, "duplicated") )
View Source
var ( UserType = reflect.TypeOf(new(User)).Elem() SimpleUserPtrType = reflect.TypeOf(&SimpleUser{}) )
Functions ¶
func IsUserType ¶
func ScopeArrContains ¶
func ScopeContains ¶
func UserIdString ¶
Types ¶
type AuthModel ¶
--------------------------------------------------
func (*AuthModel) GetClientID ¶
func (*AuthModel) SetClientID ¶
type CaptchaStore ¶
type MemoryAuthStore ¶
func NewAuthStore ¶
func NewAuthStore() *MemoryAuthStore
func (*MemoryAuthStore) Exist ¶
func (as *MemoryAuthStore) Exist(auth Auth) bool
func (*MemoryAuthStore) Find ¶
func (as *MemoryAuthStore) Find(clientId string, userID string) (auth Auth, err error)
func (*MemoryAuthStore) Save ¶
func (as *MemoryAuthStore) Save(auth Auth) error
type MemoryCaptchaStore ¶
type MemoryCaptchaStore struct {
// contains filtered or unexported fields
}
func NewMemoryCaptchaStore ¶
func NewMemoryCaptchaStore(expireDuration time.Duration) (cs *MemoryCaptchaStore, err error)
func (*MemoryCaptchaStore) Remove ¶
func (cs *MemoryCaptchaStore) Remove(mobile string) (err error)
func (*MemoryCaptchaStore) Save ¶
func (cs *MemoryCaptchaStore) Save(mobile, captcha string) (err error)
type MemoryUserStore ¶
func (*MemoryUserStore) Find ¶
func (cs *MemoryUserStore) Find(id interface{}) (u User, err error)
func (*MemoryUserStore) FindMobile ¶
func (cs *MemoryUserStore) FindMobile(mobile string) (u User, err error)
func (*MemoryUserStore) Remove ¶
func (cs *MemoryUserStore) Remove(id interface{}) (err error)
func (*MemoryUserStore) Save ¶
func (cs *MemoryUserStore) Save(u User) (err error)
func (*MemoryUserStore) UpdatePwd ¶
func (cs *MemoryUserStore) UpdatePwd(id interface{}, password string) (err error)
func (*MemoryUserStore) UpdateScope ¶
func (cs *MemoryUserStore) UpdateScope(id interface{}, clientId, scope string) (err error)
type O2ClientInfo ¶
type O2ClientInfo interface { oauth2.ClientInfo GetScopes() []string GetGrantTypes() []oauth2.GrantType }
type O2ClientStore ¶
type O2TokenStore ¶
type OauthError ¶
type OauthError struct {
// contains filtered or unexported fields
}
func NewOauthError ¶
func NewOauthError(status, code int, err string) *OauthError
func (*OauthError) Code ¶
func (e *OauthError) Code() int
func (*OauthError) Error ¶
func (e *OauthError) Error() string
func (*OauthError) Status ¶
func (e *OauthError) Status() int
type SimpleUser ¶
type SimpleUser struct { UserID interface{} `bson:"_id" json:"user_id"` Mobile string `bson:"mobile" json:"mobile"` Password []byte `bson:"password" json:"password"` Salt []byte `bson:"salt" json:"salt"` Scopes map[string]string `bson:"scopes" json:"scopes,omitempty"` }
-------------------------------
func (*SimpleUser) GetID ¶
func (u *SimpleUser) GetID() string
func (*SimpleUser) GetMobile ¶
func (u *SimpleUser) GetMobile() string
func (*SimpleUser) GetPassword ¶
func (u *SimpleUser) GetPassword() []byte
func (*SimpleUser) GetSalt ¶
func (u *SimpleUser) GetSalt() []byte
func (*SimpleUser) GetScopes ¶
func (u *SimpleUser) GetScopes() map[string]string
func (*SimpleUser) GetUserID ¶
func (u *SimpleUser) GetUserID() interface{}
func (*SimpleUser) Match ¶
func (u *SimpleUser) Match(password string) bool
func (*SimpleUser) SetRawPassword ¶
func (u *SimpleUser) SetRawPassword(password string)
func (*SimpleUser) SetUserID ¶
func (u *SimpleUser) SetUserID(userID interface{})
type User ¶
type UserStore ¶
type ValidResponse ¶
Click to show internal directories.
Click to hide internal directories.