-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathBasicAuthenticationExtensions.cs
40 lines (31 loc) · 1.59 KB
/
BasicAuthenticationExtensions.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
// Copyright (c) Barry Dorrans. 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 idunno.Authentication.Basic;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extension methods to add Basic authentication capabilities to an HTTP application pipeline.
/// </summary>
public static class BasicAuthenticationAppBuilderExtensions
{
public static AuthenticationBuilder AddBasic(this AuthenticationBuilder builder)
=> builder.AddBasic(BasicAuthenticationDefaults.AuthenticationScheme);
public static AuthenticationBuilder AddBasic(this AuthenticationBuilder builder, string authenticationScheme)
=> builder.AddBasic(authenticationScheme, configureOptions: null);
public static AuthenticationBuilder AddBasic(this AuthenticationBuilder builder, Action<BasicAuthenticationOptions> configureOptions)
=> builder.AddBasic(BasicAuthenticationDefaults.AuthenticationScheme, configureOptions);
public static AuthenticationBuilder AddBasic(
this AuthenticationBuilder builder,
string authenticationScheme,
Action<BasicAuthenticationOptions> configureOptions)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.AddScheme<BasicAuthenticationOptions, BasicAuthenticationHandler>(authenticationScheme, configureOptions);
}
}
}