Поддержка телеграм авторизации.
This commit is contained in:
parent
7610f091c1
commit
b69da53ac3
15 changed files with 99 additions and 42 deletions
|
|
@ -51,7 +51,7 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
|||
[Dependency] private readonly ITaskManager _taskManager = default!;
|
||||
[Dependency] private readonly UserDbDataManager _userDbData = default!;
|
||||
|
||||
private IServerDiscordAuthManager? _discordAuth; // Sunrise-Edit
|
||||
private IServerServiceAuthManager? _serviceAuth; // Sunrise-Edit
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
public const string SawmillId = "admin.bans";
|
||||
|
|
@ -84,7 +84,7 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
|||
_cfg.OnValueChanged(SunriseCCVars.DiscordBanWebhook, OnWebhookChanged, true);
|
||||
_cfg.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
|
||||
|
||||
IoCManager.Instance!.TryResolveType(out _discordAuth);
|
||||
IoCManager.Instance!.TryResolveType(out _serviceAuth);
|
||||
// Sunrise-End
|
||||
}
|
||||
|
||||
|
|
@ -487,10 +487,10 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
|||
|
||||
string? adminDiscordId = null;
|
||||
string? targetDiscordId = null;
|
||||
if (_discordAuth != null)
|
||||
if (_serviceAuth != null)
|
||||
{
|
||||
adminDiscordId = await _discordAuth.GetDiscordUserId(banDef.BanningAdmin);
|
||||
targetDiscordId = await _discordAuth.GetDiscordUserId(banDef.UserId);
|
||||
adminDiscordId = await _serviceAuth.GetDiscordUserId(banDef.BanningAdmin);
|
||||
targetDiscordId = await _serviceAuth.GetDiscordUserId(banDef.UserId);
|
||||
}
|
||||
|
||||
var adminLink = "";
|
||||
|
|
@ -620,10 +620,10 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit
|
|||
|
||||
string? adminDiscordId = null;
|
||||
string? targetDiscordId = null;
|
||||
if (_discordAuth != null)
|
||||
if (_serviceAuth != null)
|
||||
{
|
||||
adminDiscordId = await _discordAuth.GetDiscordUserId(banDef.BanningAdmin);
|
||||
targetDiscordId = await _discordAuth.GetDiscordUserId(banDef.UserId);
|
||||
adminDiscordId = await _serviceAuth.GetDiscordUserId(banDef.BanningAdmin);
|
||||
targetDiscordId = await _serviceAuth.GetDiscordUserId(banDef.UserId);
|
||||
}
|
||||
|
||||
var adminLink = "";
|
||||
|
|
|
|||
|
|
@ -59,20 +59,23 @@ public sealed class SunriseCCVars
|
|||
CVarDef.Create("discord.ban_webhook", string.Empty, CVar.SERVERONLY);
|
||||
|
||||
/*
|
||||
* Discord Auth
|
||||
* Service Authorization
|
||||
*/
|
||||
|
||||
public static readonly CVarDef<bool> DiscordAuthEnabled =
|
||||
CVarDef.Create("discord_auth.enabled", false, CVar.SERVERONLY);
|
||||
public static readonly CVarDef<bool> ServiceAuthEnabled =
|
||||
CVarDef.Create("service_auth.enabled", false, CVar.SERVERONLY);
|
||||
|
||||
public static readonly CVarDef<string> DiscordAuthApiUrl =
|
||||
CVarDef.Create("discord_auth.api_url", "", CVar.SERVERONLY);
|
||||
public static readonly CVarDef<string> ServiceAuthApiUrl =
|
||||
CVarDef.Create("service_auth.api_url", "", CVar.SERVERONLY);
|
||||
|
||||
public static readonly CVarDef<string> DiscordAuthApiToken =
|
||||
CVarDef.Create("discord_auth.api_token", "", CVar.SERVERONLY | CVar.CONFIDENTIAL);
|
||||
public static readonly CVarDef<string> ServiceAuthApiToken =
|
||||
CVarDef.Create("service_auth.api_token", "", CVar.SERVERONLY | CVar.CONFIDENTIAL);
|
||||
|
||||
public static readonly CVarDef<bool> DiscordAuthCheckMember =
|
||||
CVarDef.Create("discord_auth.check_member", false, CVar.SERVERONLY);
|
||||
public static readonly CVarDef<bool> ServiceAuthCheckTelegramMember =
|
||||
CVarDef.Create("service_auth.check_telegram_member", false, CVar.SERVERONLY);
|
||||
|
||||
public static readonly CVarDef<bool> ServiceAuthCheckDiscordMember =
|
||||
CVarDef.Create("service_auth.check_discord_member", false, CVar.SERVERONLY);
|
||||
|
||||
/*
|
||||
* GodMode RoundEnd
|
||||
|
|
@ -164,12 +167,22 @@ public sealed class SunriseCCVars
|
|||
public static readonly CVarDef<bool> TapePlayerClientEnabled =
|
||||
CVarDef.Create("tape_player.client_enabled", true, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/*
|
||||
* INFOLINKS
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Link to boosty to show in the launcher.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> InfoLinksDonate =
|
||||
CVarDef.Create("infolinks.donate", "", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Link to Telegram channel to show in the launcher.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> InfoLinksTelegram =
|
||||
CVarDef.Create("infolinks.telegram", "", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/**
|
||||
* Lobby
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
queue-title = Очередь
|
||||
queue-quit = Выйти
|
||||
queue-position = Ваша позиция:
|
||||
queue-total = Всего в очереди:
|
||||
queue-priority-join = Приоритетный вход
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
service-auth-discord-title = Авторизация Discord
|
||||
service-auth-telegram-title = Авторизация Telegram
|
||||
service-auth-select-service-title = Выбор сервиса авторизации
|
||||
service-auth-select-service = Для доступа на сервер вам необходимо связать аккаунт SS14 c одним из сервисов.
|
||||
service-auth-warn1 = Советуем вам делать привязку на основной аккаунт.
|
||||
service-auth-warn2 = Будьте внимательны при выборе аккаунта.
|
||||
service-auth-browser-btn = Открыть в браузере
|
||||
service-auth-quit-btn = Выйти
|
||||
service-auth-qrcode = QrCode для сканирования на телефоне.
|
||||
service-auth-check-btn = Проверить
|
||||
service-auth-check-btn-wait = Ожидайте: { TOSTRING($time, "G3") }
|
||||
service-auth-switch-link-service = Выбрать другой сервис
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
service-check-member-title = Проверка членства в Discord
|
||||
service-check-member-info = Для доступа на сервер вам необходимо быть участником нашего Discord сервера.
|
||||
service-check-member-warn = Учтите что зайти на сервер нужно с того аккаунта на который вы делали подвязку.
|
||||
service-check-member-username = Ваш подвязаный аккаунт:
|
||||
service-check-member-browser-btn = Открыть в браузере
|
||||
service-check-member-quit-btn = Выйти
|
||||
service-check-member-qrcode = QrCode для сканирования на телефоне.
|
||||
service-check-member-check-btn = Проверить
|
||||
BIN
Resources/Textures/_Sunrise/ServiceAuth/discord_icon.png
Normal file
BIN
Resources/Textures/_Sunrise/ServiceAuth/discord_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
BIN
Resources/Textures/_Sunrise/ServiceAuth/telegram_icon.png
Normal file
BIN
Resources/Textures/_Sunrise/ServiceAuth/telegram_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
BIN
Resources/Textures/_Sunrise/test.png
Normal file
BIN
Resources/Textures/_Sunrise/test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 317 B |
|
|
@ -10,4 +10,7 @@
|
|||
</ProjectReference>
|
||||
<ProjectReference Include="..\Content.Sunrise.Interfaces.Shared\Content.Sunrise.Interfaces.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="IClientDiscordAuthManager.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
using Content.Sunrise.Interfaces.Shared;
|
||||
using Robust.Client.Graphics;
|
||||
|
||||
namespace Content.Sunrise.Interfaces.Client;
|
||||
|
||||
public interface IClientDiscordAuthManager : ISharedDiscordAuthManager
|
||||
{
|
||||
public string AuthUrl { get; }
|
||||
public Texture? Qrcode { get; }
|
||||
public string DiscordUrl { get; }
|
||||
public Texture? DiscordQrcode { get; }
|
||||
public string DiscordUsername { get; }
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using Content.Sunrise.Interfaces.Shared;
|
||||
using Robust.Client.Graphics;
|
||||
|
||||
namespace Content.Sunrise.Interfaces.Client;
|
||||
|
||||
public interface IClientServiceAuthManager : ISharedServiceAuthManager
|
||||
{
|
||||
public string ServiceJoinUrl { get; }
|
||||
public Texture? ServiceJoinQrcode { get; }
|
||||
public string ServiceUsername { get; }
|
||||
public List<ServiceAuthData> ServiceAuthDatas { get; set; }
|
||||
}
|
||||
|
|
@ -4,14 +4,12 @@ using Robust.Shared.Player;
|
|||
|
||||
namespace Content.Sunrise.Interfaces.Server;
|
||||
|
||||
public interface IServerDiscordAuthManager : ISharedDiscordAuthManager
|
||||
public interface IServerServiceAuthManager : ISharedServiceAuthManager
|
||||
{
|
||||
public event EventHandler<ICommonSession>? PlayerVerified;
|
||||
public Task<DiscordGenerateLinkResponse> GenerateAuthLink(NetUserId userId, string username, CancellationToken cancel);
|
||||
public Task<bool> IsVerified(NetUserId userId, CancellationToken cancel);
|
||||
public Task<ServiceAuthDataResponse> GenerateDiscordAuthData(NetUserId userId, CancellationToken cancel);
|
||||
public Task<ServiceAuthDataResponse> GenerateTelegramAuthData(NetUserId userId, CancellationToken cancel);
|
||||
public Task<List<ServiceType>> CheckLinkedServices(NetUserId userId, string username, CancellationToken cancel);
|
||||
public Task<string?> GetDiscordUserId(NetUserId? userId, CancellationToken cancel = default);
|
||||
|
||||
}
|
||||
|
||||
public sealed record DiscordLinkResponse(string Url, byte[] Qrcode);
|
||||
public sealed record DiscordGenerateLinkResponse(string Url, byte[] Qrcode);
|
||||
|
|
|
|||
|
|
@ -7,4 +7,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\RobustToolbox\Robust.Shared\Robust.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="ISharedDiscordAuthManager.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
namespace Content.Sunrise.Interfaces.Shared;
|
||||
|
||||
public interface ISharedDiscordAuthManager
|
||||
{
|
||||
public void Initialize();
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
namespace Content.Sunrise.Interfaces.Shared;
|
||||
|
||||
public interface ISharedServiceAuthManager
|
||||
{
|
||||
public void Initialize();
|
||||
}
|
||||
|
||||
public sealed record ServiceLinkResponse(string Url, byte[] Qrcode);
|
||||
public sealed record ServiceAuthDataResponse(string Url, byte[] Qrcode);
|
||||
|
||||
public enum ServiceType
|
||||
{
|
||||
Discord,
|
||||
Telegram
|
||||
}
|
||||
|
||||
public sealed class ServiceAuthData(string url, byte[] qrcode, ServiceType serviceType)
|
||||
{
|
||||
public string Url { get; set; } = url;
|
||||
public byte[] QrCode { get; set; } = qrcode;
|
||||
public ServiceType ServiceType { get; set; } = serviceType;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue