dynamodb

package
v1.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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")
)

Variables

This section is empty.

Functions

func AwsErrorErrorNotFound

func AwsErrorErrorNotFound(err error) bool

AwsErrorErrorNotFound checks if error has type dynamodb.ErrCodeResourceNotFoundException.

func NewAppStorage

func NewAppStorage(db *DB) (model.AppStorage, error)

NewAppStorage creates new DynamoDB AppStorage implementation.

func NewInviteStorage added in v1.2.4

func NewInviteStorage(db *DB) (model.InviteStorage, error)

NewInviteStorage creates new DynamoDB invite storage.

func NewTokenBlacklist

func NewTokenBlacklist(db *DB) (model.TokenBlacklist, error)

NewTokenBlacklist creates new DynamoDB token storage.

func NewTokenStorage

func NewTokenStorage(db *DB) (model.TokenStorage, error)

NewTokenStorage creates new DynamoDB token storage.

func NewUserStorage

func NewUserStorage(db *DB) (model.UserStorage, error)

NewUserStorage creates and provisions new user storage instance.

func NewVerificationCodeStorage

func NewVerificationCodeStorage(db *DB) (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) Close

func (as *AppStorage) Close()

Close does nothing here.

func (*AppStorage) CreateApp

func (as *AppStorage) CreateApp(app model.AppData) (model.AppData, error)

CreateApp creates new app in DynamoDB.

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, skip, limit int) ([]model.AppData, int, 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) 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.

func (*AppStorage) UpdateApp

func (as *AppStorage) UpdateApp(appID string, app model.AppData) (model.AppData, error)

UpdateApp updates app in DynamoDB storage.

type DB

type DB struct {
	C *dynamodb.DynamoDB
}

DB represents connection to AWS DynamoDB service or local instance.

func NewDB

func NewDB(endpoint string, region string) (*DB, error)

NewDB creates new database connection.

func (*DB) IsTableExists

func (db *DB) IsTableExists(table string) (bool, error)

IsTableExists checks if table exists.

type Error

type Error string

Error - domain level error type

func (Error) Error

func (e Error) Error() string

Error - implementation of std.Error protocol

type InviteStorage added in v1.2.4

type InviteStorage struct {
	// contains filtered or unexported fields
}

InviteStorage is a DynamoDB invite storage.

func (*InviteStorage) ArchiveAllByEmail added in v1.2.4

func (is *InviteStorage) ArchiveAllByEmail(email string) error

ArchiveAllByEmail archived all invites by email.

func (*InviteStorage) ArchiveByID added in v1.2.4

func (is *InviteStorage) ArchiveByID(id string) error

ArchiveByID archived specific invite by its ID.

func (*InviteStorage) Close added in v1.2.4

func (is *InviteStorage) Close()

Close does nothing here.

func (*InviteStorage) GetAll added in v1.2.4

func (is *InviteStorage) GetAll(withArchived bool, skip, limit int) ([]model.Invite, int, error)

GetAll returns all active invites by default. To get an archived invites need to set withArchived argument to true.

func (*InviteStorage) GetByEmail added in v1.2.4

func (is *InviteStorage) GetByEmail(email string) (model.Invite, error)

GetByEmail returns not archived and not expired invite by email.

func (*InviteStorage) GetByID added in v1.2.4

func (is *InviteStorage) GetByID(id string) (model.Invite, error)

GetByID returns invite by its ID.

func (*InviteStorage) Save added in v1.2.4

func (is *InviteStorage) Save(email, inviteToken, role, appID, createdBy string, expiresAt time.Time) error

Save creates and saves new invite to a database.

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) Close

func (tb *TokenBlacklist) Close()

Close does nothing here.

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) Close

func (ts *TokenStorage) Close()

Close does nothing here.

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

func (us *UserStorage) AddNewUser(usr model.User, password string) (model.User, error)

AddNewUser adds new user.

func (*UserStorage) AddUserByNameAndPassword

func (us *UserStorage) AddUserByNameAndPassword(username, password, role string, isAnonymous bool) (model.User, error)

AddUserByNameAndPassword registers new user.

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 do nothing here TODO: implement device storage

func (*UserStorage) Close

func (us *UserStorage) Close()

Close 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 do nothing here yet TODO: implement

func (*UserStorage) FetchUsers

func (us *UserStorage) FetchUsers(filterString string, skip, limit int) ([]model.User, int, error)

FetchUsers fetches users which name satisfies provided filterString. Supports pagination. Search is case-sensitive for now.

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 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

func (us *UserStorage) UpdateUser(userID string, user model.User) (model.User, error)

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

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 its 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 the 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 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL