auth

package
v0.0.0-...-0301fe8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 35 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

Index

Constants

View Source
const (
	// MCPScopeTelemetryRead grants read access to Pitot observability data.
	MCPScopeTelemetryRead = "telemetry:read"
	// MCPScopeDashboardManage grants access to manage the authenticated user's dashboards.
	MCPScopeDashboardManage = "dashboard:manage"
)
View Source
const (
	// Access tokens are checked against the database on every request, so
	// revocation is immediate whatever their lifetime. A long lifetime keeps
	// agent clients from refreshing, and racing each other, more than monthly.
	OAuthAccessTTL  = 30 * 24 * time.Hour
	OAuthRefreshTTL = 90 * 24 * time.Hour
	OAuthCodeTTL    = 5 * time.Minute
	// OAuthRefreshReuseGrace admits a refresh token its own client rotated
	// within one access-token lifetime. Agent processes sharing one stored
	// credential refresh from stale copies minutes or hours apart, and the
	// holder of that credential already holds an access token that lives as
	// long; later reuse still revokes the family.
	OAuthRefreshReuseGrace = OAuthAccessTTL
)
View Source
const MaxAlertEmailRecipients = 10

MaxAlertEmailRecipients caps the addresses on one alert rule and on the default destination.

View Source
const SetupTTL = time.Hour

Variables

View Source
var (
	ErrOAuthClientNotFound     = errors.New("oauth client not found")
	ErrOAuthConnectionNotFound = errors.New("oauth connection not found")
	ErrInvalidOAuthGrant       = errors.New("invalid oauth grant")
	ErrInvalidOAuthScope       = errors.New("invalid oauth scope")
	ErrOAuthRefreshReuse       = errors.New("oauth refresh token reuse detected")
	ErrInvalidOAuthToken       = errors.New("invalid oauth token")
)
View Source
var ErrCodeSecretRequired = errors.New("auth: PITOT_AUTH_CODE_SECRET is required for sign-in credentials")

ErrCodeSecretRequired reports a sign-in credential operation attempted without PITOT_AUTH_CODE_SECRET. An empty HMAC key would make stored hashes computable from the credential alone.

View Source
var ErrFirstUserMustBeAdmin = errors.New("the first account must be an active administrator")

ErrFirstUserMustBeAdmin refuses an account on an empty database that would leave the installation without an active administrator.

View Source
var ErrIdentityConflict = errors.New("identity is already linked")
View Source
var ErrInvalidMailAddress = errors.New("invalid mail address")

ErrInvalidMailAddress marks a sender or recipient that does not parse.

View Source
var ErrLastActiveAdmin = errors.New("cannot remove the last active admin")

ErrLastActiveAdmin is returned when an operation would remove the final active admin.

View Source
var ErrSessionExpired = errors.New("session expired")
View Source
var ErrSetupComplete = errors.New("setup already complete")

ErrSetupComplete is returned when setup is attempted but users already exist.

View Source
var ErrUserConflict = errors.New("user already exists")

ErrUserConflict is returned when an email is already assigned to a user.

View Source
var ErrUserNotFound = errors.New("user not found")

ErrUserNotFound is returned when a requested user does not exist.

Functions

func CanonicalMCPOAuthScope

func CanonicalMCPOAuthScope(raw string) (string, bool)

CanonicalMCPOAuthScope validates an MCP OAuth scope string and returns its deduplicated canonical representation. Retired scope names are rejected.

func DetachedWriteContext

func DetachedWriteContext(ctx context.Context) (context.Context, context.CancelFunc)

DetachedWriteContext preserves request values but prevents a disconnected client from cancelling a security-critical revocation, session, or audit write. The deadline remains bounded beyond SQLite's busy window.

func GenerateCode

func GenerateCode() (string, error)

GenerateCode returns a random 6-digit code.

func GenerateLoginLinkToken

func GenerateLoginLinkToken() (string, error)

GenerateLoginLinkToken returns a credential with 256 bits of entropy.

func HashCode

func HashCode(code, secret string) string

HashCode produces an HMAC-SHA256 hex digest of the code.

func IsPermanentMailError

func IsPermanentMailError(err error) bool

