admin

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSessionTTL         = 24 * time.Hour
	DefaultMaxSessionsPerUser = 16
)

Variables

View Source
var (
	ErrUserNotFound     = errors.New("user not found")
	ErrCannotDeleteSelf = errors.New("cannot delete your own account")
)

Functions

func GetTracer

func GetTracer() trace.Tracer

GetTracer returns the configured tracer

func InitTelemetryWithContext added in v0.9.3

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

InitTelemetryWithContext initializes OTLP trace and metric exporters using a shared resource and endpoint.

func InitTracer

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

InitTracer initializes OpenTelemetry traces and metrics. The name is kept for source compatibility with existing embedding code.

func InitTracerWithContext added in v0.8.0

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

InitTracerWithContext initializes OpenTelemetry traces and metrics using the caller's lifecycle. The name is kept for source compatibility.

func StreamAuthInterceptor

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

func StreamMetricsInterceptor added in v0.9.3

func StreamMetricsInterceptor() grpc.StreamServerInterceptor

StreamMetricsInterceptor records OpenTelemetry metrics for streaming gRPC calls from stream establishment until the handler returns.

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 UnaryMetricsInterceptor added in v0.9.3

func UnaryMetricsInterceptor() grpc.UnaryServerInterceptor

UnaryMetricsInterceptor records OpenTelemetry metrics for unary gRPC calls.

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 {
	grpcapi.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 CredentialsValidator,
) *AdminServiceServer

NewGRPCAdminServer creates a new AdminServiceServer

func NewGRPCAdminServerWithBoundaryCommands added in v0.8.0

func NewGRPCAdminServerWithBoundaryCommands(
	logger l.Logger,
	boundary string,
	getEvents GetEventsFunc,
	saveEvents SaveEventsFunc,
	listAdminUsers ListAdminUsersFunc,
	authenticator CredentialsValidator,
	boundarySaver orisun.EventsSaver,
	boundaryReader orisun.EventsRetriever,
) *AdminServiceServer

func NewGRPCAdminServerWithDependencies added in v0.8.0

func NewGRPCAdminServerWithDependencies(
	logger l.Logger,
	boundary string,
	dependencies GRPCAdminDependencies,
) *AdminServiceServer

func (*AdminServiceServer) ChangePassword

ChangePassword changes a user's password

func (*AdminServiceServer) CreateBoundary added in v0.8.0

CreateBoundary emits the definition event. Physical provisioning is handled asynchronously by the boundary_provisioning slice subscriber.

func (*AdminServiceServer) CreateUser

CreateUser creates a new user with the given details

func (*AdminServiceServer) DeleteUser

DeleteUser deletes a user by ID

func (*AdminServiceServer) GetBoundary added in v0.8.0

func (*AdminServiceServer) GetEventCount

GetEventCount returns the number of events in a boundary

func (*AdminServiceServer) GetUserCount

GetUserCount returns the total number of users

func (*AdminServiceServer) ListBoundaries added in v0.8.0

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,
	revokeSessions ...func(string) int,
) *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(ctx context.Context, username string) (orisun.User, error),
	sessionTTL ...time.Duration,
) *Authenticator

func (*Authenticator) RevokeUserSessions added in v0.9.3

func (a *Authenticator) RevokeUserSessions(userID string) int

RevokeUserSessions invalidates every session issued for userID and returns the number of sessions removed.

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)

func (*Authenticator) VerifyCredentials added in v0.9.3

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

VerifyCredentials validates a username and password without issuing a session. Administrative credential checks use this path so their result does not leave an unreachable live token behind.

type CredentialsValidator added in v0.8.0

type CredentialsValidator interface {
	ValidateCredentials(context.Context, string, string) (orisun.User, string, error)
}

type CredentialsVerifier added in v0.9.3

type CredentialsVerifier interface {
	VerifyCredentials(context.Context, string, string) (orisun.User, error)
}

type GRPCAdminDependencies added in v0.8.0

type GRPCAdminDependencies struct {
	GetEvents            GetEventsFunc
	SaveEvents           SaveEventsFunc
	ListAdminUsers       ListAdminUsersFunc
	GetUserCount         GetUserCountFunc
	GetEventCount        GetEventCountFunc
	CredentialsValidator CredentialsValidator
	BoundarySaver        orisun.EventsSaver
	BoundaryReader       orisun.EventsRetriever
}

type GetEventCountFunc added in v0.8.0

type GetEventCountFunc func(ctx context.Context, boundary string) (int, error)

type GetEventsFunc

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

GetEventsFunc is the function signature for getting events

type GetUserCountFunc added in v0.8.0

type GetUserCountFunc func(ctx context.Context) (uint32, error)

type ListAdminUsersFunc

type ListAdminUsersFunc func(ctx context.Context) ([]*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

type SessionRevoker added in v0.9.3

type SessionRevoker interface {
	RevokeUserSessions(userID string) int
}

Directories

Path Synopsis
slices
boundary_catalog
Package boundary_catalog projects boundary lifecycle events into a catalog.
Package boundary_catalog projects boundary lifecycle events into a catalog.

Jump to

Keyboard shortcuts

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