mem

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

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

func NewAppData(data model.AppData) AppData

NewAppData instantiates app data in-memory model from the general one.

func (*AppData) Active

func (ad *AppData) Active() bool

Active implements model.AppData interface.

func (*AppData) AppleInfo

func (ad *AppData) AppleInfo() *model.AppleInfo

AppleInfo implements model.AppData interface.

func (*AppData) AuthzModel

func (ad *AppData) AuthzModel() string

AuthzModel implements model.AppData interface.

func (*AppData) AuthzPolicy

func (ad *AppData) AuthzPolicy() string

AuthzPolicy implements model.AppData interface.

func (*AppData) AuthzWay

func (ad *AppData) AuthzWay() model.AuthorizationWay

AuthzWay implements model.AppData interface.

func (*AppData) DebugTFACode

func (ad *AppData) DebugTFACode() string

DebugTFACode implements model.AppData interface.

func (*AppData) Description

func (ad *AppData) Description() string

Description implements model.AppData interface.

func (*AppData) ID

func (ad *AppData) ID() string

ID implements model.AppData interface.

func (*AppData) InviteTokenLifespan

func (ad *AppData) InviteTokenLifespan() int64

InviteTokenLifespan a inviteToken lifespan in seconds, if 0 - default one is used.

func (*AppData) Name

func (ad *AppData) Name() string

Name implements model.AppData interface.

func (*AppData) NewUserDefaultRole

func (ad *AppData) NewUserDefaultRole() string

NewUserDefaultRole implements model.AppData interface.

func (*AppData) Offline

func (ad *AppData) Offline() bool

Offline implements model.AppData interface.

func (*AppData) RedirectURLs

func (ad *AppData) RedirectURLs() []string

RedirectURLs implements model.AppData interface.

func (*AppData) RefreshTokenLifespan

func (ad *AppData) RefreshTokenLifespan() int64

RefreshTokenLifespan implements model.AppData interface.

func (*AppData) RegistrationForbidden

func (ad *AppData) RegistrationForbidden() bool

RegistrationForbidden implements model.AppData interface.

func (*AppData) RolesBlacklist

func (ad *AppData) RolesBlacklist() []string

RolesBlacklist implements model.AppData interface.

func (*AppData) RolesWhitelist

func (ad *AppData) RolesWhitelist() []string

RolesWhitelist implements model.AppData interface.

func (*AppData) Sanitize

func (ad *AppData) Sanitize()

Sanitize removes all sensitive data.

func (*AppData) Scopes

func (ad *AppData) Scopes() []string

Scopes implements model.AppData interface.

func (*AppData) Secret

func (ad *AppData) Secret() string

Secret implements model.AppData interface.

func (*AppData) SetSecret

func (ad *AppData) SetSecret(secret string)

SetSecret implements model.AppData interface.

func (*AppData) TFAStatus

func (ad *AppData) TFAStatus() model.TFAStatus

TFAStatus implements model.AppData interface.

func (*AppData) TokenLifespan

func (ad *AppData) TokenLifespan() int64

TokenLifespan implements model.AppData interface.

func (*AppData) TokenPayload

func (ad *AppData) TokenPayload() []string

TokenPayload implements model.AppData interface.

func (*AppData) Type

func (ad *AppData) Type() model.AppType

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

func (as *AppStorage) Close()

Close clears storage.

func (*AppStorage) CreateApp

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

CreateApp creates new app in memory.

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

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.

func (*AppStorage) UpdateApp

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

UpdateApp updates app in the storage.

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

func (tb *TokenBlacklist) Close()

Close clears storage.

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

func (ts *TokenStorage) Close()

Close clears storage.

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

func (us *UserStorage) Close()

Close 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

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

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

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

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.

Jump to

Keyboard shortcuts

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