IsPermanentMailError reports whether retrying err cannot succeed: an address that does not parse, or a 5xx SMTP reply. Everything else is transient, including a connection lost mid-session, which go-mail reports as a SendError with no server code and does not count as temporary.

func MailFailureDetail

func MailFailureDetail(err error) string

MailFailureDetail describes a send failure by its class and SMTP code, for logs and status shown to users. It never includes err's text, which can carry server responses and recipient addresses.

func NormalizeEmail

func NormalizeEmail(raw string) (string, error)

NormalizeEmail trims, lowercases, and validates an email address.

func NormalizeRecipients

func NormalizeRecipients(raw []string) ([]string, error)

NormalizeRecipients validates a list of bare email addresses, returning them normalized and deduplicated. It rejects display-name forms, control characters and lists over MaxAlertEmailRecipients.

func ResolveMCPRefreshScope

func ResolveMCPRefreshScope(granted, requested string) (string, bool)

ResolveMCPRefreshScope applies the optional scope from a refresh request. Refreshes may retain or reduce the original grant, but never expand it.

func SendAlert

func SendAlert(ctx context.Context, cfg SMTPConfig, alert AlertMail) error

SendAlert renders and sends one alert notification.

func SendCode

func SendCode(cfg SMTPConfig, to, code string) error

SendCode sends a verification code email via SMTP.

func SendInvite

func SendInvite(cfg SMTPConfig, to string) error

SendInvite sends an invitation email to a new user.

func SessionMetadataMiddleware

func SessionMetadataMiddleware(next http.Handler) http.Handler

SessionMetadataMiddleware must wrap SCS LoadAndSave.

func ValidRole

func ValidRole(role string) bool

func ValidUserStatus

func ValidUserStatus(status string) bool

func VerifyHash

func VerifyHash(code, hash, secret string) bool

VerifyHash checks a code against a hash using constant-time comparison.

Types

type AlertMail

type AlertMail struct {
	// ID identifies the delivery. It becomes the Message-ID, so a resend after
	// an interrupted attempt carries the same one.
	ID          string
	To          string
	Rule        string
	Description string
	Service     string
	Event       string
	Value       float64
	Time        time.Time
	// LimitNotice, when set, warns that later notifications will be suppressed.
	LimitNotice string
}

AlertMail is one alert notification for one recipient. Every text field may hold telemetry-derived or operator-written values; SendAlert neutralizes them.

type AuditEvent

type AuditEvent struct {
	ActorUserID string
	EventType   AuditEventType
	Outcome     AuditOutcome
	TargetType  AuditTargetType
	TargetID    string
	RemoteIP    string
	UserAgent   string
	Metadata    map[string]any
}

type AuditEventType

type AuditEventType string

type AuditOutcome

type AuditOutcome string

type AuditStore

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

func NewAuditStore

func NewAuditStore(db *sql.DB) *AuditStore

func (*AuditStore) Cleanup

func (s *AuditStore) Cleanup(ctx context.Context, retention time.Duration, now time.Time) (int64, error)

func (*AuditStore) Record

func (s *AuditStore) Record(ctx context.Context, event AuditEvent) error

func (*AuditStore) RecordTx

func (s *AuditStore) RecordTx(ctx context.Context, tx *sql.Tx, event AuditEvent) error

type AuditTargetType

type AuditTargetType string

type BrowserSessions

type BrowserSessions struct {
	IdleTTL            time.Duration
	AbsoluteTTL        time.Duration
	ActivityCheckpoint time.Duration
	// contains filtered or unexported fields
}

BrowserSessions owns every permitted SCS deadline and renewal operation.

func NewBrowserSessions

func NewBrowserSessions(db *sql.DB, idleTTL, absoluteTTL time.Duration, secure bool) *BrowserSessions

func (*BrowserSessions) AuthVersion

func (s *BrowserSessions) AuthVersion(ctx context.Context) int64

func (*BrowserSessions) BeginOIDCSession

func (s *BrowserSessions) BeginOIDCSession(ctx context.Context, flowTTL, maximum time.Duration, state, nonce, verifier, returnTo string) error

BeginOIDCSession creates a short-lived pre-authentication session and stores the single-use values needed to validate the callback.

func (*BrowserSessions) CleanupExpired

func (s *BrowserSessions) CleanupExpired(ctx context.Context, now time.Time) (int64, error)

