groupsync

package
v1.10.23 Latest Latest
Warning

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

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

Documentation

Overview

Package groupsync applies an SSO provider's group claims to Miabi access at sign-in: explicit mappings (group to platform admin, or to a role in a fixed workspace) and structured groups "<prefix>:<workspace>:<role>". It only ever changes memberships it governs, so a member added by hand keeps their place, and it never leaves a workspace without an owner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Action      string
	WorkspaceID uint
	Detail      map[string]any
}

Event reports a change for the audit log.

type Input

type Input struct {
	User *models.User
	// Manager is the provider name recorded on the memberships this sync grants.
	Manager string
	Groups  []string
	Rules   []Rule
	// Prefix enables structured groups; empty ignores them.
	Prefix string
}

Input is one sign-in to reconcile.

type Rule

type Rule struct {
	Group       string
	SystemAdmin bool
	WorkspaceID *uint
	Role        models.WorkspaceRole
}

Rule is one explicit mapping.

type Syncer

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

Syncer applies group claims.

func New

func New(workspaces Workspaces, users Users, canOwn func(userID uint) error, record func(userID uint, e Event)) *Syncer

New builds a Syncer.

func (*Syncer) Reconcile

func (s *Syncer) Reconcile(in Input)

Reconcile brings the user's governed memberships and admin role in line with their groups. Failures are logged, never returned: sign-in must not fail because a membership could not change.

type Users

type Users interface {
	Update(u *models.User) error
	CountByRole(role models.SystemRole) (int64, error)
}

Users promotes and demotes platform admins (*repositories.UserRepository).

type Workspaces

type Workspaces interface {
	FindByName(name string) (*models.Workspace, error)
	FindMember(workspaceID, userID uint) (*models.WorkspaceMember, error)
	AddMember(m *models.WorkspaceMember) error
	UpdateMemberRole(workspaceID, userID uint, role models.WorkspaceRole) error
	SetMemberManagedBy(workspaceID, userID uint, manager string) error
	RemoveMember(workspaceID, userID uint) error
	CountOwners(workspaceID uint) (int64, error)
	ListManagedBy(userID uint, manager string) ([]models.WorkspaceMember, error)
}

Workspaces is the membership storage group sync needs (*repositories.WorkspaceRepository).

Jump to

Keyboard shortcuts

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