ubase

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PermissionService

type PermissionService interface {
	UserHasPermission(ctx context.Context, userId int64, permission string) (bool, error)
	GetPermissionId(name string) (int64, error)
	GetPermissions(ctx context.Context) (map[string]int64, error)
	GetPermissionsForRole(ctx context.Context, roleId int64) (map[string]bool, error)
	HasPermission(ctx context.Context, userID int64, permission string) (bool, error)
	Warmup(ctx context.Context, allPermissions []string) error
}

func NewPermissionService

func NewPermissionService(dbadapter ubdata.DataAdapter, roleService RoleService) PermissionService

type PermissionServiceImpl

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

func (*PermissionServiceImpl) AsPermissionService

func (p *PermissionServiceImpl) AsPermissionService() PermissionService

func (*PermissionServiceImpl) GetPermissionId

func (p *PermissionServiceImpl) GetPermissionId(name string) (int64, error)

func (*PermissionServiceImpl) GetPermissions

func (p *PermissionServiceImpl) GetPermissions(ctx context.Context) (map[string]int64, error)

func (*PermissionServiceImpl) GetPermissionsForRole

func (p *PermissionServiceImpl) GetPermissionsForRole(ctx context.Context, roleId int64) (map[string]bool, error)

func (*PermissionServiceImpl) HasPermission

func (p *PermissionServiceImpl) HasPermission(ctx context.Context, userID int64, permission string) (bool, error)

func (*PermissionServiceImpl) UserHasPermission

func (p *PermissionServiceImpl) UserHasPermission(ctx context.Context, userId int64, permission string) (bool, error)

func (*PermissionServiceImpl) Warmup

func (p *PermissionServiceImpl) Warmup(ctx context.Context, allPermissions []string) error

type Response

type Response struct {
	Status           string                         `json:"status"`
	Message          string                         `json:"message"`
	ValidationIssues *ubvalidation.ValidationIssues `json:"validationIssues,omitempty"`
}

type RoleAggregate

type RoleAggregate struct {
	Id       int64
	Sequence int64
	State    *RoleState
}

evercore:aggregate

func NewRoleAggregate

func NewRoleAggregate() RoleAggregate

func (*RoleAggregate) ApplyEventState

func (a *RoleAggregate) ApplyEventState(eventState evercore.EventState, eventTime time.Time, reference string) error

func (*RoleAggregate) ApplySnapshot

func (a *RoleAggregate) ApplySnapshot(snapshot *evercore.Snapshot) error

func (*RoleAggregate) AsAggregate

func (a *RoleAggregate) AsAggregate() evercore.Aggregate

func (*RoleAggregate) GetAggregateType

func (a *RoleAggregate) GetAggregateType() string

func (*RoleAggregate) GetId

func (a *RoleAggregate) GetId() int64

func (*RoleAggregate) GetSequence

func (a *RoleAggregate) GetSequence() int64

func (*RoleAggregate) GetSnapshotFrequency

func (a *RoleAggregate) GetSnapshotFrequency() int64

func (*RoleAggregate) GetSnapshotState

func (a *RoleAggregate) GetSnapshotState() (*string, error)

func (*RoleAggregate) SetId

func (a *RoleAggregate) SetId(id int64)

func (*RoleAggregate) SetSequence

func (a *RoleAggregate) SetSequence(seq int64)

type RolePermissions

type RolePermissions struct {
	RoleId      int64
	Permissions []int64
}

type RoleService

type RoleService interface {
	AddRole(ctx context.Context, name string, agent string) (int64, error)
	AddPermissionToRole(ctx context.Context, role string, permissionId int64, agent string) error
	RemovePermissionFromRole(ctx context.Context, role string, permissionId int64, agent string) error

	GetRoleList(ctx context.Context) (map[string]int64, error)
}

func CreateRoleService

func CreateRoleService(
	store *evercore.EventStore,
	dbadapter ubdata.DataAdapter) RoleService

type RoleServiceImpl

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

func (RoleServiceImpl) AddPermissionToRole

func (s RoleServiceImpl) AddPermissionToRole(ctx context.Context, role string, permissionId int64, agent string) error

func (RoleServiceImpl) AddRole

func (s RoleServiceImpl) AddRole(ctx context.Context, name string, agent string) (int64, error)