func (*BrowserSessions) ClearOIDCFlow

func (s *BrowserSessions) ClearOIDCFlow(ctx context.Context)

func (*BrowserSessions) CountStatus

func (s *BrowserSessions) CountStatus(ctx context.Context, now time.Time) (active, expired int64, err error)

func (*BrowserSessions) Deadline

func (s *BrowserSessions) Deadline(ctx context.Context) time.Time

func (*BrowserSessions) Destroy

func (s *BrowserSessions) Destroy(ctx context.Context) error

func (*BrowserSessions) EnforceActivity

func (s *BrowserSessions) EnforceActivity(ctx context.Context, now time.Time) error

func (*BrowserSessions) EstablishAuthenticatedSession

func (s *BrowserSessions) EstablishAuthenticatedSession(ctx context.Context, user User) error

func (*BrowserSessions) Middleware

func (s *BrowserSessions) Middleware(next http.Handler) http.Handler

func (*BrowserSessions) OIDCFlow

func (s *BrowserSessions) OIDCFlow(ctx context.Context) (state, nonce, verifier, returnTo string)

func (*BrowserSessions) UserID

func (s *BrowserSessions) UserID(ctx context.Context) string

type CodeStore

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

CodeStore manages verification codes in SQLite.

func NewCodeStore

func NewCodeStore(db *sql.DB, secret string) *CodeStore

NewCodeStore creates a CodeStore with the given HMAC secret.

func (*CodeStore) Cleanup

func (s *CodeStore) Cleanup() error

Cleanup deletes expired verification credentials older than 1 hour.

func (*CodeStore) Create

func (s *CodeStore) Create(email string) (string, error)

Create stores a verification code for the given email. Returns the plaintext code.

func (s *CodeStore) CreateBreakGlassLoginLink(email string) (string, error)

CreateBreakGlassLoginLink stores a short-lived, single-use credential that only the OIDC-mode link route redeems.

func (s *CodeStore) CreateLoginLink(email string) (string, error)

CreateLoginLink stores a short-lived, single-use login link credential.

func (*CodeStore) RecentCount

func (s *CodeStore) RecentCount(email string, since time.Time) (int, error)

func (*CodeStore) Verify

func (s *CodeStore) Verify(email, code string) (bool, error)

Verify checks the code for the given email. Returns true if valid.

func (s *CodeStore) VerifyBreakGlassLoginLink(token string) (string, bool, error)

VerifyBreakGlassLoginLink atomically consumes a valid break-glass link and returns the email it was issued for. Ordinary login links never match.

func (s *CodeStore) VerifyLoginLink(token string) (string, bool, error)

VerifyLoginLink atomically consumes a valid login-link token and returns the email it was issued for. Login links are purpose-bound and cannot be used as ordinary email verification codes.

type IdentityStore

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

func NewIdentityStore

func NewIdentityStore(db *sql.DB) *IdentityStore

func (*IdentityStore) CountForUser

func (s *IdentityStore) CountForUser(ctx context.Context, userID string) (int64, error)

func (*IdentityStore) Find

func (s *IdentityStore) Find(ctx context.Context, issuer, subject string) (UserIdentity, error)

func (*IdentityStore) FindForUser

func (s *IdentityStore) FindForUser(ctx context.Context, userID string) (UserIdentity, error)

FindForUser returns the identity linked to a user, or ErrUserNotFound when the user has none.

func (*IdentityStore) LinkWithAudit

func (s *IdentityStore) LinkWithAudit(ctx context.Context, userID, issuer, subject, email string, audit *AuditStore, event AuditEvent) (UserIdentity, error)

func (*IdentityStore) TouchLogin

func (s *IdentityStore) TouchLogin(ctx context.Context, id string) error

type KeyedLimiter

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

KeyedLimiter is a bounded-lifetime in-memory limiter for source-derived bucket keys. Account/email cooldowns remain durable in SQLite.

func NewKeyedLimiter

func NewKeyedLimiter(count int, window time.Duration) *KeyedLimiter

func (*KeyedLimiter) Allow

func (l *KeyedLimiter) Allow(key string) bool

type OAuthAuthorizationCode

