Client LuaCsForBarotrauma
Authenticator.cs
1 #nullable enable
2 using System.Collections.Generic;
3 using System.Collections.Immutable;
4 using System.Threading.Tasks;
5 using Barotrauma.Steam;
6 
7 namespace Barotrauma.Networking;
8 
9 abstract class Authenticator
10 {
11  public abstract Task<AccountInfo> VerifyTicket(AuthenticationTicket ticket);
12  public abstract void EndAuthSession(AccountId accountId);
13 
14  public static ImmutableDictionary<AuthenticationTicketKind, Authenticator> GetAuthenticatorsForHost(Option<Endpoint> ownerEndpointOption)
15  {
16  var authenticators = new Dictionary<AuthenticationTicketKind, Authenticator>();
17 
18  if (EosInterface.Core.IsInitialized)
19  {
20  // Every kind of host should be able to do EOS ID Token authentication if they have EOS enabled
21  authenticators.Add(AuthenticationTicketKind.EgsOwnershipToken, new EgsOwnershipTokenAuthenticator());
22 
23  if (ownerEndpointOption.TryUnwrap(out var ownerEndpoint) && ownerEndpoint is EosP2PEndpoint)
24  {
25  // EOS P2P hosts do not have access to Steamworks
26  authenticators.Add(AuthenticationTicketKind.SteamAuthTicketForEosHost, new SteamAuthTicketForEosHostAuthenticator());
27  }
28  }
29 
30  if (!(ownerEndpointOption.TryUnwrap(out var ownerEndpoint2) && ownerEndpoint2 is EosP2PEndpoint) && SteamManager.IsInitialized)
31  {
32  // Steam P2P hosts and dedicated servers have access to Steamworks
33  authenticators.Add(AuthenticationTicketKind.SteamAuthTicketForSteamHost, new SteamAuthTicketForSteamHostAuthenticator());
34  }
35 
36  return authenticators.ToImmutableDictionary();
37  }
38 }
abstract Task< AccountInfo > VerifyTicket(AuthenticationTicket ticket)
abstract void EndAuthSession(AccountId accountId)
static ImmutableDictionary< AuthenticationTicketKind, Authenticator > GetAuthenticatorsForHost(Option< Endpoint > ownerEndpointOption)