Skip to content

Commit a2300a8

Browse files
authored
Add API docs to twitter auth (#29473)
1 parent bdec803 commit a2300a8

File tree

6 files changed

+79
-1
lines changed

6 files changed

+79
-1
lines changed

src/Security/Authentication/Twitter/src/Messages/RequestToken.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public class RequestToken
1818
/// </summary>
1919
public string TokenSecret { get; set; }
2020

21+
/// <summary>
22+
/// Gets or sets whether the callback was confirmed.
23+
/// </summary>
2124
public bool CallbackConfirmed { get; set; }
2225

2326
/// <summary>

src/Security/Authentication/Twitter/src/Microsoft.AspNetCore.Authentication.Twitter.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<Description>ASP.NET Core middleware that enables an application to support Twitter's OAuth 1.0 authentication workflow.</Description>
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
6-
<NoWarn>$(NoWarn);CS1591</NoWarn>
76
<GenerateDocumentationFile>true</GenerateDocumentationFile>
87
<PackageTags>aspnetcore;authentication;security</PackageTags>
98
</PropertyGroup>

src/Security/Authentication/Twitter/src/TwitterDefaults.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33

44
namespace Microsoft.AspNetCore.Authentication.Twitter
55
{
6+
/// <summary>
7+
/// Default values for the Twitter authentication handler.
8+
/// </summary>
69
public static class TwitterDefaults
710
{
11+
/// <summary>
12+
/// The default scheme for Twitter authentication. The value is <c>Twitter</c>.
13+
/// </summary>
814
public const string AuthenticationScheme = "Twitter";
915

16+
/// <summary>
17+
/// The default display name for Twitter authentication. Defaults to <c>Twitter</c>.
18+
/// </summary>
1019
public static readonly string DisplayName = "Twitter";
1120

1221
// https://developer.twitter.com/en/docs/basics/authentication/api-reference/request_token

src/Security/Authentication/Twitter/src/TwitterExtensions.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,62 @@
99

1010
namespace Microsoft.Extensions.DependencyInjection
1111
{
12+
/// <summary>
13+
/// Extension methods to configure Twitter OAuth authentication.
14+
/// </summary>
1215
public static class TwitterExtensions
1316
{
17+
/// <summary>
18+
/// Adds Twitter OAuth-based authentication to <see cref="AuthenticationBuilder"/> using the default scheme.
19+
/// The default scheme is specified by <see cref="TwitterDefaults.AuthenticationScheme"/>.
20+
/// <para>
21+
/// Facebook authentication allows application users to sign in with their Facebook account.
22+
/// </para>
23+
/// </summary>
24+
/// <param name="builder">The <see cref="AuthenticationBuilder"/>.</param>
25+
/// <returns>A reference to <paramref name="builder"/> after the operation has completed.</returns>
1426
public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder)
1527
=> builder.AddTwitter(TwitterDefaults.AuthenticationScheme, _ => { });
1628

29+
/// <summary>
30+
/// Adds Twitter OAuth-based authentication to <see cref="AuthenticationBuilder"/> using the default scheme.
31+
/// The default scheme is specified by <see cref="TwitterDefaults.AuthenticationScheme"/>.
32+
/// <para>
33+
/// Facebook authentication allows application users to sign in with their Facebook account.
34+
/// </para>
35+
/// </summary>
36+
/// <param name="builder">The <see cref="AuthenticationBuilder"/>.</param>
37+
/// <param name="configureOptions">A delegate to configure <see cref="TwitterOptions"/>.</param>
38+
/// <returns>A reference to <paramref name="builder"/> after the operation has completed.</returns>
1739
public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, Action<TwitterOptions> configureOptions)
1840
=> builder.AddTwitter(TwitterDefaults.AuthenticationScheme, configureOptions);
1941

42+
/// <summary>
43+
/// Adds Twitter OAuth-based authentication to <see cref="AuthenticationBuilder"/> using the default scheme.
44+
/// The default scheme is specified by <see cref="TwitterDefaults.AuthenticationScheme"/>.
45+
/// <para>
46+
/// Facebook authentication allows application users to sign in with their Facebook account.
47+
/// </para>
48+
/// </summary>
49+
/// <param name="builder">The <see cref="AuthenticationBuilder"/>.</param>
50+
/// <param name="authenticationScheme">The authentication scheme.</param>
51+
/// <param name="configureOptions">A delegate to configure <see cref="TwitterOptions"/>.</param>
52+
/// <returns>A reference to <paramref name="builder"/> after the operation has completed.</returns>
2053
public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, Action<TwitterOptions> configureOptions)
2154
=> builder.AddTwitter(authenticationScheme, TwitterDefaults.DisplayName, configureOptions);
2255

56+
/// <summary>
57+
/// Adds Twitter OAuth-based authentication to <see cref="AuthenticationBuilder"/> using the default scheme.
58+
/// The default scheme is specified by <see cref="TwitterDefaults.AuthenticationScheme"/>.
59+
/// <para>
60+
/// Facebook authentication allows application users to sign in with their Facebook account.
61+
/// </para>
62+
/// </summary>
63+
/// <param name="builder">The <see cref="AuthenticationBuilder"/>.</param>
64+
/// <param name="authenticationScheme">The authentication scheme.</param>
65+
/// <param name="displayName">A display name for the authentication handler.</param>
66+
/// <param name="configureOptions">A delegate to configure <see cref="TwitterOptions"/>.</param>
67+
/// <returns>A reference to <paramref name="builder"/> after the operation has completed.</returns>
2368
public static AuthenticationBuilder AddTwitter(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<TwitterOptions> configureOptions)
2469
{
2570
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());

src/Security/Authentication/Twitter/src/TwitterHandler.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
namespace Microsoft.AspNetCore.Authentication.Twitter
2424
{
25+
/// <summary>
26+
/// Authentication handler for Twitter's OAuth based authentication.
27+
/// </summary>
2528
public class TwitterHandler : RemoteAuthenticationHandler<TwitterOptions>
2629
{
2730
private static readonly JsonSerializerOptions ErrorSerializerOptions = new JsonSerializerOptions
@@ -41,12 +44,18 @@ public class TwitterHandler : RemoteAuthenticationHandler<TwitterOptions>
4144
set { base.Events = value; }
4245
}
4346

47+
/// <summary>
48+
/// Initializes a new instance of <see cref="TwitterHandler"/>.
49+
/// </summary>
50+
/// <inheritdoc />
4451
public TwitterHandler(IOptionsMonitor<TwitterOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock)
4552
: base(options, logger, encoder, clock)
4653
{ }
4754

55+
/// <inheritdoc />
4856
protected override Task<object> CreateEventsAsync() => Task.FromResult<object>(new TwitterEvents());
4957

58+
/// <inheritdoc />
5059
protected override async Task<HandleRequestResult> HandleRemoteAuthenticateAsync()
5160
{
5261
var query = Request.Query;
@@ -130,6 +139,14 @@ protected override async Task<HandleRequestResult> HandleRemoteAuthenticateAsync
130139
}
131140
}
132141

142+
/// <summary>
143+
/// Creates an <see cref="AuthenticationTicket"/> from the specified <paramref name="token"/>.
144+
/// </summary>
145+
/// <param name="identity">The <see cref="ClaimsIdentity"/>.</param>
146+
/// <param name="properties">The <see cref="AuthenticationProperties"/>.</param>
147+
/// <param name="token">The <see cref="AccessToken"/>.</param>
148+
/// <param name="user">The <see cref="JsonElement"/> for the user.</param>
149+
/// <returns>The <see cref="AuthenticationTicket"/>.</returns>
133150
protected virtual async Task<AuthenticationTicket> CreateTicketAsync(
134151
ClaimsIdentity identity, AuthenticationProperties properties, AccessToken token, JsonElement user)
135152
{
@@ -144,6 +161,7 @@ protected virtual async Task<AuthenticationTicket> CreateTicketAsync(
144161
return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name);
145162
}
146163

164+
/// <inheritdoc />
147165
protected override async Task HandleChallengeAsync(AuthenticationProperties properties)
148166
{
149167
if (string.IsNullOrEmpty(properties.RedirectUri))

src/Security/Authentication/Twitter/src/TwitterPostConfigureOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class TwitterPostConfigureOptions : IPostConfigureOptions<TwitterOptions>
1414
{
1515
private readonly IDataProtectionProvider _dp;
1616

17+
/// <summary>
18+
/// Initializes the <see cref="TwitterPostConfigureOptions"/>.
19+
/// </summary>
20+
/// <param name="dataProtection">The <see cref="IDataProtectionProvider"/>.</param>
1721
public TwitterPostConfigureOptions(IDataProtectionProvider dataProtection)
1822
{
1923
_dp = dataProtection;

0 commit comments

Comments
 (0)