Documentation ¶
Index ¶
- Constants
- func AwsErrorErrorNotFound(err error) bool
- func NewAppStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.AppStorage, error)
- func NewConnectionTester(settings model.DynamoDatabaseSettings) model.ConnectionTester
- func NewInviteStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.InviteStorage, error)
- func NewManagementKeysStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.ManagementKeysStorage, error)
- func NewSessionStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.SessionStorage, error)
- func NewTokenBlacklist(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.TokenBlacklist, error)
- func NewTokenStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.TokenStorage, error)
- func NewUserStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (model.UserStorage, error)
- func NewVerificationCodeStorage(logger *slog.Logger, settings model.DynamoDatabaseSettings) (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, app model.AppData) (model.AppData, error)
- type ConnectionTester
- type DB
- type DynamoDBSessionStorage
- func (is *DynamoDBSessionStorage) Close()
- func (dss *DynamoDBSessionStorage) DeleteSession(id string) error
- func (dss *DynamoDBSessionStorage) GetSession(id string) (model.Session, error)
- func (dss *DynamoDBSessionStorage) InsertSession(session model.Session) error
- func (dss *DynamoDBSessionStorage) ProlongSession(id string, newDuration model.SessionDuration) 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 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 Token
- type TokenBlacklist
- type TokenStorage
- type UserStorage
- func (us *UserStorage) AddNewUser(usr model.User, password string) (model.User, error)
- func (us *UserStorage) AddUserWithFederatedID(user model.User, provider string, federatedID, 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) 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 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) UserByUsername(username string) (model.User, error)
- type VerificationCodeStorage
Constants ¶
const ( // ErrorInternalError internal error ErrorInternalError = Error("internal error") // ErrorInactiveUser means user is inactive ErrorInactiveUser = Error("user is inactive") // ErrorEmptyAppID means appID params is empty ErrorEmptyAppID = Error("empty appID param") // ErrorInactiveApp means app is inactive ErrorInactiveApp = Error("app is inactive") // ErrorEmptyEndpointRegion endpoint or region are settings ErrorEmptyEndpointRegion = Error("endpoint and region required for dynamodb user storage") )
Variables ¶
This section is empty.
Functions ¶
func AwsErrorErrorNotFound ¶
AwsErrorErrorNotFound checks if error has type dynamodb.ErrCodeResourceNotFoundException.
func NewAppStorage ¶
func NewAppStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.AppStorage, error)
NewAppStorage creates new DynamoDB AppStorage implementation.
func NewConnectionTester ¶
func NewConnectionTester(settings model.DynamoDatabaseSettings) model.ConnectionTester
func NewInviteStorage ¶
func NewInviteStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.InviteStorage, error)
NewInviteStorage creates new DynamoDB invite storage.
func NewManagementKeysStorage ¶ added in v2.4.4
func NewManagementKeysStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.ManagementKeysStorage, error)
NewManagementKeysStorage creates and provisions new management keys storage instance.
func NewSessionStorage ¶
func NewSessionStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.SessionStorage, error)
NewSessionStorage creates new DynamoDB session storage.
func NewTokenBlacklist ¶
func NewTokenBlacklist( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.TokenBlacklist, error)
NewTokenBlacklist creates new DynamoDB token storage.
func NewTokenStorage ¶
func NewTokenStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.TokenStorage, error)
NewTokenStorage creates new DynamoDB token storage.
func NewUserStorage ¶
func NewUserStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.UserStorage, error)
NewUserStorage creates and provisions new user storage instance.
func NewVerificationCodeStorage ¶
func NewVerificationCodeStorage( logger *slog.Logger, settings model.DynamoDatabaseSettings, ) (model.VerificationCodeStorage, error)
NewVerificationCodeStorage creates and provisions new DynamoDB verification code storage.
Types ¶
type AppStorage ¶
type AppStorage struct {
// contains filtered or unexported fields
}
AppStorage a is 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 DynamoDB by ID. IDs are generated with https://github.com/rs/xid.
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 DynamoDB storage.
func (*AppStorage) FetchApps ¶
func (as *AppStorage) FetchApps(filterString string) ([]model.AppData, error)
FetchApps fetches apps which name satisfies provided filterString. Supports pagination. Search is case-sensitive for now.
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 checks whether we can fetch the first document in the applications table.
type ConnectionTester ¶
type ConnectionTester struct {
// contains filtered or unexported fields
}
func (*ConnectionTester) Connect ¶
func (ct *ConnectionTester) Connect() error
type DB ¶
DB represents connection to AWS DynamoDB service or local instance.
func (*DB) DeleteTable ¶ added in v2.3.2
type DynamoDBSessionStorage ¶
type DynamoDBSessionStorage struct {
// contains filtered or unexported fields
}
DynamoDBSessionStorage is a DynamoDB-backed storage for admin sessions.
func (*DynamoDBSessionStorage) Close ¶ added in v2.2.14
func (is *DynamoDBSessionStorage) Close()
func (*DynamoDBSessionStorage) DeleteSession ¶
func (dss *DynamoDBSessionStorage) DeleteSession(id string) error
DeleteSession deletes session from the storage.
func (*DynamoDBSessionStorage) GetSession ¶
func (dss *DynamoDBSessionStorage) GetSession(id string) (model.Session, error)
GetSession fetches session by ID.
func (*DynamoDBSessionStorage) InsertSession ¶
func (dss *DynamoDBSessionStorage) InsertSession(session model.Session) error
InsertSession inserts session to the storage.
func (*DynamoDBSessionStorage) ProlongSession ¶
func (dss *DynamoDBSessionStorage) ProlongSession(id string, newDuration model.SessionDuration) error
ProlongSession sets new duration for the existing session.
type InviteStorage ¶
type InviteStorage struct {
// contains filtered or unexported fields
}
InviteStorage is a DynamoDB invite storage.
func (*InviteStorage) ArchiveAllByEmail ¶
func (is *InviteStorage) ArchiveAllByEmail(email string) error
ArchiveAllByEmail archived all invites by email.
func (*InviteStorage) ArchiveByID ¶
func (is *InviteStorage) ArchiveByID(id string) error
ArchiveByID archived specific invite by its ID.
func (*InviteStorage) GetAll ¶
GetAll returns all active invites by default. To get an archived invites need to set withArchived argument to true.
func (*InviteStorage) GetByEmail ¶
func (is *InviteStorage) GetByEmail(email string) (model.Invite, error)
GetByEmail returns not archived and not expired invite by email.
type ManagementKeysStorage ¶ added in v2.4.4
type ManagementKeysStorage struct {
// contains filtered or unexported fields
}
UserStorage stores and manages data in DynamoDB storage.
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 Token ¶
type Token struct {
Token string `json:"token,omitempty"`
}
Token is a struct to store tokens in the database.
type TokenBlacklist ¶
type TokenBlacklist struct {
// contains filtered or unexported fields
}
TokenBlacklist is a DynamoDB storage for blacklisted tokens.
func (*TokenBlacklist) Add ¶
func (tb *TokenBlacklist) Add(token string) error
Add adds token to the blacklist.
func (*TokenBlacklist) IsBlacklisted ¶
func (tb *TokenBlacklist) IsBlacklisted(token string) bool
IsBlacklisted returns true if token is blacklisted.
type TokenStorage ¶
type TokenStorage struct {
// contains filtered or unexported fields
}
TokenStorage is a DynamoDB 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 token is present in the storage.
func (*TokenStorage) SaveToken ¶
func (ts *TokenStorage) SaveToken(token string) error
SaveToken saves token in the database.
type UserStorage ¶
type UserStorage struct {
// contains filtered or unexported fields
}
UserStorage stores and manages data in DynamoDB storage.
func (*UserStorage) AddNewUser ¶
AddNewUser adds new user.
func (*UserStorage) AddUserWithFederatedID ¶
func (us *UserStorage) AddUserWithFederatedID(user model.User, provider string, federatedID, role string) (model.User, error)
AddUserWithFederatedID adds new user with social ID.
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 do nothing here TODO: implement device storage
func (*UserStorage) CheckPassword ¶
func (us *UserStorage) CheckPassword(id, password string) error
CheckPassword check that password is valid for user id.
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 do nothing here yet TODO: implement
func (*UserStorage) FetchUsers ¶
FetchUsers fetches users which name satisfies provided filterString. Supports pagination. Search is case-sensitive for now.
func (*UserStorage) ImportJSON ¶
func (us *UserStorage) ImportJSON(data []byte, clearOldData bool) error
ImportJSON imports data from JSON.
func (*UserStorage) RequestScopes ¶
func (us *UserStorage) RequestScopes(userID string, scopes []string) ([]string, error)
RequestScopes for now returns requested scope TODO: implement scope logic
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, could be static data of database.
func (*UserStorage) UpdateLoginMetadata ¶
func (us *UserStorage) UpdateLoginMetadata(userID string)
UpdateLoginMetadata updates user's login metadata.
func (*UserStorage) UpdateUser ¶
UpdateUser updates user in DynamoDB storage.
func (*UserStorage) UserByEmail ¶
func (us *UserStorage) UserByEmail(email string) (model.User, error)
UserByEmail returns user by its email.
func (*UserStorage) UserByFederatedID ¶
UserByFederatedID returns user by federated ID.
func (*UserStorage) UserByID ¶
func (us *UserStorage) UserByID(id string) (model.User, error)
UserByID returns user by its ID.
func (*UserStorage) UserByPhone ¶
func (us *UserStorage) UserByPhone(phone string) (model.User, error)
UserByPhone fetches user by the phone number.
func (*UserStorage) UserByUsername ¶
func (us *UserStorage) UserByUsername(username string) (model.User, error)
UserByUsername returns user by name
type VerificationCodeStorage ¶
type VerificationCodeStorage struct {
// contains filtered or unexported fields
}
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 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.