@haneinfo/oidc-delegation
v0.5.7
Published
Readme
@haneinfo/oidc-delegation
Provider-neutral outbound OAuth 2.0 Token Exchange (RFC 8693) delegation client for Haneinfo NestJS applications.
Architecture (0.5.0)
- Port-based token exchange:
@haneinfo/oidc-delegationno longer bundles an IdP-specific HTTP adapter or reads IdP endpoint/credential environment variables. Instead, it optionally injectsIAM_TOKEN_EXCHANGE(haneinfo.iam-token-exchange, implementingTokenExchangeProviderfrom@haneinfo/plugin-api). - O3 gate (fail-closed when disabled): When
IAM_TOKEN_EXCHANGEis not provided,OidcDelegationServiceis not constructed.IDENTITY_DELEGATIONis bound to a disabled implementation that logs once on startup and rejects everyexchange()call withOidcDelegationError('delegation_disabled')(retryable: false). - Single injection token: Consumers must inject
IDENTITY_DELEGATION(IdentityDelegationPort), notOidcDelegationService.
Migrating from 0.4.x to 0.5.0
Removed options and exports
OidcDelegationModuleOptionsno longer acceptsprovider,tokenEndpoint,sourceClientId,sourceClientSecret,allowInsecureTokenEndpoint, orrequestTimeoutMs. OnlysubjectTokenIssuerClientId,policies, and optionalmaxExchangesPerMinutePerPolicyremain.KeycloakTokenExchangeProviderhas moved to@haneinfo/iam-keycloak.TokenExchangeProvider,TokenExchangeProviderParams, andTokenExchangeProviderResultare now re-exported type aliases from@haneinfo/plugin-api.OidcDelegationServiceis no longer exported as a Nest provider fromOidcDelegationModule.forRoot()or the plugin backend; injectIDENTITY_DELEGATIONinstead.haneinfo.plugin.jsonremoves allenvironmententries, addsoptionalRequires: ["haneinfo.iam-token-exchange"], and bumpsengine.haneinfoPluginApito^1.29.0. The plugin backend reads configuration solely fromconfigRef(oidcDelegation), notprocess.env.
NestJS usage
import { IDENTITY_DELEGATION, type IdentityDelegationPort } from '@haneinfo/plugin-api';
import { OidcDelegationModule } from '@haneinfo/oidc-delegation';
// Provide IAM_TOKEN_EXCHANGE (haneinfo.iam-token-exchange) via a separate module/plugin
// when cross-app delegation (O3) is enabled; omit it to keep delegation disabled.
OidcDelegationModule.forRoot({
subjectTokenIssuerClientId: 'my-web-client',
policies: {
submit: {
targetAudience: 'records-api',
requestedScopes: ['records:change:submit'],
maxExpiresInSeconds: 120,
},
},
});