You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
namespace AuthStudy.Authentication.Basic
{
public static class BasicAuthenticationExtensions
{
public static AuthenticationBuilder AddBasic(this AuthenticationBuilder builder)
{
return builder.AddBasic(BasicAuthenticationDefaults.AuthenticationScheme);
}
public static AuthenticationBuilder AddBasic(this AuthenticationBuilder builder, string authenticationScheme)
{
return builder.AddBasic(authenticationScheme, configureOptions: null);
}
public static AuthenticationBuilder AddBasic(this AuthenticationBuilder builder, Action<BasicAuthenticationOptions> configureOptions)
{
return 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);
}
}
}