Repository navigation
Expand file tree
/
Copy pathWsFederationExtensions.cs
More file actions
58 lines (53 loc) · 3.32 KB
/
Copy pathWsFederationExtensions.cs
File metadata and controls
58 lines (53 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.WsFederation;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Extensions for registering the <see cref="WsFederationHandler"/>.
/// </summary>
public static class WsFederationExtensions
{
/// <summary>
/// Registers the <see cref="WsFederationHandler"/> using the default authentication scheme, display name, and options.
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder)
=> builder.AddWsFederation(WsFederationDefaults.AuthenticationScheme, _ => { });
/// <summary>
/// Registers the <see cref="WsFederationHandler"/> using the default authentication scheme, display name, and the given options configuration.
/// </summary>
/// <param name="builder"></param>
/// <param name="configureOptions">A delegate that configures the <see cref="WsFederationOptions"/>.</param>
/// <returns></returns>
public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, Action<WsFederationOptions> configureOptions)
=> builder.AddWsFederation(WsFederationDefaults.AuthenticationScheme, configureOptions);
/// <summary>
/// Registers the <see cref="WsFederationHandler"/> using the given authentication scheme, default display name, and the given options configuration.
/// </summary>
/// <param name="builder"></param>
/// <param name="authenticationScheme"></param>
/// <param name="configureOptions">A delegate that configures the <see cref="WsFederationOptions"/>.</param>
/// <returns></returns>
public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, string authenticationScheme, Action<WsFederationOptions> configureOptions)
=> builder.AddWsFederation(authenticationScheme, WsFederationDefaults.DisplayName, configureOptions);
/// <summary>
/// Registers the <see cref="WsFederationHandler"/> using the given authentication scheme, display name, and options configuration.
/// </summary>
/// <param name="builder"></param>
/// <param name="authenticationScheme"></param>
/// <param name="displayName"></param>
/// <param name="configureOptions">A delegate that configures the <see cref="WsFederationOptions"/>.</param>
/// <returns></returns>
public static AuthenticationBuilder AddWsFederation(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<WsFederationOptions> configureOptions)
{
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<WsFederationOptions>, WsFederationPostConfigureOptions>());
return builder.AddRemoteScheme<WsFederationOptions, WsFederationHandler>(authenticationScheme, displayName, configureOptions);
}
}
}