Documentation ¶
Index ¶
- Variables
- type Auth
- func (a *Auth) AllowedChangeEmail(key EmailSecretKey, newEmail string) error
- func (a *Auth) Authentication(login, password string) (*Profile, error)
- func (a *Auth) DelPublicToken(publickToken string, profID ProfileID) error
- func (a *Auth) ForgotPassword(email string) (EmailSecretKey, error)
- func (a *Auth) NewToken(prof *Profile, tokenLifeTimeSecond TokenLifeTime) (string, error)
- func (a *Auth) ReadToken(publickToken string) (*Profile, error)
- func (a *Auth) RecoveryPassword(key EmailSecretKey, newPassword string) error
- func (a *Auth) Registration(login, email, password string) (*Profile, error)
- type AuthConfig
- type DriverStorage
- type EmailSecretKey
- type PoolBytesRaw
- type Profile
- type ProfileID
- type ResultPasswordByLogin
- type SingleflightDriverStorage
- func (sing *SingleflightDriverStorage) DelProfile(profileID ProfileID) error
- func (sing *SingleflightDriverStorage) DelToken(tokenID TokenID, profileID ProfileID) error
- func (sing *SingleflightDriverStorage) EmailDeleteSecretKey(key EmailSecretKey) error
- func (sing *SingleflightDriverStorage) EmailNewSecretKey(key EmailSecretKey, email string, lifetime int64) error
- func (sing *SingleflightDriverStorage) EmailReadSecretKey(key EmailSecretKey) (email string, err error)
- func (sing *SingleflightDriverStorage) GetEmail(profileID ProfileID) (email string, err error)
- func (sing *SingleflightDriverStorage) GetLogin(profileID ProfileID) (login string, err error)
- func (sing *SingleflightDriverStorage) GetLoginByEmail(email string) (login string, err error)
- func (sing *SingleflightDriverStorage) GetPasswordByID(profileID ProfileID) (password string, err error)
- func (sing *SingleflightDriverStorage) GetPasswordByLogin(login string) (res *ResultPasswordByLogin, err error)
- func (sing *SingleflightDriverStorage) GetProfileIDByEmail(email string) (profileID ProfileID, err error)
- func (sing *SingleflightDriverStorage) IsUniqueEmail(email string) (bool, error)
- func (sing *SingleflightDriverStorage) IsUniqueLogin(login string) (bool, error)
- func (sing *SingleflightDriverStorage) NewProfile(login, email, password string) (ProfileID, error)
- func (sing *SingleflightDriverStorage) NewToken(tokenID TokenID, profileID ProfileID, lifeTime TokenLifeTime) error
- func (sing *SingleflightDriverStorage) ReadToken(tokenID TokenID) (ProfileID, error)
- func (sing *SingleflightDriverStorage) SetEmailByProfileID(profileID ProfileID, email string) error
- func (sing *SingleflightDriverStorage) SetPasswordProfileByEmail(email string, password string) error
- func (sing *SingleflightDriverStorage) SetPasswordProfileByProfileID(profileID ProfileID, password string) error
- type Token
- type TokenID
- type TokenLifeTime
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTokenInvalidSignature = errors.New("token invalid digital signature") ErrWrongLoginOrPassword = errors.New("wrong login or password") ErrWrongPassword = errors.New("wrong password") ErrLoginNotUnique = errors.New("login is not unique") ErrEmailNotUnique = errors.New("email is not unique") ErrEmailSecretKeyNotFound = errors.New("email secret key not found") ErrTokenNotFound = errors.New("token not found") ErrTokenGoneLifeTime = errors.New("token lifetime is gone") ErrLoginNotFound = errors.New("login not found") ErrEmailNotFound = errors.New("login not found") ErrProfileIdNotFound = errors.New("profile id not found") )
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func NewAuth ¶
func NewAuth(cfg AuthConfig) *Auth
func (*Auth) AllowedChangeEmail ¶
func (a *Auth) AllowedChangeEmail(key EmailSecretKey, newEmail string) error
func (*Auth) Authentication ¶
func (*Auth) DelPublicToken ¶
func (*Auth) ForgotPassword ¶
func (a *Auth) ForgotPassword(email string) (EmailSecretKey, error)
func (*Auth) NewToken ¶
func (a *Auth) NewToken(prof *Profile, tokenLifeTimeSecond TokenLifeTime) (string, error)
func (*Auth) RecoveryPassword ¶
func (a *Auth) RecoveryPassword(key EmailSecretKey, newPassword string) error
type AuthConfig ¶
type AuthConfig struct { DriverStorage DriverStorage EmailLifeTimeSecond int64 ProfilePasswordSalt []byte TokenSecretKey []byte }
type DriverStorage ¶
type DriverStorage interface { //EmailReadSecretKey должен возвращать такие стандартные ошибки: //authentication.ErrEmailSecretKeyNotFound - если записи с таким ключом в базе не найдено //authentication.ErrEmailSecretKeyNotFound - если время жизни токена истекло EmailReadSecretKey(key EmailSecretKey) (email string, err error) //EmailReadSecretKey должен возвращать такие стандартные ошибки: //authentication.ErrTokenNotFound - время жизни токена истекло //authentication.ErrTokenNotFound - токена в базе данных не существует ReadToken(tokenID TokenID) (ProfileID, error) //GetProfileIDByEmail должен возвращать такие стандартные ошибки: //authentication.ErrEmailNotFound - если профиля с таким E-MAIL не существует GetProfileIDByEmail(email string) (profileID ProfileID, err error) //GetPasswordByID должен возвращать такие стандартные ошибки: //authentication.ErrProfileIdNotFound - если профиля с таким ID не существует GetPasswordByID(profileID ProfileID) (password string, err error) //GetPasswordByLogin должен возвращать такие стандартные ошибки: //authentication.ErrLoginNotFound - если профиля с таким логином не существует GetPasswordByLogin(login string) (res *ResultPasswordByLogin, err error) //GetLoginByEmail должен возвращать такие стандартные ошибки: //authentication.ErrEmailNotFound - если профиля с таким E-MAIL не существует GetLoginByEmail(email string) (login string, err error) //GetEmail должен возвращать такие стандартные ошибки: //authentication.ErrProfileIdNotFound - если профиля с таким ID не существует GetEmail(profileID ProfileID) (email string, err error) //GetLogin должен возвращать такие стандартные ошибки: //authentication.ErrProfileIdNotFound - если профиля с таким ID не существует GetLogin(profileID ProfileID) (login string, err error) EmailNewSecretKey(key EmailSecretKey, email string, lifetime int64) error EmailDeleteSecretKey(key EmailSecretKey) error NewToken(tokenID TokenID, profileID ProfileID, lifeTime TokenLifeTime) error DelToken(tokenID TokenID, profileID ProfileID) error IsUniqueLogin(login string) (bool, error) IsUniqueEmail(email string) (bool, error) NewProfile(login, email, password string) (ProfileID, error) DelProfile(profileID ProfileID) error SetPasswordProfileByEmail(email string, password string) error SetPasswordProfileByProfileID(profileID ProfileID, password string) error SetEmailByProfileID(profileID ProfileID, email string) error }
func RunSingleflightDriverStorage ¶
func RunSingleflightDriverStorage(st DriverStorage) DriverStorage
type EmailSecretKey ¶
type EmailSecretKey string
type PoolBytesRaw ¶
type PoolBytesRaw struct {
BS []byte
}
type Profile ¶
type Profile struct { ProfileID ProfileID // contains filtered or unexported fields }
func (*Profile) ChangeEmail ¶
func (t *Profile) ChangeEmail(password string) (EmailSecretKey, error)
func (*Profile) ChangePassword ¶
func (*Profile) DeleteProfile ¶
type ResultPasswordByLogin ¶
type SingleflightDriverStorage ¶
type SingleflightDriverStorage struct {
// contains filtered or unexported fields
}
func (*SingleflightDriverStorage) DelProfile ¶
func (sing *SingleflightDriverStorage) DelProfile(profileID ProfileID) error
func (*SingleflightDriverStorage) DelToken ¶
func (sing *SingleflightDriverStorage) DelToken(tokenID TokenID, profileID ProfileID) error
func (*SingleflightDriverStorage) EmailDeleteSecretKey ¶
func (sing *SingleflightDriverStorage) EmailDeleteSecretKey(key EmailSecretKey) error
func (*SingleflightDriverStorage) EmailNewSecretKey ¶
func (sing *SingleflightDriverStorage) EmailNewSecretKey(key EmailSecretKey, email string, lifetime int64) error
func (*SingleflightDriverStorage) EmailReadSecretKey ¶
func (sing *SingleflightDriverStorage) EmailReadSecretKey(key EmailSecretKey) (email string, err error)
func (*SingleflightDriverStorage) GetEmail ¶
func (sing *SingleflightDriverStorage) GetEmail(profileID ProfileID) (email string, err error)
func (*SingleflightDriverStorage) GetLogin ¶
func (sing *SingleflightDriverStorage) GetLogin(profileID ProfileID) (login string, err error)
func (*SingleflightDriverStorage) GetLoginByEmail ¶
func (sing *SingleflightDriverStorage) GetLoginByEmail(email string) (login string, err error)
func (*SingleflightDriverStorage) GetPasswordByID ¶
func (sing *SingleflightDriverStorage) GetPasswordByID(profileID ProfileID) (password string, err error)
func (*SingleflightDriverStorage) GetPasswordByLogin ¶
func (sing *SingleflightDriverStorage) GetPasswordByLogin(login string) (res *ResultPasswordByLogin, err error)
func (*SingleflightDriverStorage) GetProfileIDByEmail ¶
func (sing *SingleflightDriverStorage) GetProfileIDByEmail(email string) (profileID ProfileID, err error)
func (*SingleflightDriverStorage) IsUniqueEmail ¶
func (sing *SingleflightDriverStorage) IsUniqueEmail(email string) (bool, error)
func (*SingleflightDriverStorage) IsUniqueLogin ¶
func (sing *SingleflightDriverStorage) IsUniqueLogin(login string) (bool, error)
func (*SingleflightDriverStorage) NewProfile ¶
func (sing *SingleflightDriverStorage) NewProfile(login, email, password string) (ProfileID, error)
func (*SingleflightDriverStorage) NewToken ¶
func (sing *SingleflightDriverStorage) NewToken(tokenID TokenID, profileID ProfileID, lifeTime TokenLifeTime) error
func (*SingleflightDriverStorage) ReadToken ¶
func (sing *SingleflightDriverStorage) ReadToken(tokenID TokenID) (ProfileID, error)
func (*SingleflightDriverStorage) SetEmailByProfileID ¶
func (sing *SingleflightDriverStorage) SetEmailByProfileID(profileID ProfileID, email string) error
func (*SingleflightDriverStorage) SetPasswordProfileByEmail ¶
func (sing *SingleflightDriverStorage) SetPasswordProfileByEmail(email string, password string) error
func (*SingleflightDriverStorage) SetPasswordProfileByProfileID ¶
func (sing *SingleflightDriverStorage) SetPasswordProfileByProfileID(profileID ProfileID, password string) error
type Token ¶
type Token struct { ID TokenID LifeTime TokenLifeTime Hash string }
type TokenLifeTime ¶
type TokenLifeTime int64
Source Files ¶
Click to show internal directories.
Click to hide internal directories.