store

package
v0.0.0-...-ee9a93c Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongCredentials is returned when credentials are wrong.
	ErrWrongCredentials = errors.New("wrong credentials provided")

	// ErrAlreadyAssigned defines the error if relation is already assigned.
	ErrAlreadyAssigned = errors.New("user pack already exists")

	// ErrNotAssigned defines the error if relation is not assigned.
	ErrNotAssigned = errors.New("user pack is not defined")

	// ErrGroupNotFound is returned when a user was not found.
	ErrGroupNotFound = errors.New("group not found")

	// ErrUserNotFound is returned when a user was not found.
	ErrUserNotFound = errors.New("user not found")

	// ErrTokenNotFound is returned when a token was not found.
	ErrTokenNotFound = errors.New("token not found")
)
View Source
var (
	// ErrUnknownDriver defines a named error for unknown store drivers.
	ErrUnknownDriver = fmt.Errorf("unknown database driver")
)

Functions

This section is empty.

Types

type Auth

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

Auth provides all database operations related to auth.

func (*Auth) ByCreds

func (s *Auth) ByCreds(ctx context.Context, username, password string) (*model.User, error)

ByCreds tries to authenticate a user based on credentials.

func (*Auth) ByID

func (s *Auth) ByID(ctx context.Context, userID string) (*model.User, error)

ByID tries to authenticate a user based on identifier.

func (*Auth) External

func (s *Auth) External(ctx context.Context, provider, ref, username, email, fullname string, admin bool) (*model.User, error)

External creates and authenticates external users.

type Groups

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

Groups provides all database operations related to groups.

func (*Groups) AttachUser

func (s *Groups) AttachUser(ctx context.Context, params model.UserGroupParams) error

AttachUser implements the attachment of a group to an user.

func (*Groups) Create

func (s *Groups) Create(ctx context.Context, record *model.Group) error

Create implements the create of a new group.

func (*Groups) Delete

func (s *Groups) Delete(ctx context.Context, name string) error

Delete implements the deletion of a group.

func (*Groups) DropUser

func (s *Groups) DropUser(ctx context.Context, params model.UserGroupParams) error

DropUser implements the removal of a group from an user.

func (*Groups) List

func (s *Groups) List(ctx context.Context, params model.ListParams) ([]*model.Group, int64, error)

List implements the listing of all users.

func (*Groups) ListUsers

func (s *Groups) ListUsers(ctx context.Context, params model.UserGroupParams) ([]*model.UserGroup, int64, error)

ListUsers implements the listing of all users for a group.

func (*Groups) PermitUser

func (s *Groups) PermitUser(ctx context.Context, params model.UserGroupParams) error

PermitUser implements the permission update for a user on a group.

func (*Groups) Show

func (s *Groups) Show(ctx context.Context, name string) (*model.Group, error)

Show implements the details for a specific user.

func (*Groups) Update

func (s *Groups) Update(ctx context.Context, record *model.Group) error

Update implements the update of an existing group.

func (*Groups) ValidSort

func (s *Groups) ValidSort(val string) (string, bool)

ValidSort validates the given sorting column.

type Store

type Store struct {
	Auth   *Auth
	Groups *Groups
	Users  *Users
	// contains filtered or unexported fields
}

Store provides the general database abstraction layer.

func MustStore

func MustStore(cfg config.Database, scim config.Scim, uploads upload.Upload) *Store

MustStore simply calls NewStore and panics on an error.

func NewStore

func NewStore(cfg config.Database, scim config.Scim, uploads upload.Upload) (*Store, error)

NewStore initializes a new Bun

func (*Store) Admin

func (s *Store) Admin(username, password, email string) error

Admin creates an initial admin user within the database.

func (*Store) Close

func (s *Store) Close() (bool, error)

Close simply closes the database connection.

func (*Store) Handle

func (s *Store) Handle() *bun.DB

Handle returns a database handle.

func (*Store) Info

func (s *Store) Info() map[string]interface{}

Info returns some basic db informations.

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) (*migrate.MigrationGroup, error)

Migrate handles a database migration.

func (*Store) Migrator

func (s *Store) Migrator(ctx context.Context) (*migrate.Migrator, error)

Migrator provides the migration client.

func (*Store) Open

func (s *Store) Open() (bool, error)

Open simply opens the database connection.

func (*Store) Ping

func (s *Store) Ping() (bool, error)

Ping just tests the database connection.

func (*Store) Prepare

func (s *Store) Prepare() error

Prepare is preparing some database behavior.

func (*Store) Rollback

func (s *Store) Rollback(ctx context.Context) (*migrate.MigrationGroup, error)

Rollback handles a database rollback.

func (*Store) SearchQuery

func (s *Store) SearchQuery(q *bun.SelectQuery, _ string) *bun.SelectQuery

SearchQuery builds a query for search terms.

func (*Store) WithPrincipal

func (s *Store) WithPrincipal(principal *model.User) *Store

WithPrincipal integrates the current user.

type Users

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

Users provides all database operations related to users.

func (*Users) AttachGroup

func (s *Users) AttachGroup(ctx context.Context, params model.UserGroupParams) error

AttachGroup implements the attachment of an user to a group.

func (*Users) CleanupRedirectTokens

func (s *Users) CleanupRedirectTokens(ctx context.Context) error

CleanupRedirectTokens implements the cleanup of expired redirect tokens.

func (*Users) Create

func (s *Users) Create(ctx context.Context, record *model.User) error

Create implements the create of a new user.

func (*Users) CreateRedirectToken

func (s *Users) CreateRedirectToken(ctx context.Context, username string) (*model.UserToken, error)

CreateRedirectToken implements the create of a new redirect token.

func (*Users) Delete

func (s *Users) Delete(ctx context.Context, name string) error

Delete implements the deletion of an user.

func (*Users) DeleteRedirectToken

func (s *Users) DeleteRedirectToken(ctx context.Context, token string) error

DeleteRedirectToken implements the deletion of a redirect token.

func (*Users) DropGroup

func (s *Users) DropGroup(ctx context.Context, params model.UserGroupParams) error

DropGroup implements the removal of an user from a group.

func (*Users) List

func (s *Users) List(ctx context.Context, params model.ListParams) ([]*model.User, int64, error)

List implements the listing of all users.

func (*Users) ListGroups

func (s *Users) ListGroups(ctx context.Context, params model.UserGroupParams) ([]*model.UserGroup, int64, error)

ListGroups implements the listing of all groups for an user.

func (*Users) PermitGroup

func (s *Users) PermitGroup(ctx context.Context, params model.UserGroupParams) error

PermitGroup implements the permission update for a group on an user.

func (*Users) Show

func (s *Users) Show(ctx context.Context, name string) (*model.User, error)

Show implements the details for a specific user.

func (*Users) ShowRedirectToken

func (s *Users) ShowRedirectToken(ctx context.Context, token string) (*model.UserToken, error)

ShowRedirectToken implements the details for a specific redirect token.

func (*Users) Update

func (s *Users) Update(ctx context.Context, record *model.User) error

Update implements the update of an existing user.

func (*Users) ValidSort

func (s *Users) ValidSort(val string) (string, bool)

ValidSort validates the given sorting column.

Jump to

Keyboard shortcuts

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