Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithIdentity ¶
WithIdentity returns a copy of ctx carrying id, retrievable via IdentityFromContext.
Types ¶
type APIKey ¶
APIKey is a service or user credential used for tenant-scoped access. UserID is empty for a tenant-level key (e.g. a service ingestion credential not tied to any one person) and non-empty for a user-level key.
type ClaimsMapping ¶
type ClaimsMapping struct {
TenantIDClaim string
UserIDClaim string
UsernameClaim string
RolesClaim string
}
ClaimsMapping says which of a verified OIDC ID token's claims identity/oidc reads to build an Identity. TenantIDClaim is required (no standard claim holds a tenant ID); the rest default when empty: UserIDClaim to "sub", UsernameClaim to "email", RolesClaim to "roles" (its claim value must be a JSON array of strings).
type ClientCert ¶
ClientCert is an mTLS client-certificate credential used for tenant-scoped access, an alternative (or complement) to APIKey. Fingerprint is the SHA-256 hex digest of the DER-encoded cert -- not a secret, just an identifier; TLS itself already verified the cert against a CA before tenantkit ever sees the request. UserID is empty for a tenant-level cert, non-empty for a user-level cert.
type Identity ¶
type Identity struct {
UserID string
TenantID string
Username string
// Roles is opaque to tenantkit -- it's carried through for a
// consumer's own authorization logic to interpret, never read or
// written by tenantkit itself.
Roles []string
}
Identity is an authenticated user: the result of an IdentityProvider authenticating a request, or a record looked up directly via store.UserStore.
type OIDCProvider ¶
type OIDCProvider struct {
TenantID string
ProviderID string // slug, unique within a tenant, e.g. "okta", "google"
Name string // display label for a login picker, e.g. "Acme Corp Okta"
IssuerURL string
ClientID string
ClientSecret string // plain text -- see store package doc for why
Scopes []string // e.g. []string{"email", "profile"} -- "openid" is added automatically
Domains []string // e.g. []string{"acme.com", "acme.co.uk"} -- globally unique across all tenants
ClaimsMapping ClaimsMapping
}
OIDCProvider is a tenant's registration of an external OIDC-compliant IdP. A tenant may register more than one (ProviderID is unique per tenant, not globally); Domains must be globally unique across every tenant and provider (see store.OIDCProviderStore.GetOIDCProviderByDomain).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admin implements tenantkit's tenant/user/key/cert provisioning operations, working purely against the store interfaces -- the same operations cmd/tenantkit-admin's CLI wraps.
|
Package admin implements tenantkit's tenant/user/key/cert provisioning operations, working purely against the store interfaces -- the same operations cmd/tenantkit-admin's CLI wraps. |
|
Package grpcmw provides gRPC unary and stream server interceptors that resolve the tenant for each incoming call via resolve.TenantResolver, confirm it exists and is active against a store.TenantStore, and optionally authenticate the caller via an identity.IdentityProvider -- rejecting the call with an Unauthenticated/PermissionDenied status on failure and otherwise attaching the resolved tenant (and identity, if any) to the call context before invoking the handler.
|
Package grpcmw provides gRPC unary and stream server interceptors that resolve the tenant for each incoming call via resolve.TenantResolver, confirm it exists and is active against a store.TenantStore, and optionally authenticate the caller via an identity.IdentityProvider -- rejecting the call with an Unauthenticated/PermissionDenied status on failure and otherwise attaching the resolved tenant (and identity, if any) to the call context before invoking the handler. |
|
Package httpmw provides net/http middleware that resolves the tenant for each incoming request via resolve.TenantResolver, confirms it exists and is active against a store.TenantStore, and optionally authenticates the caller via an identity.IdentityProvider -- rejecting the request with 401/403 on failure and otherwise attaching the resolved tenant (and identity, if any) to the request context before calling the next handler.
|
Package httpmw provides net/http middleware that resolves the tenant for each incoming request via resolve.TenantResolver, confirms it exists and is active against a store.TenantStore, and optionally authenticates the caller via an identity.IdentityProvider -- rejecting the request with 401/403 on failure and otherwise attaching the resolved tenant (and identity, if any) to the request context before calling the next handler. |
|
Package identity defines tenantkit's identity-provider abstraction.
|
Package identity defines tenantkit's identity-provider abstraction. |
|
local
Package local is tenantkit's built-in identity.IdentityProvider implementation: password (bcrypt) and WebAuthn (passkey) authentication, opaque-token sessions, and a password-reset token flow.
|
Package local is tenantkit's built-in identity.IdentityProvider implementation: password (bcrypt) and WebAuthn (passkey) authentication, opaque-token sessions, and a password-reset token flow. |
|
local/memstore
Package memstore is an in-memory implementation of identity/local's storage interfaces, including a LoginLimiter (see NewLoginLimiter).
|
Package memstore is an in-memory implementation of identity/local's storage interfaces, including a LoginLimiter (see NewLoginLimiter). |
|
local/sqlite
Package sqlite is a SQLite-backed implementation of identity/local's storage interfaces (CredentialStore, SessionStore, EphemeralStore), using the same pure-Go modernc.org/sqlite driver, Open/Close, and schema-migration pattern as tenantkit/store/sqlite.
|
Package sqlite is a SQLite-backed implementation of identity/local's storage interfaces (CredentialStore, SessionStore, EphemeralStore), using the same pure-Go modernc.org/sqlite driver, Open/Close, and schema-migration pattern as tenantkit/store/sqlite. |
|
local/storetest
Package storetest provides interface-conformance test helpers for identity/local's storage interfaces.
|
Package storetest provides interface-conformance test helpers for identity/local's storage interfaces. |
|
oidc
Package oidc is tenantkit's built-in identity.IdentityProvider implementation wrapping an external OIDC-compliant identity provider: the OAuth2 Authorization Code ceremony (BeginLogin/BeginLoginByDomain/FinishLogin), verified-ID token claims mapped to a tenantkit.Identity, and opaque-token sessions.
|
Package oidc is tenantkit's built-in identity.IdentityProvider implementation wrapping an external OIDC-compliant identity provider: the OAuth2 Authorization Code ceremony (BeginLogin/BeginLoginByDomain/FinishLogin), verified-ID token claims mapped to a tenantkit.Identity, and opaque-token sessions. |
|
oidc/memstore
Package memstore is an in-memory implementation of identity/oidc's storage interfaces.
|
Package memstore is an in-memory implementation of identity/oidc's storage interfaces. |
|
oidc/storetest
Package storetest provides interface-conformance test helpers for identity/oidc's storage interfaces.
|
Package storetest provides interface-conformance test helpers for identity/oidc's storage interfaces. |
|
Package resolve provides tenantkit's tenant-resolution abstractions: Source, a transport-agnostic view of an incoming request, and TenantResolver, a pluggable strategy for extracting a tenant ID from one.
|
Package resolve provides tenantkit's tenant-resolution abstractions: Source, a transport-agnostic view of an incoming request, and TenantResolver, a pluggable strategy for extracting a tenant ID from one. |
|
Package store defines tenantkit's storage interfaces.
|
Package store defines tenantkit's storage interfaces. |
|
memstore
Package memstore is an in-memory implementation of tenantkit's store interfaces.
|
Package memstore is an in-memory implementation of tenantkit's store interfaces. |
|
sqlite
Package sqlite is a SQLite-backed implementation of all four tenantkit/store interfaces (TenantStore, UserStore, APIKeyStore, ClientCertStore), using the pure-Go modernc.org/sqlite driver -- no cgo, no server process, just a library reading/writing one file (or ":memory:" for tests).
|
Package sqlite is a SQLite-backed implementation of all four tenantkit/store interfaces (TenantStore, UserStore, APIKeyStore, ClientCertStore), using the pure-Go modernc.org/sqlite driver -- no cgo, no server process, just a library reading/writing one file (or ":memory:" for tests). |
|
Package storetest provides interface-conformance test helpers for tenantkit's store interfaces.
|
Package storetest provides interface-conformance test helpers for tenantkit's store interfaces. |
|
tools
module
|