rolemap

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rolemap resolves an external identity's group memberships to one of B1's roles.

Shared by LDAP (group DNs) and OIDC (a groups claim) so the precedence rule cannot drift between them: an operator who reorders auth.ldap.role_map expects auth.oidc.role_map to behave the same way.

Index

Constants

View Source
const (
	// SourceDirectory recomputes the role from the provider's groups on every
	// login; the users API rejects role edits on such accounts.
	SourceDirectory = "directory"
	// SourceLocal seeds the role from groups when the account is first
	// provisioned only; admins own it afterwards and the API allows edits.
	SourceLocal = "local"
)

Role sources decide who owns an externally-authenticated user's role after the account exists. They live here, beside Map, because LDAP and OIDC must spell them identically: the users API compares an account's provider mode against these values, and two copies of the enum could drift apart.

Variables

This section is empty.

Functions

func Map

func Map(mappings []Mapping, defaultRole string, groups []string) (string, bool)

Map returns the role for groups, or defaultRole when nothing matches.

Iteration is over mappings, not over groups: config order IS the precedence mechanism, so a user in both an admin group and an artist group gets whatever the operator listed first. Iterating groups instead would make the result depend on the order the provider happened to return them — non-deterministic and unexplainable.

The false return means "reject this login": an empty defaultRole is how a deployment requires group membership to sign in at all.

Types

type Mapping

type Mapping struct {
	Group string
	Role  string
}

Mapping is one group → role rule.

Jump to

Keyboard shortcuts

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