Documentation ¶
Index ¶
- Constants
- func CloseDB(db *bolt.DB) error
- func InitDB(file string) (*bolt.DB, error)
- func NewAppStorage(db *bolt.DB) (model.AppStorage, error)
- func NewInviteStorage(db *bolt.DB) (model.InviteStorage, error)
- func NewTokenBlacklist(db *bolt.DB) (model.TokenBlacklist, error)
- func NewTokenStorage(db *bolt.DB) (model.TokenStorage, error)
- func NewUserStorage(db *bolt.DB) (model.UserStorage, error)
- func NewVerificationCodeStorage(db *bolt.DB) (model.VerificationCodeStorage, error)
- 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) TestDatabaseConnection() error
- func (as *AppStorage) UpdateApp(appID string, newApp model.AppData) (model.AppData, error)
- type Error
- type InviteStorage
- func (is *InviteStorage) ArchiveAllByEmail(email string) error
- func (is *InviteStorage) ArchiveByID(id string) error
- func (is *InviteStorage) Close()
- func (is *InviteStorage) GetAll(withArchived bool, skip, limit int) ([]model.Invite, int, error)
- func (is *InviteStorage) GetByEmail(email string) (model.Invite, error)
- func (is *InviteStorage) GetByID(id string) (model.Invite, error)
- func (is *InviteStorage) Save(email, inviteToken, role, appID, createdBy string, expiresAt time.Time) error
- type TokenBlacklist
- type TokenStorage
- type UserStorage
- func (us *UserStorage) AddNewUser(user model.User, password string) (model.User, error)
- 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, federatedID, 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) RequestScopes(userID string, scopes []string) ([]string, error)
- func (us *UserStorage) ResetPassword(id, password string) error
- func (us *UserStorage) ResetUsername(id, username string) error
- func (us *UserStorage) Scopes() []string
- func (us *UserStorage) UpdateLoginMetadata(userID string)
- func (us *UserStorage) UpdateUser(userID string, user 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) UserExists(name string) bool
- type VerificationCodeStorage
Constants ¶
const ( ErrorWrongDataFormat = Error("wrong data format") // ErrorWrongDataFormat is for corrupted request data. ErrorInactiveUser = Error("user is inactive") // ErrorInactiveUser means that user is inactive. ErrorEmptyAppID = Error("empty appID param") // ErrorEmptyAppID means appID params is empty ErrorInactiveApp = Error("app is inactive") // ErrorInactiveApp means app is inactive )
const ( UserBucket = "Users" // UserBucket is a name for bucket with users. UserBySocialIDBucket = "UserBySocialID" // UserBySocialIDBucket is a name for bucket with social IDs as keys. UserByNameAndPassword = "UserByNameAndPassword" // UserByNameAndPassword is a name for bucket with user names as keys. UserByPhoneNumberBucket = "UserByPhoneNumber" // UserByPhoneNumberBucket is a name for bucket with phone numbers as keys. )
const (
// AppBucket is a name for bucket with apps.
AppBucket = "Apps"
)
const (
// BlacklistedTokenBucket is a name for bucket with tokens blacklist.
BlacklistedTokenBucket = "BlacklistedTokens"
)
const (
// InviteBucket is a name for bucket with invites.
InviteBucket = "Invites"
)
const (
// TokenBucket is a name for bucket with tokens.
TokenBucket = "Tokens"
)
const (
// VerificationCodesBucket is a bucket with verification codes.
VerificationCodesBucket = "VerificationCodes"
)
Variables ¶
This section is empty.
Functions ¶
func NewAppStorage ¶
func NewAppStorage(db *bolt.DB) (model.AppStorage, error)
NewAppStorage creates new BoltDB AppStorage implementation.
func NewInviteStorage ¶ added in v1.2.4
func NewInviteStorage(db *bolt.DB) (model.InviteStorage, error)
NewInviteStorage creates a BoltDB invites storage.
func NewTokenBlacklist ¶
func NewTokenBlacklist(db *bolt.DB) (model.TokenBlacklist, error)
NewTokenBlacklist creates a token blacklist in BoltDB.
func NewTokenStorage ¶
func NewTokenStorage(db *bolt.DB) (model.TokenStorage, error)
NewTokenStorage creates a BoltDB token storage.
func NewUserStorage ¶
func NewUserStorage(db *bolt.DB) (model.UserStorage, error)
NewUserStorage creates and inits an embedded user storage.
func NewVerificationCodeStorage ¶
func NewVerificationCodeStorage(db *bolt.DB) (model.VerificationCodeStorage, error)
NewVerificationCodeStorage creates and inits BoltDB verification code storage.
Types ¶
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 from memory by ID.
func (*AppStorage) DeleteApp ¶
func (as *AppStorage) DeleteApp(id string) error
DeleteApp deletes app by ID.
func (*AppStorage) DisableApp ¶
func (as *AppStorage) DisableApp(app model.AppData) error
DisableApp disables app in the 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) TestDatabaseConnection ¶
func (as *AppStorage) TestDatabaseConnection() error
TestDatabaseConnection checks whether we can fetch the first document in the applications bucket.
type InviteStorage ¶ added in v1.2.4
type InviteStorage struct {
// contains filtered or unexported fields
}
InviteStorage is a BoltDB invite storage.
func (*InviteStorage) ArchiveAllByEmail ¶ added in v1.2.4
func (is *InviteStorage) ArchiveAllByEmail(email string) error
ArchiveAllByEmail invalidates all invites by email.
func (*InviteStorage) ArchiveByID ¶ added in v1.2.4
func (is *InviteStorage) ArchiveByID(id string) error
ArchiveByID invalidates specific invite by its ID.
func (*InviteStorage) Close ¶ added in v1.2.4
func (is *InviteStorage) Close()
Close closes underlying database.
func (*InviteStorage) GetAll ¶ added in v1.2.4
GetAll returns all active invites by default. To get an invalid invites need to set withInvalid argument to true.
func (*InviteStorage) GetByEmail ¶ added in v1.2.4
func (is *InviteStorage) GetByEmail(email string) (model.Invite, error)
GetByEmail returns valid and not expired invite by email.
type TokenBlacklist ¶
type TokenBlacklist struct {
// contains filtered or unexported fields
}
TokenBlacklist is a BoltDB token blacklist.
func (*TokenBlacklist) Add ¶
func (tb *TokenBlacklist) Add(token string) error
Add adds token in the blacklist.
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 a BoltDB token storage.
func (*TokenStorage) DeleteToken ¶
func (ts *TokenStorage) DeleteToken(token string) error
DeleteToken removes token from the storage.
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 the storage.
type UserStorage ¶
type UserStorage struct {
// contains filtered or unexported fields
}
UserStorage implements user storage interface for BoltDB.
func (*UserStorage) AddNewUser ¶
AddNewUser adds new user to the storage.
func (*UserStorage) AddUserByNameAndPassword ¶
func (us *UserStorage) AddUserByNameAndPassword(username, password, role string, isAnonymous bool) (model.User, error)
AddUserByNameAndPassword creates new user and saves it in the database.
func (*UserStorage) AddUserByPhone ¶
func (us *UserStorage) AddUserByPhone(phone, role string) (model.User, error)
AddUserByPhone registers new user with phone number.
func (*UserStorage) AddUserWithFederatedID ¶
func (us *UserStorage) AddUserWithFederatedID(provider model.FederatedIdentityProvider, federatedID, role string) (model.User, error)
AddUserWithFederatedID adds new user with social ID.
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 deletes user by ID.
func (*UserStorage) DetachDeviceToken ¶
func (us *UserStorage) DetachDeviceToken(token string) error
DetachDeviceToken does nothing here.
func (*UserStorage) FetchUsers ¶
FetchUsers fetches users which name satisfies provided filterString. Supports pagination.
func (*UserStorage) IDByName ¶
func (us *UserStorage) IDByName(name string) (string, error)
IDByName returns userID by name.
func (*UserStorage) ImportJSON ¶
func (us *UserStorage) ImportJSON(data []byte) error
ImportJSON imports data from JSON.
func (*UserStorage) RequestScopes ¶
func (us *UserStorage) RequestScopes(userID string, scopes []string) ([]string, error)
RequestScopes returns requested scopes.
func (*UserStorage) ResetPassword ¶
func (us *UserStorage) ResetPassword(id, password string) error
ResetPassword sets new user password.
func (*UserStorage) ResetUsername ¶
func (us *UserStorage) ResetUsername(id, username string) error
ResetUsername sets user username.
func (*UserStorage) Scopes ¶
func (us *UserStorage) Scopes() []string
Scopes returns supported scopes.
func (*UserStorage) UpdateLoginMetadata ¶
func (us *UserStorage) UpdateLoginMetadata(userID string)
UpdateLoginMetadata updates user's login metadata.
func (*UserStorage) UpdateUser ¶
UpdateUser updates user in BoltDB storage.
func (*UserStorage) UserByEmail ¶
func (us *UserStorage) UserByEmail(email string) (model.User, error)
UserByEmail returns user by its email.
func (*UserStorage) UserByFederatedID ¶
func (us *UserStorage) UserByFederatedID(provider model.FederatedIdentityProvider, id string) (model.User, error)
UserByFederatedID returns user by federated ID.
func (*UserStorage) UserByID ¶
func (us *UserStorage) UserByID(id string) (model.User, error)
UserByID returns user by ID.
func (*UserStorage) UserByNamePassword ¶
func (us *UserStorage) UserByNamePassword(name, password string) (model.User, error)
UserByNamePassword returns user by name and password.
func (*UserStorage) UserByPhone ¶
func (us *UserStorage) UserByPhone(phone string) (model.User, error)
UserByPhone fetches user by phone number.
func (*UserStorage) UserExists ¶
func (us *UserStorage) UserExists(name string) bool
UserExists checks if user with provided name exists.
type VerificationCodeStorage ¶
type VerificationCodeStorage struct {
// contains filtered or unexported fields
}
VerificationCodeStorage implements verification code storage interface.
func (*VerificationCodeStorage) Close ¶
func (vcs *VerificationCodeStorage) Close()
Close closes underlying database.
func (*VerificationCodeStorage) CreateVerificationCode ¶
func (vcs *VerificationCodeStorage) CreateVerificationCode(phone, code string) error
CreateVerificationCode inserts new verification code to the database.
func (*VerificationCodeStorage) IsVerificationCodeFound ¶
func (vcs *VerificationCodeStorage) IsVerificationCodeFound(phone, code string) (bool, error)
IsVerificationCodeFound checks whether verification code can be found.