-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathRemoteAppAuthenticationExtensions.cs
39 lines (33 loc) · 1.52 KB
/
RemoteAppAuthenticationExtensions.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.AspNetCore.SystemWebAdapters;
using Microsoft.AspNetCore.SystemWebAdapters.Authentication;
using Microsoft.Extensions.DependencyInjection;
namespace System.Web;
/// <summary>
/// Helper methods for registering remote authentication endpoints.
/// </summary>
public static class RemoteAppAuthenticationExtensions
{
/// <summary>
/// Adds the remote authentication module to System.Web adapter configuration.
/// </summary>
/// <param name="builder">The System.Web adapter builder to modify.</param>
/// <param name="configure">Configuration to use when registering the remote authentication module.</param>
/// <returns>The System.Web adapter builder updated to include the remote authentication module.</returns>
public static ISystemWebAdapterRemoteServerAppBuilder AddAuthenticationServer(this ISystemWebAdapterRemoteServerAppBuilder builder, Action<RemoteAppAuthenticationServerOptions>? configure = null)
{
if (builder is null)
{
throw new ArgumentNullException(nameof(builder));
}
builder.Services.AddScoped<IHttpModule, RemoteAppAuthenticationModule>();
var options = builder.Services.AddOptions<RemoteAppAuthenticationServerOptions>()
.ValidateDataAnnotations();
if (configure is not null)
{
options.Configure(configure);
}
return builder;
}
}