useraccess

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReferenceNotFound = errors.New("referenced entity not found")
)

Functions

This section is empty.

Types

type HTTPHandler

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

func NewHTTPHandler

func NewHTTPHandler(service *Service, repo *Repository, logger *slog.Logger) *HTTPHandler

func (*HTTPHandler) ListOwnerRefs added in v0.6.0

type Observer

type Observer interface {
	OnHostAccessChanged(ctx context.Context)
}

Observer is implemented by any component that must react when user host-access grants change (e.g. policy.Service refreshing its cache).

type Repository

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

func NewRepository

func NewRepository(db *database.DB) *Repository

func (*Repository) DeleteUserData

func (r *Repository) DeleteUserData(ctx context.Context, userID ids.UserID) error

func (*Repository) EnsureUserSettings

func (r *Repository) EnsureUserSettings(ctx context.Context, userID ids.UserID) error

func (*Repository) GetAllUserHostGrants

func (r *Repository) GetAllUserHostGrants(ctx context.Context) ([]UserHostGrant, error)

GetAllUserHostGrants resolves every (user, fqdn) pair reachable through user_allowed_host_groups → host_group_members → hosts.

NOTE: this query intentionally crosses into the hosts domain tables (hosts, host_group_members), which violates the cross-domain-queries pattern (docs/patterns/backend/cross-domain-queries.md). It is kept here because this data is tightly coupled to the policy cache lifecycle. If this query grows or is reused outside of cache population, move it to internal/queries/.

func (*Repository) GetAllUserHostSettings

func (r *Repository) GetAllUserHostSettings(ctx context.Context) ([]UserHostSetting, error)

func (*Repository) GetOwnerRefs added in v0.6.0

func (r *Repository) GetOwnerRefs(ctx context.Context) ([]httpapi.OwnerRef, error)

GetOwnerRefs returns every non-deleted user as a minimal {id, display_name} reference for owner pickers, sorted the way they render.

func (*Repository) SetUserAccess

func (r *Repository) SetUserAccess(ctx context.Context, userID ids.UserID, bypassHostCheck bool, groupIDs []ids.HostGroupID) error

func (*Repository) SubjectRows added in v0.6.0

func (r *Repository) SubjectRows(ctx context.Context, userID *ids.UserID) ([]SubjectRow, error)

SubjectRows returns every non-deleted user as an access subject, optionally narrowed to one. It carries no device aggregates: a caller composing a fleet already holds the device rows those counts derive from.

type Service

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

func NewService

func NewService(repo repository, tx transactor, logger *slog.Logger) *Service

func (*Service) AddObserver

func (s *Service) AddObserver(o Observer)

func (*Service) GetAllUserHostAccess

func (s *Service) GetAllUserHostAccess(ctx context.Context) ([]policy.UserHostAccess, error)

GetAllUserHostAccess implements the policy.HostAccessProvider interface.

func (*Service) OnUserEvent

func (s *Service) OnUserEvent(ctx context.Context, event auth.UserEvent)

func (*Service) SetUserAccess

func (s *Service) SetUserAccess(ctx context.Context, userID ids.UserID, bypassHostCheck bool, groupIDs []ids.HostGroupID) error

type SubjectRow added in v0.6.0

type SubjectRow struct {
	ID              ids.UserID
	DisplayName     string
	Role            httpapi.UserRole
	BypassHostCheck bool
	HostGroups      []httpapi.GroupSummary
}

SubjectRow is one access subject's display identity: the role and bypass-host-check badge and the host groups granted to them. Role and bypass are rendered, never interpreted — the deciding domains are auth and the policy engine.

type UserHostGrant

type UserHostGrant struct {
	UserID ids.UserID `db:"user_id"`
	FQDN   string     `db:"fqdn"`
}

UserHostGrant is a resolved (user, fqdn) access grant.

type UserHostSetting

type UserHostSetting struct {
	UserID          ids.UserID `db:"user_id"`
	BypassHostCheck bool       `db:"bypass_host_check"`
}

UserHostSetting is the per-user bypass flag from user_host_settings.

Jump to

Keyboard shortcuts

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