authswitch

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 10 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 authswitch holds the leader tasks that run after a cluster moved from AUTH_MODE=local to oidc (ADR 0032, FA-AUTH-08).

Index

Constants

View Source
const BindInterval = 30 * time.Second

BindInterval is how often the leader retries binding the default tenant.

View Source
const SessionInterval = 30 * time.Second

SessionInterval is how often the leader looks for local refresh sessions. It also bounds how long a session issued by a voter that still runs in local mode during a rolling restart stays valid (ADR 0032).

View Source
const StartupHintsInterval = 5 * time.Second

StartupHintsInterval is how often RunStartupHints checks whether it can log.

Variables

This section is empty.

Functions

func BindPlatformOrg

func BindPlatformOrg(ctx context.Context, cfg config.Config, log *slog.Logger, n Applier, st TenantReader)

BindPlatformOrg binds the default tenant to the platform organization (zitadel profile, ADR 0027). Only the leader proposes; the loop ends once the binding exists or cannot succeed.

func LogStartupHints

func LogStartupHints(ctx context.Context, cfg config.Config, log *slog.Logger, st HintReader, now func() time.Time) error

LogStartupHints logs what an operator must check after the switch from AUTH_MODE=local to oidc (ADR 0032, options 3A, 4A, 5A): every tenant from local mode that has no organization, and the API tokens that local users created and that stay valid. It runs once, on the leader.

func RevokeLocalSessions

func RevokeLocalSessions(ctx context.Context, log *slog.Logger, n Applier, st SessionLister, interval time.Duration)

RevokeLocalSessions revokes, while this node leads, every refresh session of a local account, at once and then every interval until ctx ends. Local accounts stay for emergency access (ADR 0019), but a switch back to local must not revive cookies from before the migration (ADR 0032, option 1B). The caller starts it only in AUTH_MODE=oidc.

func RevokeOnce

func RevokeOnce(ctx context.Context, log *slog.Logger, n Applier, st SessionLister) (int, error)

RevokeOnce revokes the refresh sessions of every user that holds one and returns the number of users. It stops at the first failed command; the next run retries the rest.

func RunStartupHints

func RunStartupHints(ctx context.Context, cfg config.Config, log *slog.Logger, n Applier, st HintReader, now func() time.Time, interval time.Duration)

RunStartupHints waits until this node leads and the default tenant exists, then calls LogStartupHints once. It stops early when ctx ends or the hints are logged. The caller starts it only in AUTH_MODE=oidc.

func TryBindPlatformOrg

func TryBindPlatformOrg(ctx context.Context, log *slog.Logger, n Applier, st TenantReader, org string) bool

TryBindPlatformOrg makes one attempt to bind the default tenant to org. It returns true when the attempt is final: the binding exists, the default tenant is bound elsewhere, or the command was rejected for good. It returns false when the caller should try again.

Types

type Applier

type Applier interface {
	IsLeader() bool
	Apply(ctx context.Context, cmd *pb.Command) (cluster.ApplyResult, error)
}

Applier is the part of cluster.Node the tasks use.

type HintReader

type HintReader interface {
	GetTenant(ctx context.Context, id string) (store.Tenant, error)
	ListTenants(ctx context.Context) ([]store.Tenant, error)
	GetUser(ctx context.Context, tenantID, id string) (store.User, error)
	ListAPITokens(ctx context.Context, tenantID string) ([]store.APIToken, error)
}

HintReader is the read access of the startup hints.

type SessionLister

type SessionLister interface {
	ListUnrevokedSessionUsers(ctx context.Context) ([]store.SessionUser, error)
}

SessionLister lists the users that still hold a refresh token.

type TenantReader

type TenantReader interface {
	GetTenant(ctx context.Context, id string) (store.Tenant, error)
}

TenantReader reads the default tenant.

Jump to

Keyboard shortcuts

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