Table of Contents

Class OnBehalfOfAuthenticationExtensions

Namespace
Arc4u.OAuth2.Extensions
Assembly
Arc4u.OAuth2.AspNetCore.Authentication.dll

Registers the on-behalf-of settings: named SimpleKeyValueSettings read by the Obo token provider.

public static class OnBehalfOfAuthenticationExtensions
Inheritance
OnBehalfOfAuthenticationExtensions
Inherited Members

Methods

AddOnBehalfOf(IServiceCollection, IConfiguration, string)

Registers the on-behalf-of settings of a configuration section. Each child of the section is a OnBehalfOfSettingsOptions registered under the name of the child. Nothing is registered when the section does not exist.

public static void AddOnBehalfOf(this IServiceCollection services, IConfiguration configuration, string sectionName = "Authentication:OnBehalfOf")

Parameters

services IServiceCollection

The service collection.

configuration IConfiguration

The configuration.

sectionName string

The section to read. The default is Authentication:OnBehalfOf.

Exceptions

ConfigurationException

A setting has an empty client id, client secret, scopes or authentication type.

AddOnBehalfOfSettings(IServiceCollection, Action<OnBehalfOfSettingsOptions>, string)

Registers one on-behalf-of setting from code.

public static void AddOnBehalfOfSettings(this IServiceCollection services, Action<OnBehalfOfSettingsOptions> options, string optionKey)

Parameters

services IServiceCollection

The service collection.

options Action<OnBehalfOfSettingsOptions>

The action that configures the setting.

optionKey string

The name under which the settings are registered.

Examples

builder.Services.AddOnBehalfOfSettings(o =>
{
    o.ClientId = "my-client-id";
    o.ClientSecret = "my-client-secret";
    o.Scopes.Add("api://downstream-api/.default");
}, "DownstreamApi");

Exceptions

ArgumentNullException

An argument is null or empty.

ConfigurationException

The client id, the client secret, the scopes or the authentication type is empty.