Skip to main content

ServiceCollectionExtensions Class

Abblix.Oidc.Server

Abblix.Oidc.Server

ServiceCollectionExtensions Class

Extension methods for integrating OpenID Connect (OIDC) core services into an application's service collection.

public static class ServiceCollectionExtensions

Inheritance System.Object → ServiceCollectionExtensions

Remarks

These methods facilitate the setup of essential components for implementing OIDC authentication and authorization flows, such as token issuance, client authentication, and session management. By calling these extension methods, developers can configure and customize the OIDC server according to their application's security requirements and user management policies.

Methods

ServiceCollectionExtensions.AddEndpoints(this IServiceCollection) Method

Configures the service collection with the always-on OAuth 2.0 and OpenID Connect endpoints — the set mounted unconditionally regardless of EnabledEndpoints: discovery, authorization, PAR, token, UserInfo and end session.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddEndpoints(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The Microsoft.Extensions.DependencyInjection.IServiceCollection to configure with necessary endpoints.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The configured Microsoft.Extensions.DependencyInjection.IServiceCollection, enabling further service registration chaining.

Remarks

By calling this method, the application integrates support for:

- The Configuration (discovery) Endpoint for publishing provider metadata. - The Authorization Endpoint for initiating user authentication and consent. - Pushed Authorization Request (PAR) Endpoint for pre-registering authorization requests. - Token Endpoint for issuing tokens following successful authentication. - User Info Endpoint for accessing authenticated user information. - End Session Endpoint for managing user logout processes.

The niche or security-sensitive endpoints — Revocation, Introspection, CIBA, Check Session and Dynamic Client Registration — are not wired here. Each is opt-in through its dedicated AddX() feature method (AddRevocation, AddIntrospection, AddBackChannelAuthentication, AddCheckSession, AddDynamicClientRegistration), which registers the endpoint services and re-enables its flag in EnabledEndpoints (defaulting to Base).

ServiceCollectionExtensions.AddFeatures(this IServiceCollection) Method

Registers a comprehensive set of services related to client authentication, information management, issuer identification, token services, JWT handling, session management, random value generation and logout notifications.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddFeatures(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The Microsoft.Extensions.DependencyInjection.IServiceCollection to configure with essential features.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The configured Microsoft.Extensions.DependencyInjection.IServiceCollection, allowing for further chaining of service registrations.

Remarks

This method serves as a convenience wrapper that aggregates the registration of various foundational services necessary for the application's security and functionality.

It includes: - Client authentication mechanisms. - Client information management. - Issuer identification. - Token generation, validation and management services. - JSON Web Token (JWT) support. - Session management capabilities. - Random value generators for security tokens and identifiers. - Logout notification mechanisms.

By invoking this method, an application ensures that all critical security and operational features are configured and ready for use.

ServiceCollectionExtensions.AddOidcCore(this IServiceCollection, Action<OidcOptions,IServiceProvider>) Method

Adds OIDC server core services to the service collection with additional access to the service provider for more complex configuration scenarios.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddOidcCore(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Abblix.Oidc.Server.Common.Configuration.OidcOptions,System.IServiceProvider> configureOptions);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The IServiceCollection to enhance with OIDC services.

configureOptions System.Action<OidcOptions,System.IServiceProvider>

A delegate that configures OIDC options with access to the service provider, allowing for dynamic configurations based on other registered services.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The IServiceCollection enabling further configurations.

Remarks

This overload provides flexibility to access other services during the OIDC configuration, such as dynamic issuer discovery or conditional service registrations based on the environment or other services.

ServiceCollectionExtensions.AddOidcCore(this IServiceCollection, Action<OidcOptions>) Method

Registers the core OIDC server services and configurations into the provided service collection.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddOidcCore(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Abblix.Oidc.Server.Common.Configuration.OidcOptions> configureOptions);

Parameters

services Microsoft.Extensions.DependencyInjection.IServiceCollection

The IServiceCollection instance to which the OIDC services are added.

configureOptions System.Action<OidcOptions>

A delegate to configure OIDC server options, allowing customization of settings like issuer URL, token lifetimes, and supported grant types.

Returns

Microsoft.Extensions.DependencyInjection.IServiceCollection
The updated IServiceCollection instance, enabling chaining of further service registrations.