Table of Contents

Class ServiceCollectionExtensions

Namespace
Cuemon.Extensions.AspNetCore.Authentication
Assembly
Cuemon.Extensions.AspNetCore.Authentication.dll

Extension methods for the IServiceCollection interface.

public static class ServiceCollectionExtensions
Inheritance
ServiceCollectionExtensions

Examples

The following example demonstrates how to register the in-memory digest nonce tracker and the authorization response handler services.

using System;
using Cuemon.AspNetCore.Authentication;
using Cuemon.Diagnostics;
using Cuemon.Extensions.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;

namespace MyApp.Examples;

public static class ServiceCollectionExtensionsExample
{
    public static void Demonstrate()
    {
        var services = new ServiceCollection();

        services.AddInMemoryDigestAuthenticationNonceTracker();
        services.AddAuthorizationResponseHandler(o =>
        {
            o.SensitivityDetails = FaultSensitivityDetails.All;
        });

        using var provider = services.BuildServiceProvider();

        Console.WriteLine(provider.GetRequiredService<INonceTracker>().GetType().Name);
        Console.WriteLine(provider.GetRequiredService<AuthorizationResponseHandler>().GetType().Name);
    }
}

Methods

AddAuthorizationResponseHandler(IServiceCollection, Action<AuthorizationResponseHandlerOptions>)

Adds a AuthorizationResponseHandler service to the specified IServiceCollection.

public static IServiceCollection AddAuthorizationResponseHandler(this IServiceCollection services, Action<AuthorizationResponseHandlerOptions> setup = null)

Parameters

services IServiceCollection

The IServiceCollection to extend.

setup Action<AuthorizationResponseHandlerOptions>

The AuthorizationResponseHandlerOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional configuration calls can be chained.

Exceptions

ArgumentNullException

services cannot be null.

ArgumentException

setup failed to configure an instance of AuthorizationResponseHandlerOptions in a valid state.

AddInMemoryDigestAuthenticationNonceTracker(IServiceCollection)

Adds a MemoryNonceTracker service to the specified IServiceCollection.

public static IServiceCollection AddInMemoryDigestAuthenticationNonceTracker(this IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to add services to.

Returns

IServiceCollection

An IServiceCollection that can be used to further configure other services.