admin

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound       = errors.New("user not found")
	ErrUserAlreadyExists  = errors.New("username already exists")
	ErrInvalidCredentials = errors.New("invalid credentials")
	ErrPasswordMismatch   = errors.New("passwords do not match")
	ErrCannotDeleteSelf   = errors.New("cannot delete your own account")
)

Functions

func GetTracer

func GetTracer() trace.Tracer

GetTracer returns the configured tracer

func InitTracer

func InitTracer(serviceName, otelEndpoint string, logger l.Logger) (func(context.Context) error, error)

InitTracer initializes the OpenTelemetry tracer

func StreamAuthInterceptor

func StreamAuthInterceptor(auth *Authenticator, logger l.Logger) grpc.StreamServerInterceptor

func StreamTracingInterceptor

func StreamTracingInterceptor(logger l.Logger) grpc.StreamServerInterceptor

StreamTracingInterceptor returns a gRPC streaming interceptor that adds OpenTelemetry tracing

func UnaryAuthInterceptor

func UnaryAuthInterceptor(auth *Authenticator, logger l.Logger) grpc.UnaryServerInterceptor

func UnaryPerformanceInterceptor

func UnaryPerformanceInterceptor() grpc.UnaryServerInterceptor

middleware to measure performance of grpc requests

func UnaryTracingInterceptor

func UnaryTracingInterceptor(logger l.Logger) grpc.UnaryServerInterceptor

UnaryTracingInterceptor returns a gRPC unary interceptor that adds OpenTelemetry tracing

Types

type AdminServiceServer

type AdminServiceServer struct {
	orisun.UnimplementedAdminServer
	// contains filtered or unexported fields
}

AdminServiceServer implements the Admin gRPC service

func NewGRPCAdminServer

func NewGRPCAdminServer(
	logger l.Logger,
	boundary string,
	getEvents GetEventsFunc,
	saveEvents SaveEventsFunc,
	listAdminUsers ListAdminUsersFunc,
	authenticator *Authenticator,
) *AdminServiceServer

NewGRPCAdminServer creates a new AdminServiceServer

func (*AdminServiceServer) ChangePassword

ChangePassword changes a user's password

func (*AdminServiceServer) CreateUser

CreateUser creates a new user with the given details

func (*AdminServiceServer) DeleteUser

DeleteUser deletes a user by ID

func (*AdminServiceServer) GetEventCount

GetEventCount returns the number of events in a boundary

func (*AdminServiceServer) GetUserCount

GetUserCount returns the total number of users

func (*AdminServiceServer) ListUsers

ListUsers returns all users

func (*AdminServiceServer) ValidateCredentials

ValidateCredentials validates username and password

type AuthUserProjector

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

func NewAuthUserProjector

func NewAuthUserProjector(
	logger logger.Logger,
	subscribeToEvents admin_common.SubscribeToEventStoreType,
	boundary string,
) *AuthUserProjector

func (*AuthUserProjector) Start

func (p *AuthUserProjector) Start(ctx context.Context) error

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(getEvents admin_common.GetEventsType, logger logger.Logger,
	boundary string, getUserByUsername func(username string) (orisun.User, error)) *Authenticator

func (*Authenticator) ValidateCredentials

func (a *Authenticator) ValidateCredentials(ctx context.Context, username string, password string) (orisun.User, string, error)

func (*Authenticator) ValidateToken

func (a *Authenticator) ValidateToken(ctx context.Context, token string) (*orisun.User, error)

type GetEventsFunc

type GetEventsFunc func(ctx context.Context, req *orisun.GetEventsRequest) (*orisun.GetEventsResponse, error)

GetEventsFunc is the function signature for getting events

type ListAdminUsersFunc

type ListAdminUsersFunc func() ([]*orisun.User, error)

ListAdminUsersFunc is the function signature for listing admin users

type SaveEventsFunc

type SaveEventsFunc func(ctx context.Context, req *orisun.SaveEventsRequest) (*orisun.WriteResult, error)

SaveEventsFunc is the function signature for saving events

Jump to

Keyboard shortcuts

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