service

package
v0.0.2-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCreateService            = errors.New("service: failed to create service")
	ErrPermissionDenied         = errors.New("service: permission denied")
	ErrDeleteAdminAccount       = errors.New("service: admin account can't be deleted")
	ErrChangeAdminRole          = errors.New("service: admin role can't be changed")
	ErrResetPasswordUnsupported = errors.New("service: reset password feature unsupported by auth store")
)
View Source
var (
	ErrUnsupportedAuthType = errors.New("unsupported auth type")
	ErrUserNotFound        = errors.New("user not found")
)
View Source
var (
	ErrOrganizationNotFound = errors.New("organization not found")
)
View Source
var (
	ErrRoleNotFound = errors.New("role not found")
)

Functions

This section is empty.

Types

type AuthServicer

type AuthServicer interface {
	Activate(registrationID uint64) (*entities.User, error)
	Login(userCredentials *UserCredential) (*entities.User, []*entities.Organization, []*entities.Service, error)
	Register(userCredentials *UserCredential, baseURI string) (*entities.User, error)
	ResetPassword(userCredentials *UserCredential) error
}

type Organization

type Organization struct {
	OrganizationService
	// contains filtered or unexported fields
}

func (*Organization) Create

func (service *Organization) Create(organization *entities.Organization) error

Creates a new organization

func (*Organization) Delete

func (service *Organization) Delete(session Session) error

Deletes an existing organization and all associated entites from the database

func (*Organization) GetUsers

func (service *Organization) GetUsers(session Session) ([]*entities.User, error)

Returns a list of User entities that belong to the organization

func (*Organization) Page

func (service *Organization) Page(session Session,
	pageQuery datastore.PageQuery) (datastore.PageResult[*entities.Organization], error)

Returns a list of User entities that belong to the organization

type OrganizationService

type OrganizationService interface {
	Create(organization *entities.Organization) error
	Page(session Session, pageQuery datastore.PageQuery) (datastore.PageResult[*entities.Organization], error)
	GetUsers(session Session) ([]*entities.User, error)
	Delete(session Session) error
}

func NewOrganizationService

func NewOrganizationService(
	logger *logging.Logger,
	orgDAO datastore.OrganizationDAO) OrganizationService

type RoleService

type RoleService struct {
	RoleServicer
	// contains filtered or unexported fields
}

func (*RoleService) GetByName

func (service *RoleService) GetByName(name string, CONSISTENCY_LEVEL int) (*entities.Role, error)

Returns the role with the given name

func (*RoleService) Page

func (service *RoleService) Page(pageQuery datastore.PageQuery) (datastore.PageResult[*entities.Role], error)

Returns a list of all Role entities in the database

type RoleServicer

type RoleServicer interface {
	GetPage(pageQuery datastore.PageQuery) (datastore.PageResult[*entities.Role], error)
	GetByName(name string, CONSISTENCY_LEVEL int) (*entities.Role, error)
}

func NewRoleService

func NewRoleService(
	logger *logging.Logger,
	roleDAO datastore.RoleDAO) RoleServicer

type Service

type Service struct {
	ID            uint64
	Name          string
	KeyAttributes *keystore.KeyAttributes
}

type ServiceSession

type ServiceSession struct {
	Session
	// contains filtered or unexported fields
}

func (*ServiceSession) Close

func (session *ServiceSession) Close()

func (*ServiceSession) Error

func (session *ServiceSession) Error(err error)

func (*ServiceSession) IsMemberOfOrganization

func (session *ServiceSession) IsMemberOfOrganization(organizationID uint64) bool

func (*ServiceSession) Logger

func (session *ServiceSession) Logger() *logging.Logger

func (*ServiceSession) RequestedOrganizationID

func (session *ServiceSession) RequestedOrganizationID() uint64

func (*ServiceSession) RequestedServiceID

func (session *ServiceSession) RequestedServiceID() uint64

func (*ServiceSession) String

func (session *ServiceSession) String() string

func (*ServiceSession) User

func (session *ServiceSession) User() *entities.User

type Session

type Session interface {
	Close()
	Logger() *logging.Logger
	RequestedOrganizationID() uint64
	RequestedServiceID() uint64
	SetLogger(*logging.Logger)
	User() *entities.User
}

func CreateSession

func CreateSession(
	logger *logging.Logger,
	orgClaims []uint64,
	requestedOrgID uint64,
	requestedServiceID uint64,
	serviceClaims []uint64,
	user *entities.User) Session

type User

type User struct {
	UserServicer
	AuthServicer
	// contains filtered or unexported fields
}

func (*User) Activate

func (service *User) Activate(registrationID uint64) (*entities.User, error)

Activates a pending registration

func (*User) CreateUser

func (service *User) CreateUser(user *entities.User) error

CreateUser creates a new user account

func (*User) Delete

func (service *User) Delete(session Session, userID uint64) error

Deletes an existing user account

func (*User) Get

func (service *User) Get(userID uint64) (*entities.User, error)

Looks up the user account by user ID

func (*User) Login

func (service *User) Login(userCredential *UserCredential) (*entities.User,
	[]*entities.Organization, []*entities.Service, error)

Login authenticates a user account against the AuthService

func (*User) Refresh

func (service *User) Refresh(userID uint64) (*entities.User,
	[]*entities.Organization, []*entities.Service, error)

Reloads the users organizations, services and permissions

func (*User) Register

func (service *User) Register(userCredential *UserCredential,
	baseURI string) (*entities.User, error)

Register signs up a new account

func (*User) ResetPassword

func (service *User) ResetPassword(userCredential *UserCredential) error

Sets a new user password

func (*User) UpdateUser

func (service *User) UpdateUser(user *entities.User) error

UpdateUser an existing user account

type UserCredential

type UserCredential struct {
	OrgID    uint64 `json:"org"`
	Email    string `json:"email"`
	Password string `json:"password"`
	AuthType int    `json:"authType"`
}

type UserServicer

type UserServicer interface {
	CreateUser(user *entities.User) error
	UpdateUser(user *entities.User) error
	Delete(session Session, userID uint64) error
	// DeletePermission(session Session, userID uint64) error
	Get(userID uint64) (*entities.User, error)
	// SetPermission(session Session, permission *entities.Permission) error
	// probably needs to be moved to auth service; not implemented in google_auth yet
	// Refresh(userID uint64) (*entities.User, []*entities.Organization, []*entities.Service, error)
	AuthServicer
}

func NewUserService

func NewUserService(
	logger *logging.Logger,
	userDAO datastore.UserDAO,
	orgDAO datastore.OrganizationDAO,
	roleDAO datastore.RoleDAO,

	authServices map[int]AuthServicer) UserServicer

Jump to

Keyboard shortcuts

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