type OAuthAuthorizationCode struct {
	ClientID      string
	UserID        string
	RedirectURI   string
	Scope         string
	Resource      string
	CodeChallenge string
	ExpiresAt     time.Time
}

type OAuthClient

type OAuthClient struct {
	ClientID                string   `json:"client_id"`
	ClientName              string   `json:"client_name"`
	ClientURI               string   `json:"client_uri,omitempty"`
	RedirectURIs            []string `json:"redirect_uris"`
	GrantTypes              []string `json:"grant_types"`
	ResponseTypes           []string `json:"response_types"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method"`
	CreatedAt               int64    `json:"client_id_issued_at"`
}

type OAuthConnection

type OAuthConnection struct {
	ClientID    string    `json:"client_id"`
	ClientName  string    `json:"client_name"`
	ConnectedAt time.Time `json:"connected_at"`
	RefreshedAt time.Time `json:"refreshed_at"`
	Scope       string    `json:"scope"`
}

type OAuthStore

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

func NewOAuthStore

func NewOAuthStore(db *sql.DB) *OAuthStore

func (*OAuthStore) CleanupExpired

func (s *OAuthStore) CleanupExpired(ctx context.Context, now time.Time) (int64, error)

CleanupExpired garbage-collects OAuth state that can no longer affect any flow, returning the total number of rows deleted. It removes:

  • authorization codes past their expiry,
  • token rows that are individually dead (expired or revoked) AND whose refresh family has no live refresh token left — revoked rows in a still-live family are kept because they are exactly what refresh-reuse detection matches against,
  • dynamically-registered clients older than oauthClientGCAge with no remaining codes or tokens.

func (*OAuthStore) ConsumeAuthorizationCode

func (s *OAuthStore) ConsumeAuthorizationCode(ctx context.Context, raw string) (OAuthAuthorizationCode, error)

func (*OAuthStore) CreateAuthorizationCode

func (s *OAuthStore) CreateAuthorizationCode(ctx context.Context, code OAuthAuthorizationCode) (string, error)

func (*OAuthStore) GetClient

func (s *OAuthStore) GetClient(ctx context.Context, clientID string) (OAuthClient, error)

func (*OAuthStore) IssueTokenPair

func (s *OAuthStore) IssueTokenPair(ctx context.Context, clientID, userID, scope, resource string) (OAuthTokenPair, error)

func (*OAuthStore) ListConnections

func (s *OAuthStore) ListConnections(ctx context.Context, userID string) ([]OAuthConnection, error)

func (*OAuthStore) RegisterClient

func (s *OAuthStore) RegisterClient(ctx context.Context, name, clientURI string, redirectURIs []string) (OAuthClient, error)

func (*OAuthStore) RevokeConnection

func (s *OAuthStore) RevokeConnection(ctx context.Context, userID, clientID string, event AuditEvent) error

func (*OAuthStore) RotateRefreshToken

func (s *OAuthStore) RotateRefreshToken(ctx context.Context, clientID, raw, resource, requestedScope string) (OAuthTokenPair, error)

func (*OAuthStore) VerifyAccessToken

func (s *OAuthStore) VerifyAccessToken(ctx context.Context, raw, resource string) (OAuthTokenRecord, error)

VerifyAccessToken returns ErrInvalidOAuthToken only for tokens that are definitively invalid (unknown, expired, revoked, or wrong audience). A database failure is returned as a wrapped infrastructure error so callers can fail closed without treating an outage as a bad credential.

type OAuthTokenPair

type OAuthTokenPair struct {
	AccessToken  string
	RefreshToken string
	ExpiresIn    int64
	Scope        string
}

func (OAuthTokenPair) String

func (p OAuthTokenPair) String() string

String implements fmt.Stringer with the token material redacted so that a stray %v/%s log of a pair can never leak raw credentials.

type OAuthTokenRecord

type OAuthTokenRecord struct {
	Kind      TokenKind
	FamilyID  string
	ClientID  string
	UserID    string
	Scope     string
	Resource  string
	ExpiresAt time.Time
	RevokedAt sql.NullInt64
}

type ProvisionRequest

type ProvisionRequest struct {
	Issuer      string
	Subject     string
	Email       string
	DisplayName string
	Role        Role
	Status      UserStatus
}

ProvisionRequest describes an account an identity provider wants to exist.

type Role

