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
- func BindPlatformOrg(ctx context.Context, cfg config.Config, log *slog.Logger, n Applier, ...)
- func LogStartupHints(ctx context.Context, cfg config.Config, log *slog.Logger, st HintReader, ...) error
- func RevokeLocalSessions(ctx context.Context, log *slog.Logger, n Applier, st SessionLister, ...)
- func RevokeOnce(ctx context.Context, log *slog.Logger, n Applier, st SessionLister) (int, error)
- func RunStartupHints(ctx context.Context, cfg config.Config, log *slog.Logger, n Applier, ...)
- func TryBindPlatformOrg(ctx context.Context, log *slog.Logger, n Applier, st TenantReader, org string) bool
- type Applier
- type HintReader
- type SessionLister
- type TenantReader
Constants ¶
const BindInterval = 30 * time.Second
BindInterval is how often the leader retries binding the default tenant.
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).
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 ¶
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.