-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1997 from tgstation/GitHubGateway [APIDeploy][GQL…
…Deploy][NugetDeploy] OAuth Gateways
- Loading branch information
Showing
22 changed files
with
275 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Tgstation.Server.Api/Models/Response/OAuthGatewayResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Tgstation.Server.Api.Models.Response | ||
{ | ||
/// <summary> | ||
/// Success result for an OAuth gateway login attempt. | ||
/// </summary> | ||
public sealed class OAuthGatewayResponse | ||
{ | ||
/// <summary> | ||
/// The user's access token for the requested OAuth service. | ||
/// </summary> | ||
public string? AccessCode { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/Tgstation.Server.Host/Configuration/OAuthGatewayStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Tgstation.Server.Host | ||
{ | ||
/// <summary> | ||
/// Status of the OAuth gateway for a provider. | ||
/// </summary> | ||
public enum OAuthGatewayStatus | ||
{ | ||
/// <summary> | ||
/// The OAuth Gateway is disabled. | ||
/// </summary> | ||
Disabled, | ||
|
||
/// <summary> | ||
/// The OAuth Gateway is enabled. | ||
/// </summary> | ||
Enabled, | ||
|
||
/// <summary> | ||
/// The provider may ONLY be used as an OAuth Gateway. | ||
/// </summary> | ||
Only, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Tgstation.Server.Host/Extensions/OAuthGatewayStatusExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
|
||
namespace Tgstation.Server.Host.Extensions | ||
{ | ||
/// <summary> | ||
/// Extension methods for <see cref="OAuthGatewayStatus"/>. | ||
/// </summary> | ||
static class OAuthGatewayStatusExtensions | ||
{ | ||
/// <summary> | ||
/// Convert a given <paramref name="oAuthGatewayStatus"/> to a <see cref="Nullable{T}"/> <see cref="bool"/> for API usage. | ||
/// </summary> | ||
/// <param name="oAuthGatewayStatus">The <see cref="OAuthGatewayStatus"/> to convert.</param> | ||
/// <returns>The <see cref="Nullable{T}"/> <see cref="bool"/> form of the <paramref name="oAuthGatewayStatus"/>.</returns> | ||
public static bool? ToBoolean(this OAuthGatewayStatus oAuthGatewayStatus) | ||
=> oAuthGatewayStatus switch | ||
{ | ||
OAuthGatewayStatus.Disabled => null, | ||
OAuthGatewayStatus.Enabled => false, | ||
OAuthGatewayStatus.Only => true, | ||
_ => throw new InvalidOperationException($"Invalid {nameof(OAuthGatewayStatus)}: {oAuthGatewayStatus}"), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Tgstation.Server.Host/GraphQL/Mutations/Payloads/OAuthGatewayLoginResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using HotChocolate; | ||
|
||
using Tgstation.Server.Api.Models.Response; | ||
using Tgstation.Server.Host.Models; | ||
|
||
namespace Tgstation.Server.Host.GraphQL.Mutations.Payloads | ||
{ | ||
/// <summary> | ||
/// Success result for an OAuth gateway login attempt. | ||
/// </summary> | ||
public sealed class OAuthGatewayLoginResult : ILegacyApiTransformable<OAuthGatewayResponse> | ||
{ | ||
/// <summary> | ||
/// The user's access token for the requested OAuth service. | ||
/// </summary> | ||
public required string AccessCode { get; init; } | ||
|
||
/// <inheritdoc /> | ||
[GraphQLIgnore] | ||
public OAuthGatewayResponse ToApi() | ||
=> new() | ||
{ | ||
AccessCode = AccessCode, | ||
}; | ||
} | ||
} |
Oops, something went wrong.