-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathUnauthenticatedAuthenticationBuilderExtensions.cs
More file actions
34 lines (29 loc) · 1.31 KB
/
UnauthenticatedAuthenticationBuilderExtensions.cs
File metadata and controls
34 lines (29 loc) · 1.31 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.AspNetCore.Authentication;
namespace Azure.DataApiBuilder.Core.AuthenticationHelpers.UnauthenticatedAuthentication;
/// <summary>
/// Extension methods related to Unauthenticated authentication.
/// This class allows setting up Unauthenticated authentication in the startup class with
/// a single call to .AddAuthentication(scheme).AddUnauthenticatedAuthentication()
/// </summary>
public static class UnauthenticatedAuthenticationBuilderExtensions
{
/// <summary>
/// Add authentication with Unauthenticated provider.
/// </summary>
/// <param name="builder">Authentication builder.</param>
/// <returns>The builder, to chain commands.</returns>
public static AuthenticationBuilder AddUnauthenticatedAuthentication(this AuthenticationBuilder builder)
{
if (builder is null)
{
throw new System.ArgumentNullException(nameof(builder));
}
builder.AddScheme<AuthenticationSchemeOptions, UnauthenticatedAuthenticationHandler>(
authenticationScheme: UnauthenticatedAuthenticationDefaults.AUTHENTICATIONSCHEME,
displayName: UnauthenticatedAuthenticationDefaults.AUTHENTICATIONSCHEME,
configureOptions: null);
return builder;
}
}