store

package
v0.0.0-...-8495d1f Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseConnection

func CloseConnection(tb testing.TB, store *SqlStore)

Types

type OAuthStateStore

type OAuthStateStore interface {
	CreateOAuthState() (*model.OAuthState, error)
	GetOAuthState(idOrToken string) (*model.OAuthState, error)
	DeleteOAuthState(id string) error
}

type PrefixedMigration

type PrefixedMigration struct {
	*bindata.Bindata
	// contains filtered or unexported fields
}

func (*PrefixedMigration) ReadDown

func (pm *PrefixedMigration) ReadDown(version uint) (io.ReadCloser, string, error)

func (*PrefixedMigration) ReadUp

func (pm *PrefixedMigration) ReadUp(version uint) (io.ReadCloser, string, error)

type RoleStore

type RoleStore interface {
	CreateRole(role *model.Role) (*model.Role, error)
	GetRoleByName(name string) (*model.Role, error)
	UserHasRole(userID, roleID string) (bool, error)
	UserHasRoleByName(userID, roleName string) (bool, error)
	AddUserRole(userID, roleID string) error
	DeleteUserRole(userID, roleID string) error
}

type SessionStore

type SessionStore interface {
	CreateSession(session *model.Session) (*model.Session, error)
	GetSession(idOrToken string) (*model.Session, error)
	DeleteSession(id string) error
	DeleteSessionsForUser(userID string) error
}

type SqlOAuthStateStore

type SqlOAuthStateStore struct {
	*SqlStore
}

func (*SqlOAuthStateStore) CreateOAuthState

func (s *SqlOAuthStateStore) CreateOAuthState() (*model.OAuthState, error)

CreateOAuthState inserts a new OAuth state.

func (*SqlOAuthStateStore) DeleteOAuthState

func (s *SqlOAuthStateStore) DeleteOAuthState(id string) error

DeleteOAuthState deletes a oauth state by ID.

func (*SqlOAuthStateStore) GetOAuthState

func (s *SqlOAuthStateStore) GetOAuthState(idOrToken string) (*model.OAuthState, error)

GetOAuthState fetches the given OAuth state by id or token. Does not return expired state.

type SqlRoleStore

type SqlRoleStore struct {
	*SqlStore
}

func (*SqlRoleStore) AddUserRole

func (s *SqlRoleStore) AddUserRole(userID, roleID string) error

func (*SqlRoleStore) CreateRole

func (s *SqlRoleStore) CreateRole(role *model.Role) (*model.Role, error)

CreateRole inserts a new role.

func (*SqlRoleStore) DeleteUserRole

func (s *SqlRoleStore) DeleteUserRole(userID, roleID string) error

func (*SqlRoleStore) GetRoleByName

func (s *SqlRoleStore) GetRoleByName(name string) (*model.Role, error)

GetRoleByName returns the role entity for the provided name.

func (*SqlRoleStore) UserHasRole

func (s *SqlRoleStore) UserHasRole(userID, roleID string) (bool, error)

func (*SqlRoleStore) UserHasRoleByName

func (s *SqlRoleStore) UserHasRoleByName(userID, roleName string) (bool, error)

type SqlSessionStore

type SqlSessionStore struct {
	*SqlStore
}

func (*SqlSessionStore) CreateSession

func (s *SqlSessionStore) CreateSession(session *model.Session) (*model.Session, error)

CreateSession inserts a new session.

func (*SqlSessionStore) DeleteSession

func (s *SqlSessionStore) DeleteSession(id string) error

DeleteSession deletes a session by ID.

func (*SqlSessionStore) DeleteSessionsForUser

func (s *SqlSessionStore) DeleteSessionsForUser(userID string) error

DeleteSessionsForUser deletes all the sessions for a user

func (*SqlSessionStore) GetSession

func (s *SqlSessionStore) GetSession(idOrToken string) (*model.Session, error)

GetSession fetches the given session by id or token. Does not return expired sessions.

type SqlStore

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

func MakeTestStore

func MakeTestStore(tb testing.TB, logger log.FieldLogger) *SqlStore

func New

func New(dsn string, tablePrefix string, logger logrus.FieldLogger) (*SqlStore, error)

New constructs a new instance of SqlStore.

func (*SqlStore) Initialize

func (s *SqlStore) Initialize() error

Initialize imports initial values

func (*SqlStore) Migrate

func (s *SqlStore) Migrate() error

func (*SqlStore) OAuthState

func (s *SqlStore) OAuthState() OAuthStateStore

func (*SqlStore) Role

func (s *SqlStore) Role() RoleStore

func (*SqlStore) Session

func (s *SqlStore) Session() SessionStore

func (*SqlStore) Token

func (s *SqlStore) Token() TokenStore

func (*SqlStore) User

func (s *SqlStore) User() UserStore

func (*SqlStore) UserAuthInfo

func (s *SqlStore) UserAuthInfo() UserAuthInfoStore

type SqlStoreStores

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

type SqlTokenStore

type SqlTokenStore struct {
	*SqlStore
}

func (*SqlTokenStore) CleanupTokenStore

