15.2. Register through an OIDC authorization request
Feature guides / 15. OIDC and OAuth workflows · Example context
Maya chooses Umeå University OP on LIGO Wiki's sign-in page. LIGO Wiki resolves Umeå University OP, selects a compatible federation path, and creates the request that Umeå University OP will use for automatic registration.
How to use it
Call automaticallyRegister() on the initialized RP role. It returns a Result describing the signed request and delivery. On the OP side, processAutomaticRegistration() verifies the Request Object and registration evidence; the OP host supplies replay storage. Automatic registration.
import type { OidcRelyingPartyRole } from "@oidfed/oidc";
export async function beginUmeaOpLogin(rp: OidcRelyingPartyRole, state: string, nonce: string) {
const result = await rp.automaticallyRegister({
opEntityId: "https://op.umu.example",
redirect_uri: "https://wiki.ligo.example/callback",
scope: "openid profile", state, nonce,
});
if (!result.ok) return result;
return result;
}
LIGO Wiki must sign with a key published in its resolved client metadata. If eduGAIN supplies or replaces its protocol keys through metadata or policy, the Request Object and PAR client assertion checks use those effective keys. A key published only in LIGO Wiki’s own Entity Configuration cannot satisfy the check after its Superior has replaced that key set. The same rule applies to OAuth clients.
What your application owns
Generate state and nonce for the session and validate them when the protocol returns. Follow the returned delivery instructions rather than constructing an authorization URL from raw metadata. Federation acceptance does not complete the OIDC authorization code flow. The application owns client persistence, login, consent, authorization-code processing, and token validation. Registration must not outlive its applicable evidence.
Require accreditation before registration
Configure trustMarkRequirements: { requiredTypes: [type] } on the provider role. An optional beforeRegistration callback can add host policy using immutable authenticated chain evidence. Requirements run first; both must pass before registration persistence, response signing, or replay consumption. Callback exceptions and malformed results reject registration. Evidence lifetime is checked again after an asynchronous callback returns.
Issuer verification can use independent accreditation anchors through options.trustMarkVerification. Current active-status checks remain the host's policy choice. See Trust Mark validation and the provider API.
Approve trust before creating protocol state
LIGO Wiki discovers Umeå, selects a compatible chain, and builds the signed request using the resulting protocol metadata. Umeå validates the RP evidence and applicable accreditation before creating client secrets, consuming replay state, or accepting registration through the configured flow.
Test a valid request and one whose policy or Trust Mark requirement fails. The negative request must not leave accepted client state behind. The host still owns the user's authorization interaction after federation registration succeeds; completing this step alone does not authenticate Maya.
PAR acceptance and authentication failures
Use effective client and server metadata when deciding whether a Request Object
is required and which signing algorithms are allowed. Provider role methods
apply these declarations; pass completed providerMetadata when publication is
only partial. Preserve the returned authorization parameter values, including
JSON objects and repeated resources, for your authorization policy checks.
authenticationExpiresAt records the current deadline for registration/PAR
authentication. The library checks it before starting registration persistence.
Your application owns the transaction and the single-use PAR request URI.
Cancellation or a timeout stops waiting; it does not roll back a callback's
external effects. Check the storage outcome before retrying an uncertain write.
For Client Attestation, use the typed failure reason to produce the required
protocol response. A challenge error needs a fresh host-issued challenge in
OAuth-Client-Attestation-Challenge; an attestation-age rejection needs
use_fresh_attestation. Handle infrastructure failures separately. The library's
callback timeout is an operational limit, not a specification-mandated duration.
Request Objects, keys, and PAR authentication
For automatic registration, RPs sign authorization requests as Request Objects using protocol keys. The trust_chain JOSE header carries the RP's chain when available; metadata is resolved from its Entity Statements. Use OidcRelyingPartyRole.automaticallyRegister(...) for the normal RP flow: it discovers the OP, validates the selected trust chain, signs the Request Object, and returns the delivery-specific authorization parameters. Use createAuthorizationRequest(...) only when you already have a validated DiscoveryResult.
RP and OP protocol metadata accept public keys with optional kid values, as defined by Federation §5.2.1. During automatic registration, a Request Object can omit its header kid when the resolved protocol key set contains exactly one key. Multiple-key sets require the header identifier (OIDC Core §10.1); when supplied, it must identify a matching client key (RFC 9101 §6.2). Explicit registration keeps the federation key requirements for the request Entity Configuration while accepting optional identifiers in its protocol metadata. The built-in signers include their key identifiers in generated JWTs.
With requestDelivery: "par", the role posts the signed Request Object as proof under Federation §12.1.1.2. It adds a private_key_jwt assertion when the selected chains' effective RP and OP metadata both advertise that method, as required by §12.1.4. The RP can advertise a supported-method list or a single method. When both are supplied, the single value must belong to the list (RP Metadata Choices §2).
When mutual support for JWT authentication is absent, the request uses its signed Request Object alone. Contradictory method declarations return invalid_metadata. Each signer used must be published in the selected chain’s resolved client metadata through jwks, jwks_uri, or signed_jwks_uri. This applies to both OIDC and OAuth Request Objects and PAR client assertions. An Immediate Superior can supply or replace the client’s keys through metadata or policy. The local signer checks use that effective metadata: a signer whose identifier is absent from the resolved inline jwks is rejected before that JWT is signed. The assertion audience is the OP Entity Identifier.
OAuthClientRole reads the client's authentication methods from oauth_client metadata. Its provider counterpart is oauth_authorization_server; co-published OIDC metadata does not change that selection. OidcRelyingPartyRole reads them from openid_relying_party, including when the entity hosts both roles (Federation §12.1.5).
Choose incoming Request Object typing
The provider role defaults to requestObjectTyping: "strict", requiring the explicit
oauth-authz-req+jwt type. Outgoing requests always use that type. A deployment that
needs legacy OIDC Request Objects can opt into "compatible", which also accepts
JWT typing or an absent typ. Both policies recognize case-insensitive media types
and the equivalent application/ prefix under RFC 7515 §4.1.9. Other token types remain
rejected.
import { OidcProviderRole } from "@oidfed/oidc";
const provider = new OidcProviderRole({ requestObjectTyping: "compatible" });
Configure replay storage on the host before initializing the role and processing
requests. The same option applies to OAuthAuthorizationServerRole, automatic
registration, and signed PAR requests. A method-level option overrides the role setting.
Compatibility preserves signature, trusted-key, issuer, audience, expiry, accreditation,
and replay checks. It changes only which Request Object types the provider accepts.
Federation §12.1.1.1.1 uses explicit typing in a non-normative example; RFC 9101 §10.8
explains explicit typing and compatibility with existing deployments.
Handle the selected delivery mode
automaticallyRegister() and createAuthorizationRequest() return a Result<AutomaticRegistrationResult>. After checking ok, narrow value.delivery before accessing fields specific to a delivery mode.
Every successful result contains requestObjectJwt (string), trustChain (ValidatedTrustChain, for the OP), and trustChainExpiresAt (NumericDate seconds).
delivery |
Additional fields | Application action |
|---|---|---|
"query" |
authorizationUrl: string |
Redirect to the URL carrying request and client_id |
"form_post" |
authorizationEndpoint: string, formParams: Record<string, string> |
POST the returned form fields to the endpoint |
"request_uri" |
requestUri: string, authorizationUrl: string |
Serve requestObjectJwt at requestUri, then redirect |
"par" |
pushedAuthorizationRequestEndpoint: string, authorizationUrl: string, parRequestUri: string, parExpiresAt: number |
Redirect to the returned URL before PAR expiry |
Other PAR proof choices
LIGO Wiki can use createPushedAuthorizationRequest to prepare PAR with a
signed Request Object, private_key_jwt, or self-signed mTLS. Client Attestation
is also available alongside a signed Request Object: it does not replace the
Federation requirement to prove possession of an RP protocol key.
The provider calls processPushedAuthorizationRequest before creating its PAR
request URI. The library verifies registration and authentication; the host owns
request-URI storage, the TLS connection, and the subsequent authorization session.
See the PAR role methods.
The academic portal can include JSON claims, numeric max_age, and multiple
resource values in its PAR request. Prepared parameters is a URLSearchParams;
pass it directly as the HTTP body so repeated values survive. If either side's
effective metadata requires signed Request Objects, use a mode that includes one.
The university receives the complete verified parameters and an
authenticationExpiresAt deadline. Its persistence callback starts only after
that deadline and cancellation have been checked. The university still owns
request URI storage, authorization decisions, and transaction handling.