Documentation ¶
Index ¶
- Constants
- func NewAppStorage() (model.AppStorage, error)
- func NewTokenBlacklist() (model.TokenBlacklist, error)
- func NewTokenStorage() (model.TokenStorage, error)
- func NewUserStorage() (model.UserStorage, error)
- func NewVerificationCodeStorage() (model.VerificationCodeStorage, error)
- type AppData
- func (ad *AppData) Active() bool
- func (ad *AppData) AppleInfo() *model.AppleInfo
- func (ad *AppData) AuthzModel() string
- func (ad *AppData) AuthzPolicy() string
- func (ad *AppData) AuthzWay() model.AuthorizationWay
- func (ad *AppData) DebugTFACode() string
- func (ad *AppData) Description() string
- func (ad *AppData) ID() string
- func (ad *AppData) InviteTokenLifespan() int64
- func (ad *AppData) Name() string
- func (ad *AppData) NewUserDefaultRole() string
- func (ad *AppData) Offline() bool
- func (ad *AppData) RedirectURLs() []string
- func (ad *AppData) RefreshTokenLifespan() int64
- func (ad *AppData) RegistrationForbidden() bool
- func (ad *AppData) RolesBlacklist() []string
- func (ad *AppData) RolesWhitelist() []string
- func (ad *AppData) Sanitize()
- func (ad *AppData) Scopes() []string
- func (ad *AppData) Secret() string
- func (ad *AppData) SetSecret(secret string)
- func (ad *AppData) TFAStatus() model.TFAStatus
- func (ad *AppData) TokenLifespan() int64
- func (ad *AppData) TokenPayload() []string
- func (ad *AppData) Type() model.AppType
- type AppStorage
- func (as *AppStorage) ActiveAppByID(appID string) (model.AppData, error)
- func (as *AppStorage) AppByID(id string) (model.AppData, error)
- func (as *AppStorage) Close()
- func (as *AppStorage) CreateApp(app model.AppData) (model.AppData, error)
- func (as *AppStorage) DeleteApp(id string) error
- func (as *AppStorage) DisableApp(app model.AppData) error
- func (as *AppStorage) FetchApps(filterString string, skip, limit int) ([]model.AppData, int, error)
- func (as *AppStorage) ImportJSON(data []byte) error
- func (as *AppStorage) NewAppData() model.AppData
- func (as *AppStorage) TestDatabaseConnection() error
- func (as *AppStorage) UpdateApp(appID string, newApp model.AppData) (model.AppData, error)
- type Error
- type TokenBlacklist
- type TokenStorage
- type UserStorage
- func (us *UserStorage) AddUserByNameAndPassword(username, password, role string, isAnonymous bool) (model.User, error)
- func (us *UserStorage) AddUserByPhone(phone, role string) (model.User, error)
- func (us *UserStorage) AddUserWithFederatedID(provider model.FederatedIdentityProvider, id, role string) (model.User, error)
- func (us *UserStorage) AttachDeviceToken(id, token string) error
- func (us *UserStorage) Close()
- func (us *UserStorage) DeleteUser(id string) error
- func (us *UserStorage) DetachDeviceToken(token string) error
- func (us *UserStorage) FetchUsers(filterString string, skip, limit int) ([]model.User, int, error)
- func (us *UserStorage) IDByName(name string) (string, error)
- func (us *UserStorage) ImportJSON(data []byte) error
- func (us *UserStorage) NewUser() model.User
- func (us *UserStorage) RequestScopes(userID string, scopes []string) ([]string, error)
- func (us *UserStorage) ResetPassword(id, password string) error
- func (us *UserStorage) Scopes() []string
- func (us *UserStorage) UpdateLoginMetadata(userID string)
- func (us *UserStorage) UpdateUser(userID string, newUser model.User) (model.User, error)
- func (us *UserStorage) UserByEmail(email string) (model.User, error)
- func (us *UserStorage) UserByFederatedID(provider model.FederatedIdentityProvider, id string) (model.User, error)
- func (us *UserStorage) UserByID(id string) (model.User, error)
- func (us *UserStorage) UserByNamePassword(name, password string) (model.User, error)
- func (us *UserStorage) UserByPhone(phone string) (model.User, error)
- func (us *UserStorage) UserBySocialID(id string) (model.User, error)
- func (us *UserStorage) UserExists(name string) bool
- type VerificationCodeStorage
Constants ¶
const ( //ErrorNotFound general not found error ErrorNotFound = Error("not found") // ErrorEmptyAppID means appID params is empty ErrorEmptyAppID = Error("Empty appID param") // ErrorInactiveApp means app is inactive ErrorInactiveApp = Error("App is inactive") )
Variables ¶
This section is empty.
Functions ¶
func NewAppStorage ¶
func NewAppStorage() (model.AppStorage, error)
NewAppStorage creates new in-memory AppStorage implementation.
func NewTokenBlacklist ¶
func NewTokenBlacklist() (model.TokenBlacklist, error)
NewTokenBlacklist creates an in-memory token storage.
func NewTokenStorage ¶
func NewTokenStorage() (model.TokenStorage, error)
NewTokenStorage creates an in-memory token storage.
func NewUserStorage ¶
func NewUserStorage() (model.UserStorage, error)
NewUserStorage creates and inits in-memory user storage. Use it only for test purposes and in CI, all data is wiped on exit.
func NewVerificationCodeStorage ¶
func NewVerificationCodeStorage() (model.VerificationCodeStorage, error)
NewVerificationCodeStorage creates and inits in-memory verification code storage.
Types ¶
type AppData ¶
type AppData struct {
// contains filtered or unexported fields
}
AppData is an in-memory model for model.AppData.
func MakeAppData ¶
func MakeAppData(id, secret string, active bool, name, description string, scopes []string, offline bool, redirectURLs []string, refreshTokenLifespan, inviteTokenLifespan, tokenLifespan int64, tokenPayload []string, registrationForbidden bool, tfaStatus model.TFAStatus, debugTFACode string, authzWay model.AuthorizationWay, authzModel, authzPolicy string, rolesWhitelist, rolesBlacklist []string, newUserDefaultRole string) AppData
MakeAppData creates new in-memory app data instance.
func NewAppData ¶
NewAppData instantiates app data in-memory model from the general one.
func (*AppData) AuthzModel ¶
AuthzModel implements model.AppData interface.
func (*AppData) AuthzPolicy ¶
AuthzPolicy implements model.AppData interface.
func (*AppData) AuthzWay ¶
func (ad *AppData) AuthzWay() model.AuthorizationWay
AuthzWay implements model.AppData interface.
func (*AppData) DebugTFACode ¶
DebugTFACode implements model.AppData interface.
func (*AppData) Description ¶
Description implements model.AppData interface.
func (*AppData) InviteTokenLifespan ¶
InviteTokenLifespan a inviteToken lifespan in seconds, if 0 - default one is used.
func (*AppData) NewUserDefaultRole ¶
NewUserDefaultRole implements model.AppData interface.
func (*AppData) RedirectURLs ¶
RedirectURLs implements model.AppData interface.
func (*AppData) RefreshTokenLifespan ¶
RefreshTokenLifespan implements model.AppData interface.
func (*AppData) RegistrationForbidden ¶
RegistrationForbidden implements model.AppData interface.
func (*AppData) RolesBlacklist ¶
RolesBlacklist implements model.AppData interface.
func (*AppData) RolesWhitelist ¶
RolesWhitelist implements model.AppData interface.
func (*AppData) TokenLifespan ¶
TokenLifespan implements model.AppData interface.
func (*AppData) TokenPayload ¶
TokenPayload implements model.AppData interface.
type AppStorage ¶
type AppStorage struct {
// contains filtered or unexported fields
}
AppStorage is a fully functional app storage.
func (*AppStorage) ActiveAppByID ¶
func (as *AppStorage) ActiveAppByID(appID string) (model.AppData, error)
ActiveAppByID returns app by id only if it's active.
func (*AppStorage) AppByID ¶
func (as *AppStorage) AppByID(id string) (model.AppData, error)
AppByID returns app by ID from the in-memory storage.
func (*AppStorage) DeleteApp ¶
func (as *AppStorage) DeleteApp(id string) error
DeleteApp does nothing here.
func (*AppStorage) DisableApp ¶
func (as *AppStorage) DisableApp(app model.AppData) error
DisableApp deletes app from in-memory storage.
func (*AppStorage) FetchApps ¶
FetchApps fetches apps which name satisfies provided filterString. Supports pagination.
func (*AppStorage) ImportJSON ¶
func (as *AppStorage) ImportJSON(data []byte) error
ImportJSON imports data from JSON.
func (*AppStorage) NewAppData ¶
func (as *AppStorage) NewAppData() model.AppData
NewAppData returns pointer to newly created app data.
func (*AppStorage) TestDatabaseConnection ¶
func (as *AppStorage) TestDatabaseConnection() error
TestDatabaseConnection is always optimistic about the database connection.
type TokenBlacklist ¶
type TokenBlacklist struct {
// contains filtered or unexported fields
}
TokenBlacklist is an in-memory token storage. Please do not use it in production, it has no disk swap or persistent cache support.
func (*TokenBlacklist) Add ¶
func (tb *TokenBlacklist) Add(token string) error
Add blacklists token.
func (*TokenBlacklist) IsBlacklisted ¶
func (tb *TokenBlacklist) IsBlacklisted(token string) bool
IsBlacklisted returns true if the token is blacklisted.
type TokenStorage ¶
type TokenStorage struct {
// contains filtered or unexported fields
}
TokenStorage is an in-memory token storage. Please do not use it in production, it has no disk swap or persistent cache support.
func (*TokenStorage) DeleteToken ¶
func (ts *TokenStorage) DeleteToken(token string) error
DeleteToken removes token from memory storage. Actually, just marks it as deleted.
func (*TokenStorage) HasToken ¶
func (ts *TokenStorage) HasToken(token string) bool
HasToken returns true if the token is present in the storage.
func (*TokenStorage) SaveToken ¶
func (ts *TokenStorage) SaveToken(token string) error
SaveToken saves token in memory.
type UserStorage ¶
type UserStorage struct{}
UserStorage is an in-memory user storage .
func (*UserStorage) AddUserByNameAndPassword ¶
func (us *UserStorage) AddUserByNameAndPassword(username, password, role string, isAnonymous bool) (model.User, error)
AddUserByNameAndPassword returns randomly generated user.
func (*UserStorage) AddUserByPhone ¶
func (us *UserStorage) AddUserByPhone(phone, role string) (model.User, error)
AddUserByPhone returns randomly generated user.
func (*UserStorage) AddUserWithFederatedID ¶
func (us *UserStorage) AddUserWithFederatedID(provider model.FederatedIdentityProvider, id, role string) (model.User, error)
AddUserWithFederatedID returns randomly generated user.
func (*UserStorage) AttachDeviceToken ¶
func (us *UserStorage) AttachDeviceToken(id, token string) error
AttachDeviceToken does nothing here.
func (*UserStorage) DeleteUser ¶
func (us *UserStorage) DeleteUser(id string) error
DeleteUser does nothing here.
func (*UserStorage) DetachDeviceToken ¶
func (us *UserStorage) DetachDeviceToken(token string) error
DetachDeviceToken does nothing here.
func (*UserStorage) FetchUsers ¶
FetchUsers returns randomly generated user enclosed in slice.
func (*UserStorage) IDByName ¶
func (us *UserStorage) IDByName(name string) (string, error)
IDByName returns random id.
func (*UserStorage) ImportJSON ¶
func (us *UserStorage) ImportJSON(data []byte) error
ImportJSON imports data from JSON.
func (*UserStorage) NewUser ¶
func (us *UserStorage) NewUser() model.User
NewUser returns pointer to newly created user.
func (*UserStorage) RequestScopes ¶
func (us *UserStorage) RequestScopes(userID string, scopes []string) ([]string, error)
RequestScopes always returns requested scopes.
func (*UserStorage) ResetPassword ¶
func (us *UserStorage) ResetPassword(id, password string) error
ResetPassword does nothing here.
func (*UserStorage) Scopes ¶
func (us *UserStorage) Scopes() []string
Scopes returns supported scopes, could be static data of database.
func (*UserStorage) UpdateLoginMetadata ¶
func (us *UserStorage) UpdateLoginMetadata(userID string)
UpdateLoginMetadata does nothing here.
func (*UserStorage) UpdateUser ¶
UpdateUser returns what it receives.
func (*UserStorage) UserByEmail ¶
func (us *UserStorage) UserByEmail(email string) (model.User, error)
UserByEmail returns randomly generated user.
func (*UserStorage) UserByFederatedID ¶
func (us *UserStorage) UserByFederatedID(provider model.FederatedIdentityProvider, id string) (model.User, error)
UserByFederatedID returns randomly generated user.
func (*UserStorage) UserByID ¶
func (us *UserStorage) UserByID(id string) (model.User, error)
UserByID returns randomly generated user.
func (*UserStorage) UserByNamePassword ¶
func (us *UserStorage) UserByNamePassword(name, password string) (model.User, error)
UserByNamePassword returns randomly generated user.
func (*UserStorage) UserByPhone ¶
func (us *UserStorage) UserByPhone(phone string) (model.User, error)
UserByPhone returns randomly generated user.
func (*UserStorage) UserBySocialID ¶
func (us *UserStorage) UserBySocialID(id string) (model.User, error)
UserBySocialID returns randomly generated user.
func (*UserStorage) UserExists ¶
func (us *UserStorage) UserExists(name string) bool
UserExists always returns true.
type VerificationCodeStorage ¶
type VerificationCodeStorage struct{}
VerificationCodeStorage implements verification code storage interface.
func (*VerificationCodeStorage) Close ¶
func (vcs *VerificationCodeStorage) Close()
Close does nothing here.
func (*VerificationCodeStorage) CreateVerificationCode ¶
func (vcs *VerificationCodeStorage) CreateVerificationCode(phone, code string) error
CreateVerificationCode is always optimistic.
func (*VerificationCodeStorage) IsVerificationCodeFound ¶
func (vcs *VerificationCodeStorage) IsVerificationCodeFound(phone, code string) (bool, error)
IsVerificationCodeFound is always optimistic.