func (RoleServiceImpl) GetRoleList

func (s RoleServiceImpl) GetRoleList(ctx context.Context) (map[string]int64, error)

func (RoleServiceImpl) RemovePermissionFromRole

func (s RoleServiceImpl) RemovePermissionFromRole(ctx context.Context, role string, permissionId int64, agent string) error

type RoleState

type RoleState struct {
	Name        string
	Premissions []int64
}

type UserAggregate

type UserAggregate struct {
	evercore.StateAggregate[ubstate.UserState]
}

evercore:aggregate

type UserCreateCommand

type UserCreateCommand struct {
	Email       string `json:"email"`
	Password    string `json:"password"`
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	DisplayName string `json:"displayName"`
}

func (UserCreateCommand) Validate

type UserCreateResponse

type UserCreateResponse struct {
	Response `json:"response"`
	Id       int64 `json:"id"`
}

type UserLoginCommand

type UserLoginCommand struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UserLoginResponse

type UserLoginResponse struct {
	Response
	UserId      int64   `json:"userId"`
	LastName    *string `json:"lastName,omitempty"`
	FirstName   *string `json:"firstName,omitempty"`
	DisplayName *string `json:"displayName,omitempty"`
	Email       *string `json:"email,omitempty"`
}

type UserRoles

type UserRoles struct {
	UserId int64
	Roles  []int64
}

type UserService

type UserService interface {
	CreateUser(ctx context.Context, command UserCreateCommand, agent string) (UserCreateResponse, error)
	UpdateUser(ctx context.Context, command UserUpdateCommand, agent string) (UserUpdatedResponse, error)
	GetUserByEmail(ctx context.Context, email string) (*UserAggregate, error)
	Login(ctx context.Context, command UserLoginCommand) (*UserLoginResponse, error)
	SetRoles(ctx context.Context, command UserSetRolesComand, agent string) (UserSetRolesResponse, error)
	GetUserRolesIds(ctx context.Context, userId int64) ([]int64, error)
}

func CreateUserService

func CreateUserService(store *evercore.EventStore, hashingService ubsecurity.HashGenerator, dbadapter ubdata.DataAdapter) UserService

type UserServiceImpl

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

func (UserServiceImpl) CreateUser

func (s UserServiceImpl) CreateUser(ctx context.Context, command UserCreateCommand, agent string) (UserCreateResponse, error)

func (UserServiceImpl) GetUserByEmail

func (s UserServiceImpl) GetUserByEmail(ctx context.Context, email string) (*UserAggregate, error)

func (UserServiceImpl) GetUserRolesIds

func (s UserServiceImpl) GetUserRolesIds(ctx context.Context, userId int64) ([]int64, error)

func (UserServiceImpl) Login

func (UserServiceImpl) ProjectRoles

func (s UserServiceImpl) ProjectRoles(ctx context.Context, userAggregate *UserAggregate) error

func (UserServiceImpl) ProjectUser

func (s UserServiceImpl) ProjectUser(ctx context.Context, userAggregate *UserAggregate) error

ProjectUser projects the user to the relational database.

func (UserServiceImpl) SetRoles

func (UserServiceImpl) UpdateUser

func (s UserServiceImpl) UpdateUser(ctx context.Context, command UserUpdateCommand, agent string) (UserUpdatedResponse, error)

type UserSetRolesComand

type UserSetRolesComand struct {
	Id      int64   `json:"id"`
	RoleIds []int64 `json:"roleIds"`
}

type UserSetRolesResponse

type UserSetRolesResponse struct {
	Response `json:"response"`
}

type UserUpdateCommand

type UserUpdateCommand struct {
	Id          int64   `json:"id"`
	Password    *string `json:"password,omitempty"`
	FirstName   *string `json:"firstName,omitempty"`
	LastName    *string `json:"lastName,omitempty"`
	DisplayName *string `json:"displayName,omitempty"`
}

func (UserUpdateCommand) Validate

type UserUpdatedResponse

type UserUpdatedResponse struct {
	Response
}

Directories

Path Synopsis
The algorithms package contains useful data structures for re-use
The algorithms package contains useful data structures for re-use
Security related tools.
Security related tools.

Jump to

Keyboard shortcuts

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