Documentation ¶
Index ¶
- Constants
- func NewAppStorage(logger *slog.Logger) (model.AppStorage, error)
- func NewConnectionTester() model.ConnectionTester
- func NewInviteStorage() (model.InviteStorage, error)
- func NewManagementKeysStorage() (model.ManagementKeysStorage, error)
- func NewMapOverlayFS(base fs.FS, files map[string][]byte) fs.FS
- func NewSessionStorage() model.SessionStorage
- func NewTokenBlacklist() (model.TokenBlacklist, error)
- func NewTokenStorage() (model.TokenStorage, error)
- func NewUserStorage() (model.UserStorage, error)
- func NewVerificationCodeStorage() (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) ([]model.AppData, error)
- func (as *AppStorage) ImportJSON(data []byte, cleanOldData bool) error
- func (as *AppStorage) TestDatabaseConnection() error
- func (as *AppStorage) UpdateApp(appID string, newApp model.AppData) (model.AppData, error)
- type ConnectionTester
- 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 ManagementKeysStorage
- func (ms *ManagementKeysStorage) ChangeScopesForKey(ctx context.Context, id string, scopes []string) (model.ManagementKey, error)
- func (ms *ManagementKeysStorage) CreateKey(ctx context.Context, name string, scopes []string) (model.ManagementKey, error)
- func (ms *ManagementKeysStorage) DisableKey(ctx context.Context, id string) (model.ManagementKey, error)
- func (ms *ManagementKeysStorage) GetKey(ctx context.Context, id string) (model.ManagementKey, error)
- func (ms *ManagementKeysStorage) GeyAllKeys(ctx context.Context) ([]model.ManagementKey, error)
- func (ms *ManagementKeysStorage) ImportJSON(data []byte, cleanOldData bool) error
- func (ms *ManagementKeysStorage) RenameKey(ctx context.Context, id, name string) (model.ManagementKey, error)
- func (ms *ManagementKeysStorage) UseKey(ctx context.Context, id string) (model.ManagementKey, error)
- type TokenBlacklist
- type TokenStorage
- type UserStorage
- func (us *UserStorage) AddNewUser(user model.User, password string) (model.User, error)
- func (us *UserStorage) AddUserWithFederatedID(user model.User, provider string, id, role string) (model.User, error)
- func (us *UserStorage) AddUserWithPassword(user model.User, password, role string, isAnonymous bool) (model.User, error)
- func (us *UserStorage) AllDeviceTokens(userID string) ([]string, error)
- func (us *UserStorage) AttachDeviceToken(id, token string) error
- func (us *UserStorage) CheckPassword(id, password 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) ImportJSON(data []byte, clearOldData bool) error
- func (us *UserStorage) ResetPassword(id, password string) error
- 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 string, id string) (model.User, error)
- func (us *UserStorage) UserByID(id 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) UserByUsername(username string) (model.User, error)
- 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(logger *slog.Logger) (model.AppStorage, error)
NewAppStorage creates new in-memory AppStorage implementation.
func NewConnectionTester ¶
func NewConnectionTester() model.ConnectionTester
func NewInviteStorage ¶
func NewInviteStorage() (model.InviteStorage, error)
NewInviteStorage creates an in-memory invite storage.
func NewManagementKeysStorage ¶ added in v2.4.4
func NewManagementKeysStorage() (model.ManagementKeysStorage, error)
NewKeysManagementStorage creates an in-memory management keys storage.
func NewSessionStorage ¶
func NewSessionStorage() model.SessionStorage
NewSessionStorage creates an in-memory session storage.
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 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 ¶
func (as *AppStorage) FetchApps(filterString string) ([]model.AppData, error)
FetchApps fetches apps which name satisfies provided filterString. Supports pagination.
func (*AppStorage) ImportJSON ¶
func (as *AppStorage) ImportJSON(data []byte, cleanOldData bool) error
ImportJSON imports data from JSON.
func (*AppStorage) TestDatabaseConnection ¶
func (as *AppStorage) TestDatabaseConnection() error
TestDatabaseConnection is always optimistic about the database connection.
type ConnectionTester ¶
type ConnectionTester struct{}
func (*ConnectionTester) Connect ¶
func (ct *ConnectionTester) Connect() error
type InviteStorage ¶
type InviteStorage struct {
// contains filtered or unexported fields
}
InviteStorage is an in-memory invite storage. Please do not use it in production, it has no disk swap or persistent cache support.
func (*InviteStorage) ArchiveAllByEmail ¶
func (is *InviteStorage) ArchiveAllByEmail(email string) error
ArchiveAllByEmail invalidates all invites by email.
func (*InviteStorage) ArchiveByID ¶
func (is *InviteStorage) ArchiveByID(id string) error
ArchiveByID invalidates specific invite by its ID.
func (*InviteStorage) GetAll ¶
GetAll returns all active invites by default. To get an invalid invites need to set withInvalid argument to true.
func (*InviteStorage) GetByEmail ¶
func (is *InviteStorage) GetByEmail(email string) (model.Invite, error)
GetByEmail returns valid and not expired invite by email.
type ManagementKeysStorage ¶ added in v2.4.4
type ManagementKeysStorage struct {
// contains filtered or unexported fields
}
func (*ManagementKeysStorage) ChangeScopesForKey ¶ added in v2.4.4
func (ms *ManagementKeysStorage) ChangeScopesForKey(ctx context.Context, id string, scopes []string) (model.ManagementKey, error)
func (*ManagementKeysStorage) CreateKey ¶ added in v2.4.4
func (ms *ManagementKeysStorage) CreateKey(ctx context.Context, name string, scopes []string) (model.ManagementKey, error)
func (*ManagementKeysStorage) DisableKey ¶ added in v2.4.4
func (ms *ManagementKeysStorage) DisableKey(ctx context.Context, id string) (model.ManagementKey, error)
func (*ManagementKeysStorage) GetKey ¶ added in v2.4.4
func (ms *ManagementKeysStorage) GetKey(ctx context.Context, id string) (model.ManagementKey, error)
func (*ManagementKeysStorage) GeyAllKeys ¶ added in v2.4.4
func (ms *ManagementKeysStorage) GeyAllKeys(ctx context.Context) ([]model.ManagementKey, error)
func (*ManagementKeysStorage) ImportJSON ¶ added in v2.4.5
func (ms *ManagementKeysStorage) ImportJSON(data []byte, cleanOldData bool) error
func (*ManagementKeysStorage) RenameKey ¶ added in v2.4.4
func (ms *ManagementKeysStorage) RenameKey(ctx context.Context, id, name string) (model.ManagementKey, error)
func (*ManagementKeysStorage) UseKey ¶ added in v2.4.4
func (ms *ManagementKeysStorage) UseKey(ctx context.Context, id string) (model.ManagementKey, error)
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 {
// contains filtered or unexported fields
}
UserStorage is an in-memory user storage .
func (*UserStorage) AddNewUser ¶
AddNewUser adds new user to the database.
func (*UserStorage) AddUserWithFederatedID ¶
func (us *UserStorage) AddUserWithFederatedID(user model.User, provider string, id, role string) (model.User, error)
AddUserWithFederatedID returns randomly generated user.
func (*UserStorage) AddUserWithPassword ¶
func (us *UserStorage) AddUserWithPassword(user model.User, password, role string, isAnonymous bool) (model.User, error)
AddUserWithPassword creates new user and saves it in the database.
func (*UserStorage) AllDeviceTokens ¶
func (us *UserStorage) AllDeviceTokens(userID string) ([]string, error)
TODO: implement get all device tokens logic
func (*UserStorage) AttachDeviceToken ¶
func (us *UserStorage) AttachDeviceToken(id, token string) error
AttachDeviceToken does nothing here.
func (*UserStorage) CheckPassword ¶
func (us *UserStorage) CheckPassword(id, password string) error
CheckPassword does nothig 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) ImportJSON ¶
func (us *UserStorage) ImportJSON(data []byte, clearOldData bool) error
ImportJSON imports data from JSON.
func (*UserStorage) ResetPassword ¶
func (us *UserStorage) ResetPassword(id, password string) error
ResetPassword does nothing here.
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 ¶
UserByFederatedID returns randomly generated user.
func (*UserStorage) UserByID ¶
func (us *UserStorage) UserByID(id string) (model.User, error)
UserByID 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) UserByUsername ¶
func (us *UserStorage) UserByUsername(username string) (model.User, error)
UserByUsername returns randomly generated user.
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.