type Role string
const (
	RoleViewer   Role = "viewer"
	RoleOperator Role = "operator"
	RoleAdmin    Role = "admin"
)

type SMTPConfig

type SMTPConfig struct {
	Host string
	Port int
	User string
	Pass string
	From string
}

SMTPConfig holds SMTP connection settings.

type SQLiteSessionStore

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

SQLiteSessionStore implements both scs.Store and scs.CtxStore. Reads inherit request cancellation. Security writes deliberately shed request cancellation but remain bounded beyond SQLite's busy timeout.

func NewSQLiteSessionStore

func NewSQLiteSessionStore(db *sql.DB) *SQLiteSessionStore

func (*SQLiteSessionStore) CleanupExpired

func (s *SQLiteSessionStore) CleanupExpired(ctx context.Context, idleTTL time.Duration, now time.Time) (int64, error)

func (*SQLiteSessionStore) Commit

func (s *SQLiteSessionStore) Commit(token string, data []byte, expiry time.Time) error

func (*SQLiteSessionStore) CommitCtx

func (s *SQLiteSessionStore) CommitCtx(ctx context.Context, token string, data []byte, expiry time.Time) error

func (*SQLiteSessionStore) CountStatus

func (s *SQLiteSessionStore) CountStatus(ctx context.Context, idleTTL time.Duration, now time.Time) (active, expired int64, err error)

func (*SQLiteSessionStore) Delete

func (s *SQLiteSessionStore) Delete(token string) error

func (*SQLiteSessionStore) DeleteCtx

func (s *SQLiteSessionStore) DeleteCtx(ctx context.Context, token string) error

func (*SQLiteSessionStore) DeleteUserSessions

func (s *SQLiteSessionStore) DeleteUserSessions(ctx context.Context, userID string) error

func (*SQLiteSessionStore) Find

func (s *SQLiteSessionStore) Find(token string) ([]byte, bool, error)

func (*SQLiteSessionStore) FindCtx

func (s *SQLiteSessionStore) FindCtx(ctx context.Context, token string) ([]byte, bool, error)

func (*SQLiteSessionStore) Touch

func (s *SQLiteSessionStore) Touch(ctx context.Context, rawToken SessionToken, before, now time.Time) (bool, error)

type SessionMetadata

type SessionMetadata struct {
	UserID            string
	CreatedAt         time.Time
	LastActivityAt    time.Time
	AbsoluteExpiresAt time.Time
}

SessionMetadata is queryable metadata stored alongside SCS's opaque blob. A pointer is placed in the request context before SCS runs so FindCtx and CommitCtx share it without replacing the context SCS retains for commit.

type SessionToken

type SessionToken string

type SessionTokenDigest

type SessionTokenDigest string

func SessionTokenHash

func SessionTokenHash(token SessionToken) SessionTokenDigest

SessionTokenHash matches SCS v2.9 HashTokenInStore. Its compatibility is covered by an integration test so an upstream format change cannot silently orphan activity updates or revocation.

type Setup

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

Setup holds the in-memory first-boot admin token.

func NewSetup

func NewSetup() *Setup

func (*Setup) Clear

func (s *Setup) Clear()

func (*Setup) Rotate

func (s *Setup) Rotate() (string, time.Time, error)

func (*Setup) Verify

func (s *Setup) Verify(token string) SetupStatus

Verify returns why a setup token is or isn't acceptable. Comparison is constant-time.

type SetupStatus

type SetupStatus int

SetupStatus is the result of verifying a presented setup token.

const (
	SetupStatusOK SetupStatus = iota
	SetupStatusUnset
	SetupStatusExpired
	SetupStatusWrong
)

func (SetupStatus) String

func (s SetupStatus) String() string

type TokenKind

type TokenKind string

TokenKind discriminates the two token rows stored per grant.

const (
	TokenKindAccess  TokenKind = "access"
	TokenKindRefresh TokenKind = "refresh"
)

type User

type User struct {
	ID          string     `json:"id"`
	Email       string     `json:"email"`
	DisplayName string     `json:"display_name"`
	Role        Role       `json:"role"`
	Status      UserStatus `json:"status"`
	AuthVersion int64      `json:"-"`
	LoggedInAt  string     `json:"logged_in_at,omitempty"`
	CreatedAt   string     `json:"created_at"`
	UpdatedAt   string     `json:"updated_at"`
}

