identity

package
v0.0.0-...-7c417f4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package identity abstracts external identity providers behind a subject-keyed Directory, an issuer-aware Linkage over user_identities, and a Service that routes user-keyed operations to the directory registered for each linked issuer.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownIssuer = errors.New("no identity directory registered for issuer")
View Source
var ErrUserNotFound = errors.New("user not found")

Functions

func CreatorContextFromIdentity

func CreatorContextFromIdentity(id Identity) *sharedteamprovision.CreatorContextV1

func ResolveOryIssuer

func ResolveOryIssuer(sdkURL string, jwtConfigs []sharedauth.JWTConfig) (string, error)

ResolveOryIssuer picks the Ory issuer URL from the auth provider's JWT configurations by matching the host of sdkURL against each issuer URL. When exactly one JWT entry is configured, its issuer is used without requiring a host match. When no JWT entries are configured, it falls back to the SDK URL.

Types

type DeleteUserHandle

type DeleteUserHandle interface {
	// Execute removes the external identities (e.g. Ory). It must be called
	// only after the caller has already deleted the database rows.
	Execute(ctx context.Context) error
}

type Directory

type Directory interface {
	GetIdentity(ctx context.Context, subject string) (Identity, error)
	ListIdentities(ctx context.Context, subjects []string) ([]Identity, error)
	SearchByEmail(ctx context.Context, email string) ([]Identity, error)
	SetExternalID(ctx context.Context, subject string, externalID uuid.UUID) error
	DeleteIdentity(ctx context.Context, subject string) error
}

Directory is the subject-keyed admin API of a single identity provider (e.g. one Ory project). It never touches the database; issuer routing is the Service's concern.

func NewOryDirectory

func NewOryDirectory(config OryConfig) (Directory, error)

type Identity

type Identity struct {
	Subject           string
	Email             string
	Name              string
	ProfilePictureURL string
	Providers         []string
	OrganizationID    uuid.UUID
	SignupIP          string
	SignupUserAgent   string
	AuthMethod        string
}

type Linkage

type Linkage interface {
	IdentitiesForUsers(ctx context.Context, issuers []string, userIDs []uuid.UUID) ([]LinkedIdentity, error)
	UsersForSubjects(ctx context.Context, issuer string, subjects []string) ([]LinkedIdentity, error)
}

Linkage resolves the user_id <-> (issuer, subject) mapping. It is the only layer that knows about oidc_iss.

func NewQueriesLinkage

func NewQueriesLinkage(queries linkageQueries) Linkage

type LinkedIdentity

type LinkedIdentity struct {
	Issuer  string
	Subject string
	UserID  uuid.UUID
}

type OryConfig

type OryConfig struct {
	HTTPClient *http.Client
	SDKURL     string
	Token      string
}

type Profile

type Profile struct {
	UserID            uuid.UUID
	Email             string
	Name              string
	ProfilePictureURL string
	Providers         []string
}

func ProfileFromIdentity

func ProfileFromIdentity(userID uuid.UUID, id Identity) Profile

type Service

type Service interface {
	IdentityOrganizationID(ctx context.Context, issuer, subject string) (uuid.UUID, error)
	SetIdentityExternalID(ctx context.Context, issuer, subject string, externalID uuid.UUID) error
	ProfilesByUserID(ctx context.Context, userIDs []uuid.UUID) (map[uuid.UUID]Profile, error)
	UserOrganizationID(ctx context.Context, userID uuid.UUID) (uuid.UUID, error)
	TeamCreatorContext(ctx context.Context, userID uuid.UUID) (*sharedteamprovision.CreatorContextV1, error)
	FindProfilesByEmail(ctx context.Context, email string) ([]Profile, error)
	PrepareDeleteUser(ctx context.Context, userID uuid.UUID) (DeleteUserHandle, error)
}

func NewService

func NewService(directories map[string]Directory, linkage Linkage) (Service, error)

Jump to

Keyboard shortcuts

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