forked from aspnet-contrib/AspNet.Security.OAuth.Providers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitCodeAuthenticationExtensions.cs
More file actions
74 lines (68 loc) · 3.61 KB
/
GitCodeAuthenticationExtensions.cs
File metadata and controls
74 lines (68 loc) · 3.61 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/
using AspNet.Security.OAuth.GitCode;
namespace Microsoft.Extensions.DependencyInjection;
/// <summary>
/// Extension methods to add GitCode authentication capabilities to an HTTP application pipeline.
/// </summary>
public static class GitCodeAuthenticationExtensions
{
/// <summary>
/// Adds <see cref="GitCodeAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables GitCode authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddGitCode([NotNull] this AuthenticationBuilder builder)
{
return builder.AddGitCode(GitCodeAuthenticationDefaults.AuthenticationScheme, options => { });
}
/// <summary>
/// Adds <see cref="GitCodeAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables GitCode authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="configuration">The delegate used to configure the OpenID 2.0 options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddGitCode(
[NotNull] this AuthenticationBuilder builder,
[NotNull] Action<GitCodeAuthenticationOptions> configuration)
{
return builder.AddGitCode(GitCodeAuthenticationDefaults.AuthenticationScheme, configuration);
}
/// <summary>
/// Adds <see cref="GitCodeAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables GitCode authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="scheme">The authentication scheme associated with this instance.</param>
/// <param name="configuration">The delegate used to configure the GitCode options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddGitCode(
[NotNull] this AuthenticationBuilder builder,
[NotNull] string scheme,
[NotNull] Action<GitCodeAuthenticationOptions> configuration)
{
return builder.AddGitCode(scheme, GitCodeAuthenticationDefaults.DisplayName, configuration);
}
/// <summary>
/// Adds <see cref="GitCodeAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables GitCode authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="scheme">The authentication scheme associated with this instance.</param>
/// <param name="caption">The optional display name associated with this instance.</param>
/// <param name="configuration">The delegate used to configure the GitCode options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddGitCode(
[NotNull] this AuthenticationBuilder builder,
[NotNull] string scheme,
[CanBeNull] string caption,
[NotNull] Action<GitCodeAuthenticationOptions> configuration)
{
return builder.AddOAuth<GitCodeAuthenticationOptions, GitCodeAuthenticationHandler>(scheme, caption, configuration);
}
}