principal

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToInfo

func MapToInfo(p *Info) types.PrincipalInfo

Types

type Info

type Info struct {
	ID          int64              `gorm:"column:principal_id;primaryKey"`
	UID         string             `gorm:"column:principal_uid"`
	DisplayName string             `gorm:"column:principal_display_name"`
	Email       string             `gorm:"column:principal_email"`
	Type        enum.PrincipalType `gorm:"column:principal_type"`
	Created     int64              `gorm:"column:principal_created"`
	Updated     int64              `gorm:"column:principal_updated"`
}

type InfoView

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

func NewPrincipalOrmInfoView

func NewPrincipalOrmInfoView(db *gorm.DB) *InfoView

NewPrincipalOrmInfoView returns a new InfoView. It's used by the principal info cache.

func (*InfoView) Find

func (s *InfoView) Find(ctx context.Context, id int64) (*types.PrincipalInfo, error)

Find returns a single principal info object by id from the `principals` database table.

func (*InfoView) FindMany

func (s *InfoView) FindMany(ctx context.Context, ids []int64) ([]*types.PrincipalInfo, error)

FindMany returns a several principal info objects by id from the `principals` database table.

type PrincipalOrmStore

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

PrincipalOrmStore implements a PrincipalStore backed by a relational database.

func NewPrincipalOrmStore

func NewPrincipalOrmStore(db *gorm.DB, uidTransformation store.PrincipalUIDTransformation) *PrincipalOrmStore

NewPrincipalOrmStore returns a new PrincipalStoreOrm.

func (*PrincipalOrmStore) CountServiceAccounts

func (s *PrincipalOrmStore) CountServiceAccounts(ctx context.Context,
	parentType enum.ParentResourceType, parentID int64) (int64, error)

CountServiceAccounts returns a count of service accounts for a specific parent.

func (*PrincipalOrmStore) CountServices

func (s *PrincipalOrmStore) CountServices(ctx context.Context) (int64, error)

CountServices returns a count of service for a specific parent.

func (*PrincipalOrmStore) CountUsers

func (s *PrincipalOrmStore) CountUsers(ctx context.Context, opts *types.UserFilter) (int64, error)

CountUsers returns a count of users matching the given filter.

func (*PrincipalOrmStore) CreateService

func (s *PrincipalOrmStore) CreateService(ctx context.Context, svc *types.Service) error

CreateService saves the service.

func (*PrincipalOrmStore) CreateServiceAccount

func (s *PrincipalOrmStore) CreateServiceAccount(ctx context.Context, sa *types.ServiceAccount) error

CreateServiceAccount saves the service account.

func (*PrincipalOrmStore) CreateUser

func (s *PrincipalOrmStore) CreateUser(ctx context.Context, user *types.User) error

CreateUser saves the user details.

func (*PrincipalOrmStore) DeleteService

func (s *PrincipalOrmStore) DeleteService(ctx context.Context, id int64) error

DeleteService deletes the service.

func (*PrincipalOrmStore) DeleteServiceAccount

func (s *PrincipalOrmStore) DeleteServiceAccount(ctx context.Context, id int64) error

DeleteServiceAccount deletes the service account.

func (*PrincipalOrmStore) DeleteUser

func (s *PrincipalOrmStore) DeleteUser(ctx context.Context, id int64) error

DeleteUser deletes the user.

func (*PrincipalOrmStore) Find

Find finds the principal by id.

func (*PrincipalOrmStore) FindByEmail

func (s *PrincipalOrmStore) FindByEmail(ctx context.Context, email string) (*types.Principal, error)

FindByEmail finds the principal by email.

func (*PrincipalOrmStore) FindByUID

func (s *PrincipalOrmStore) FindByUID(ctx context.Context, uid string) (*types.Principal, error)

FindByUID finds the principal by uid.

func (*PrincipalOrmStore) FindManyByUID

func (s *PrincipalOrmStore) FindManyByUID(ctx context.Context, uids []string) ([]*types.Principal, error)

FindManyByUID returns all principals found for the provided UIDs. If a UID isn't found, it's not returned in the list.

func (*PrincipalOrmStore) FindService

func (s *PrincipalOrmStore) FindService(ctx context.Context, id int64) (*types.Service, error)

FindService finds the service by id.

func (*PrincipalOrmStore) FindServiceAccount

