forked from blowdart/idunno.Authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCertificateAuthenticationExtensions.cs
38 lines (31 loc) · 1.68 KB
/
CertificateAuthenticationExtensions.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.Certificate;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extension methods to add Certificate authentication capabilities to an HTTP application pipeline.
/// </summary>
public static class CertificateAuthenticationAppBuilderExtensions
{
public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder builder)
=> builder.AddCertificate(CertificateAuthenticationDefaults.AuthenticationScheme);
public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder builder, string authenticationScheme)
=> builder.AddCertificate(authenticationScheme, configureOptions: null);
public static AuthenticationBuilder AddCertificate(this AuthenticationBuilder builder, Action<CertificateAuthenticationOptions> configureOptions)
=> builder.AddCertificate(CertificateAuthenticationDefaults.AuthenticationScheme, configureOptions);
public static AuthenticationBuilder AddCertificate(
this AuthenticationBuilder builder,
string authenticationScheme,
Action<CertificateAuthenticationOptions> configureOptions)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.AddScheme<CertificateAuthenticationOptions, CertificateAuthenticationHandler>(authenticationScheme, configureOptions);
}
}
}