Refactors Scope into base OAuthTokenRequest

This commit is contained in:
Jordan Brown
2020-12-07 12:40:04 -05:00
parent 3b4bd2d703
commit 3168eded05
2 changed files with 12 additions and 11 deletions
@@ -13,21 +13,15 @@ namespace Tgstation.Server.Host.Security.OAuth
/// </summary>
public string GrantType { get; }
/// <summary>
/// The 'scope' field.
/// </summary>
public string Scope { get; }
/// <summary>
/// Initializes a new instance of the <see cref="DiscordTokenRequest"/> <see langword="class"/>.
/// </summary>
/// <param name="oAuthConfiguration">The <see cref="OAuthConfigurationBase"/> for the <see cref="OAuthTokenRequest"/>.</param>
/// <param name="code">The OAuth code for the <see cref="OAuthTokenRequest"/>.</param>
public DiscordTokenRequest(OAuthConfigurationBase oAuthConfiguration, string code)
: base(oAuthConfiguration, code)
: base(oAuthConfiguration, code, "identify")
{
GrantType = "authorization_code";
Scope = "identify";
}
}
}
@@ -9,19 +9,26 @@ namespace Tgstation.Server.Host.Security.OAuth
class OAuthTokenRequest : OAuthConfigurationBase
{
/// <summary>
/// The OAuth code.
/// The OAuth code received from the browser.
/// </summary>
public string Code { get; }
/// <summary>
/// Initializes a new instance of the <see cref="OAuthTokenRequest"/>
/// The scopes being requested.
/// </summary>
public string Scope { get; }
/// <summary>
/// Initializes a new instance of the <see cref="OAuthTokenRequest"/> <see langword="class"/>.
/// </summary>
/// <param name="oAuthConfiguration">The <see cref="OAuthConfiguration"/> to build from.</param>
/// <param name="code">The OAuth code received from the browser.</param>
public OAuthTokenRequest(OAuthConfigurationBase oAuthConfiguration, string code)
/// <param name="code">The value of <see cref="Code"/>.</param>
/// <param name="scope">The value of <see cref="Scope"/></param>
public OAuthTokenRequest(OAuthConfigurationBase oAuthConfiguration, string code, string scope)
: base(oAuthConfiguration)
{
Code = code ?? throw new ArgumentNullException(nameof(code));
Scope = scope ?? throw new ArgumentNullException(nameof(scope));
}
}
}