-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
IOAuthValidator.cs
38 lines (33 loc) · 1.49 KB
/
IOAuthValidator.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
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
namespace Tgstation.Server.Host.Security.OAuth
{
/// <summary>
/// Validates OAuth responses for a given <see cref="Provider"/>.
/// </summary>
public interface IOAuthValidator
{
/// <summary>
/// The <see cref="OAuthProvider"/> this validator is for.
/// </summary>
OAuthProvider Provider { get; }
/// <summary>
/// The <see cref="OAuthGatewayStatus"/> for the <see cref="IOAuthValidator"/>.
/// </summary>
OAuthGatewayStatus GatewayStatus { get; }
/// <summary>
/// Gets the <see cref="OAuthProvider"/> of validator.
/// </summary>
/// <returns>The client ID of the validator on success, <see langword="null"/> on failure.</returns>
OAuthProviderInfo GetProviderInfo();
/// <summary>
/// Validate a given OAuth response <paramref name="code"/>.
/// </summary>
/// <param name="code">The OAuth response string from web application.</param>
/// <param name="requireUserID">If the resulting user ID should be retrieved.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in <see langword="null"/> if authentication failed or the validated <see cref="OAuthConnection.ExternalUserId"/> and OAuth access code otherwise.</returns>
ValueTask<(string? UserID, string AccessCode)?> ValidateResponseCode(string code, bool requireUserID, CancellationToken cancellationToken);
}
}