func (s *PrincipalOrmStore) FindServiceAccount(ctx context.Context, id int64) (*types.ServiceAccount, error)

FindServiceAccount finds the service account by id.

func (*PrincipalOrmStore) FindServiceAccountByUID

func (s *PrincipalOrmStore) FindServiceAccountByUID(ctx context.Context, uid string) (*types.ServiceAccount, error)

FindServiceAccountByUID finds the service account by uid.

func (*PrincipalOrmStore) FindServiceByUID

func (s *PrincipalOrmStore) FindServiceByUID(ctx context.Context, uid string) (*types.Service, error)

FindServiceByUID finds the service by uid.

func (*PrincipalOrmStore) FindUser

func (s *PrincipalOrmStore) FindUser(ctx context.Context, id int64) (*types.User, error)

FindUser finds the user by id.

func (*PrincipalOrmStore) FindUserByEmail

func (s *PrincipalOrmStore) FindUserByEmail(ctx context.Context, email string) (*types.User, error)

FindUserByEmail finds the user by email.

func (*PrincipalOrmStore) FindUserByUID

func (s *PrincipalOrmStore) FindUserByUID(ctx context.Context, uid string) (*types.User, error)

FindUserByUID finds the user by uid.

func (*PrincipalOrmStore) List

List lists the principals matching the provided filter.

func (*PrincipalOrmStore) ListServiceAccounts

func (s *PrincipalOrmStore) ListServiceAccounts(ctx context.Context, parentType enum.ParentResourceType,
	parentID int64) ([]*types.ServiceAccount, error)

ListServiceAccounts returns a list of service accounts for a specific parent.

func (*PrincipalOrmStore) ListServices

func (s *PrincipalOrmStore) ListServices(ctx context.Context) ([]*types.Service, error)

ListServices returns a list of service for a specific parent.

func (*PrincipalOrmStore) ListUsers

func (s *PrincipalOrmStore) ListUsers(ctx context.Context, opts *types.UserFilter) ([]*types.User, error)

ListUsers returns a list of users.

func (*PrincipalOrmStore) UpdateService

func (s *PrincipalOrmStore) UpdateService(ctx context.Context, svc *types.Service) error

UpdateService updates the service.

func (*PrincipalOrmStore) UpdateServiceAccount

func (s *PrincipalOrmStore) UpdateServiceAccount(ctx context.Context, sa *types.ServiceAccount) error

UpdateServiceAccount updates the service account details.

func (*PrincipalOrmStore) UpdateUser

func (s *PrincipalOrmStore) UpdateUser(ctx context.Context, usr *types.User) error

UpdateUser updates an existing user.

type TokenStore

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

TokenStore implements a TokenStore backed by a relational database.

func NewTokenOrmStore

func NewTokenOrmStore(db *gorm.DB) *TokenStore

NewTokenOrmStore returns a new TokenStore.

func (*TokenStore) Count

func (s *TokenStore) Count(ctx context.Context, principalID int64, tokenType enum.TokenType) (int64, error)

Count returns a count of tokens of a specifc type for a specific principal.

func (*TokenStore) Create

func (s *TokenStore) Create(ctx context.Context, token *types.Token) error

Create saves the token details.

func (*TokenStore) Delete

func (s *TokenStore) Delete(ctx context.Context, id int64) error

Delete deletes the token with the given id.

func (*TokenStore) DeleteExpiredBefore

func (s *TokenStore) DeleteExpiredBefore(
	ctx context.Context,
	before time.Time,
	tknTypes []enum.TokenType,
) (int64, error)

DeleteExpiredBefore deletes all tokens that expired before the provided time. If tokenTypes are provided, then only tokens of that type are deleted.

func (*TokenStore) Find

func (s *TokenStore) Find(ctx context.Context, id int64) (*types.Token, error)

Find finds the token by id.

func (*TokenStore) FindByIdentifier

func (s *TokenStore) FindByIdentifier(ctx context.Context, principalID int64, identifier string) (*types.Token, error)

FindByIdentifier finds the token by principalId and token identifier.

func (*TokenStore) List

func (s *TokenStore) List(ctx context.Context,
	principalID int64, tokenType enum.TokenType) ([]*types.Token, error)

List returns a list of tokens of a specific type for a specific principal.

Jump to

Keyboard shortcuts

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