func (s *SqlTokenStore) CleanupTokenStore(expiryTimeMillis int64)

CleanupTokenStore removes tokens that are past the defined expiry time.

func (*SqlTokenStore) CreateToken

func (s *SqlTokenStore) CreateToken(token *model.Token) (*model.Token, error)

CreateToken inserts a new token.

func (*SqlTokenStore) DeleteToken

func (s *SqlTokenStore) DeleteToken(tokenValue string) error

DeleteToken deletes a token.

func (*SqlTokenStore) DeleteTokensByEmail

func (s *SqlTokenStore) DeleteTokensByEmail(email, tokenType string) error

DeleteTokensByEmail deletes all the tokes, of one type, belonging to the passed email

func (*SqlTokenStore) GetToken

func (s *SqlTokenStore) GetToken(tokenValue string) (*model.Token, error)

GetToken fetches the given token by token value.

func (*SqlTokenStore) GetTokensByEmail

func (s *SqlTokenStore) GetTokensByEmail(email, tokenType string) ([]*model.Token, error)

GetTokensByEmail fetches the tokens for the passed email

type SqlUserAuthInfoStore

type SqlUserAuthInfoStore struct {
	*SqlStore
}

func (*SqlUserAuthInfoStore) CreateUserAuthInfo

func (s *SqlUserAuthInfoStore) CreateUserAuthInfo(userAuthInfo *model.UserAuthInfo) (*model.UserAuthInfo, error)

CreateUserAuthInfo inserts a new user.

func (*SqlUserAuthInfoStore) GetUserAuthInfo

func (s *SqlUserAuthInfoStore) GetUserAuthInfo(userID, oauthProvider string) (*model.UserAuthInfo, error)

GetUser fetches the given user by id.

func (*SqlUserAuthInfoStore) UpdateUserAuthInfoToken

func (s *SqlUserAuthInfoStore) UpdateUserAuthInfoToken(userAuthInfo *model.UserAuthInfo) error

UpdateUserAuthInfoToken updates the given user.

type SqlUserStore

type SqlUserStore struct {
	*SqlStore
}

func (*SqlUserStore) CreateUser

func (s *SqlUserStore) CreateUser(user *model.User) (*model.User, error)

CreateUser inserts a new user.

func (*SqlUserStore) GetUser

func (s *SqlUserStore) GetUser(id string) (*model.User, error)

GetUser fetches the given user by id.

func (*SqlUserStore) GetUserByEmail

func (s *SqlUserStore) GetUserByEmail(email string) (*model.User, error)

GetUserByEmail fetches the given user by email.

func (*SqlUserStore) UnverifyEmail

func (s *SqlUserStore) UnverifyEmail(id, email string) error

UnverifyEmail updates a user's email and marks it as unverified.

func (*SqlUserStore) UpdatePassword

func (s *SqlUserStore) UpdatePassword(id, password string) error

UpdatePassword accepts a plaintext password value, hashes it, and saves it as the new password for a given user.

func (*SqlUserStore) UpdateUser

func (s *SqlUserStore) UpdateUser(user *model.User) error

UpdateUser updates the given user.

func (*SqlUserStore) UpdateUserState

func (s *SqlUserStore) UpdateUserState(userID string, state string) error

func (*SqlUserStore) VerifyEmail

func (s *SqlUserStore) VerifyEmail(id, email string) error

VerifyEmail updates a user's email and marks it as verified.

type Store

type Store interface {
	OAuthState() OAuthStateStore
	Role() RoleStore
	Session() SessionStore
	Token() TokenStore
	User() UserStore
	UserAuthInfo() UserAuthInfoStore
}

type StoreTestHelper

type StoreTestHelper struct {
	SqlStore *SqlStore
}

func SetupStoreTestHelper

func SetupStoreTestHelper(t *testing.T) *StoreTestHelper

func (*StoreTestHelper) TearDown

func (th *StoreTestHelper) TearDown(t *testing.T)

type TokenStore

type TokenStore interface {
	CreateToken(token *model.Token) (*model.Token, error)
	GetToken(tokenValue string) (*model.Token, error)
	GetTokensByEmail(email, tokenType string) ([]*model.Token, error)
	DeleteToken(tokenValue string) error
	DeleteTokensByEmail(email, tokenType string) error
	CleanupTokenStore(expiryTimeMillis int64)
}

type UserAuthInfoStore

type UserAuthInfoStore interface {
	CreateUserAuthInfo(user *model.UserAuthInfo) (*model.UserAuthInfo, error)
	GetUserAuthInfo(userID, oauthProvider string) (*model.UserAuthInfo, error)
	UpdateUserAuthInfoToken(user *model.UserAuthInfo) error
}

type UserStore

type UserStore interface {
	CreateUser(user *model.User) (*model.User, error)
	GetUser(id string) (*model.User, error)
	GetUserByEmail(email string) (*model.User, error)
	VerifyEmail(id, email string) error
	UnverifyEmail(id, email string) error
	UpdatePassword(id, password string) error
	UpdateUser(user *model.User) error
	UpdateUserState(userID string, state string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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