Documentation
¶
Overview ¶
Package authkit binds ContentKit channels to AuthKit permission groups. Host-defined roles use access.ChannelPermissions; current group authority controls authoring independently of descriptive metadata and paid readership.
Index ¶
- Variables
- func AppPermission(p access.Permission) string
- func AppScopes(c Client, scope contentkit.Scope) (entities.Scopes, error)
- func ChannelScopeID(scope contentkit.Scope, groupID string) (string, error)
- func MigrationScopes(pool *pgxpool.Pool, cfg authkit.Config, scope contentkit.Scope) (entities.ScopeProvisioner, error)
- func NewAuthorization(ctx context.Context, groups AuthorizationGroups, cfg AuthorizationConfig) (contentkit.Authorization, error)
- func Scopes(c Client) entities.Scopes
- func TenantPermission(p access.Permission) string
- type AccountResolver
- type AuthorizationConfig
- type AuthorizationGroups
- type ChannelResolver
- type Client
- type TenantActorResolver
Constants ¶
This section is empty.
Variables ¶
var ErrScopeMigrationRequired = errors.New("contentkit/authkit: explicit authorization-scope migration required")
ErrScopeMigrationRequired means persisted authorization groups still use the retired library-specific personas. Migrate them explicitly through AuthKit before adopting this adapter; startup never rewrites grants or keys.
Functions ¶
func AppPermission ¶ added in v0.7.0
func AppPermission(p access.Permission) string
AppPermission is the AuthKit app permission for a ContentKit staff operation. A limited tenant role may include that same permission; AuthKit scopes its inheritance to the tenant's apps.
func AppScopes ¶ added in v0.7.0
AppScopes isolates provider authorization groups even when two apps reuse a content group ID. Existing content references remain unchanged.
func ChannelScopeID ¶ added in v0.14.0
func ChannelScopeID(scope contentkit.Scope, groupID string) (string, error)
ChannelScopeID is a deterministic AuthKit group identity for a ContentKit channel in one tenant and app. Existing content IDs and stored auth_scope references stay unchanged; only the provider's authorization ID is derived.
func MigrationScopes ¶ added in v0.13.0
func MigrationScopes(pool *pgxpool.Pool, cfg authkit.Config, scope contentkit.Scope) (entities.ScopeProvisioner, error)
MigrationScopes supplies MigratePostgres with the same app-isolated group identities as AppScopes, without constructing an AuthKit runtime. The host supplies its normal AuthKit store/role configuration after migrating AuthKit. No signing keys, login providers, senders or worker fleet are needed.
func NewAuthorization ¶ added in v0.7.0
func NewAuthorization(ctx context.Context, groups AuthorizationGroups, cfg AuthorizationConfig) (contentkit.Authorization, error)
NewAuthorization returns an app-bound ContentKit policy. The authenticator must produce PermissionChecker credentials. AuthKit's native effective Can preserves global root grants, live membership and credential restrictions.
func TenantPermission ¶ added in v0.7.0
func TenantPermission(p access.Permission) string
TenantPermission names shared account operations. It is empty for app-only operations: tenant roles include AppPermission grants instead of defining a duplicate tenant permission. Currently only avatar administration is shared.
Types ¶
type AccountResolver ¶ added in v0.7.0
AccountResolver is the legacy dedicated-issuer mapping to an existing account in the requested tenant. Shared multi-tenant issuers use TenantActorResolver instead. Matching email or subject text alone does not establish an association.
func IssuerAccounts ¶ added in v0.7.0
func IssuerAccounts(tenant contentkit.TenantID, issuer string) AccountResolver
IssuerAccounts binds one entire, dedicated issuer account directory to a tenant, retaining its existing subject IDs. Use a different resolver when one issuer contains accounts from multiple tenants or subject IDs differ.
type AuthorizationConfig ¶ added in v0.7.0
type AuthorizationConfig struct {
Scope contentkit.Scope
// Issuer identifies the trusted tenant account directory. For a resource
// server it can differ from the authority that owns the permission entities.
Issuer string
// PermissionAuthority owns AppScope, TenantAdminScope and content group
// scopes. Empty preserves the same-issuer behavior by using Issuer.
PermissionAuthority string
AppScope auth.Scope
// TenantAdminScope is optional, explicit tenant administration. Native
// effective root authority also applies, within the credential's limits.
TenantAdminScope auth.Scope
// TenantActors defaults to groups when it implements TenantActorResolver.
// New multi-tenant hosts use this verified, live ownership boundary.
TenantActors TenantActorResolver
// Accounts is the legacy dedicated-issuer contract. Do not use it when
// one issuer contains accounts from more than one tenant.
Accounts AccountResolver
// Channels overrides deterministic ChannelScopeID resolution only for an
// explicitly verified legacy binding. New apps use AppScopes and omit it.
Channels ChannelResolver
}
AuthorizationConfig binds one ContentKit app to its identity directory and AuthKit permission group. These values come from trusted provisioning, never request headers. It creates no groups, accounts or role assignments.
type AuthorizationGroups ¶ added in v0.7.0
type AuthorizationGroups interface {
Group(context.Context, iam.GroupRef) (iam.Group, error)
Scope(context.Context, iam.GroupRef) (auth.Scope, error)
}
AuthorizationGroups reads the AuthKit groups used by the binding. A *authkit.Client satisfies it; no credential or role mutation is needed.
type ChannelResolver ¶ added in v0.14.0
ChannelResolver resolves a channel authorization group owned by this app. Return auth.ErrForbidden for a missing group or one belonging to another app.
type Client ¶ added in v0.6.0
type Client interface {
Persona(name string) (iam.Persona, error)
Group(ctx context.Context, ref iam.GroupRef) (iam.Group, error)
CreateGroup(ctx context.Context, g iam.NewGroup, opts ...authkit.Option) (iam.Group, error)
DeleteGroup(ctx context.Context, ref iam.GroupRef, opts ...authkit.Option) error
PurgeGroup(ctx context.Context, ref iam.GroupRef, opts ...authkit.Option) error
Permission(text string) (iam.Perm, error)
ListMemberships(ctx context.Context, s iam.Subject, p iam.PageRequest) (iam.ListPage[iam.Membership], error)
EffectivePermissions(ctx context.Context, who auth.Identity, refs []iam.GroupRef) (map[string][]iam.Perm, error)
}
Client is what Scopes needs of AuthKit: *authkit.Client.
type TenantActorResolver ¶ added in v0.8.0
type TenantActorResolver interface {
ResolveTenantActor(context.Context, auth.Verified) (iam.TenantActor, error)
}
TenantActorResolver returns live source-account ownership from a verified credential. AuthKit's Client implements it; it never grants target access.