User represents an authenticated user.

type UserChange

type UserChange struct {
	Email       *string
	DisplayName *string
	Role        *Role
	Status      *UserStatus
}

UserChange lists the fields a directory update may set; nil leaves one alone.

type UserIdentity

type UserIdentity struct {
	ID          string
	UserID      string
	Issuer      string
	Subject     string
	EmailAtLink string
	CreatedAt   string
	LastLoginAt string
}

type UserStatus

type UserStatus string
const (
	UserStatusActive    UserStatus = "active"
	UserStatusSuspended UserStatus = "suspended"
)

type UserStore

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

UserStore provides CRUD operations for users.

func NewUserStore

func NewUserStore(db *sql.DB) *UserStore

NewUserStore creates a UserStore backed by the given database connection.

func (*UserStore) CountActiveAdmins

func (s *UserStore) CountActiveAdmins() (int64, error)

CountActiveAdmins returns the number of active admin users.

func (*UserStore) CountUsers

func (s *UserStore) CountUsers() (int64, error)

CountUsers returns the number of users in the database.

func (*UserStore) CreateFirstAdminWithAudit

func (s *UserStore) CreateFirstAdminWithAudit(email, displayName string, event AuditEvent) (User, error)

CreateFirstAdminWithAudit atomically creates the first admin user. Returns ErrSetupComplete if users already exist (race-safe).

func (*UserStore) CreateWithAudit

func (s *UserStore) CreateWithAudit(email, displayName string, role Role, event AuditEvent) (User, error)

CreateWithAudit adds a new user.

func (*UserStore) DeleteWithAudit

func (s *UserStore) DeleteWithAudit(id string, event AuditEvent) error

DeleteWithAudit removes a user and all of its browser sessions by ID.

func (*UserStore) GetByEmail

func (s *UserStore) GetByEmail(email string) (User, error)

GetByEmail returns a user by email address.

func (*UserStore) GetByEmailContext

func (s *UserStore) GetByEmailContext(ctx context.Context, email string) (User, error)

func (*UserStore) GetByID

func (s *UserStore) GetByID(id string) (User, error)

GetByID returns a user by ID.

func (*UserStore) GetByIDContext

func (s *UserStore) GetByIDContext(ctx context.Context, id string) (User, error)

func (*UserStore) List

func (s *UserStore) List() ([]User, error)

List returns all users ordered by creation time.

func (*UserStore) ProvisionFederated

func (s *UserStore) ProvisionFederated(ctx context.Context, req ProvisionRequest, source AuditEvent) (User, UserIdentity, bool, error)

ProvisionFederated creates an account and its identity link in one transaction, so a crash cannot leave an unlinked account for a later login to claim by email.

A request whose identity already exists changes nothing and returns the current account with created false. A delayed retry therefore cannot undo a later role change or suspension; the provisioner applies changes with an update.

source supplies attribution for the audit events; its type and target are set here.

func (*UserStore) RevokeAllSessionsWithAudit

func (s *UserStore) RevokeAllSessionsWithAudit(id string, event AuditEvent) error

RevokeAllSessionsWithAudit invalidates and removes every browser session for a user.

func (*UserStore) TouchLogin

func (s *UserStore) TouchLogin(id string) error

TouchLogin updates the logged_in_at timestamp.

func (*UserStore) TouchLoginAt

func (s *UserStore) TouchLoginAt(id string, at time.Time) error

func (*UserStore) UpdateProvisioned

func (s *UserStore) UpdateProvisioned(id string, change UserChange, source AuditEvent) (User, bool, error)

UpdateProvisioned applies a directory update in one write transaction, including the last-active-administrator check. A change to the current state is reported with changed false and writes nothing, so it is safe to repeat. The exception is repeating a suspension while a session or OAuth credential is still live: those are removed and audited. The identity link is never touched.

func (*UserStore) UpdateWithAudit

func (s *UserStore) UpdateWithAudit(id string, email, displayName *string, role *Role, status *UserStatus, event AuditEvent) (User, error)

UpdateWithAudit modifies a user's fields. Email, role, or status changes revoke every browser session.

Jump to

Keyboard shortcuts

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