-
-
-
1445 logger.LogTrace(
"Starting HealthCheckLoop...");
-
-
-
1448 var nextForceHealthCheckTask = forceHealthCheckTcs!.Task;
-
1449 while (!cancellationToken.IsCancellationRequested)
-
-
-
1452 if (swarmController)
-
-
-
-
-
1457 if (lastControllerHealthCheck.HasValue)
-
-
1459 var recommendedTimeOfNextCheck = lastControllerHealthCheck.Value + delay;
-
-
1461 if (recommendedTimeOfNextCheck > DateTimeOffset.UtcNow)
-
1462 delay = recommendedTimeOfNextCheck - DateTimeOffset.UtcNow;
-
-
-
-
1466 var delayTask = asyncDelayer.Delay(
-
-
+
+
+
+
+
1433 HttpMethod httpMethod,
+
+
+
1436 Guid? registrationIdOverride =
null)
+
+
+
+
1440 Address = swarmConfiguration.ControllerAddress,
+
+
+
1443 var fullRoute = $
"{SwarmConstants.ControllerRoute}/{route}";
+
+
1445 "{method} {route} to swarm server {nodeIdOrAddress}",
+
+
+
+
+
1450 var request =
new HttpRequestMessage(
+
+
1452 swarmServer.
Address + fullRoute[1..]);
+
+
+
1455 request.Headers.Accept.Clear();
+
1456 request.Headers.Accept.Add(
new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));
+
+
+
1459 if (registrationIdOverride.HasValue)
+
+
1461 else if (swarmController)
+
+
1463 lock (swarmServers!)
+
1464 if (registrationIdsAndTimes!.TryGetValue(swarmServer.
Identifier!, out var registrationIdAndTime))
+
+
+
1467 else if (controllerRegistration.HasValue)
+
-
1470 var awakeningTask = Task.WhenAny(
-
-
1472 nextForceHealthCheckTask);
-
-
1474 await awakeningTask;
+
+
1471 request.Content =
new StringContent(
+
+
+
1474 MediaTypeNames.Application.Json);
-
1476 if (nextForceHealthCheckTask.IsCompleted && swarmController)
-
-
-
-
-
-
1482 else if (!swarmController && !nextForceHealthCheckTask.IsCompleted)
-
-
1484 if (!lastControllerHealthCheck.HasValue)
-
-
1486 logger.LogTrace(
"Not initially registered with controller, skipping health check.");
-
-
-
-
-
-
1492 logger.LogTrace(
"Controller seems to be active, skipping health check.");
-
-
-
-
-
1497 nextForceHealthCheckTask = forceHealthCheckTcs.Task;
-
-
1499 logger.LogTrace(
"Performing swarm health check...");
-
-
-
1502 if (swarmController)
-
1503 await HealthCheckNodes(cancellationToken);
-
-
1505 await HealthCheckController(cancellationToken);
-
-
1507 catch (
Exception ex) when (ex is not OperationCanceledException)
-
-
1509 logger.LogError(ex,
"Health check error!");
-
-
-
-
1513 catch (OperationCanceledException ex)
-
-
1515 logger.LogTrace(ex,
"Health check loop cancelled!");
-
-
-
1518 logger.LogTrace(
"Stopped HealthCheckLoop");
-
+
+
+
+
+
+
+
+
+
+
+
+
+
1492 logger.LogTrace(
"Starting HealthCheckLoop...");
+
+
+
1495 var nextForceHealthCheckTask = forceHealthCheckTcs!.Task;
+
1496 while (!cancellationToken.IsCancellationRequested)
+
+
+
1499 if (swarmController)
+
+
+
+
+
1504 if (lastControllerHealthCheck.HasValue)
+
+
1506 var recommendedTimeOfNextCheck = lastControllerHealthCheck.Value + delay;
+
+
1508 if (recommendedTimeOfNextCheck > DateTimeOffset.UtcNow)
+
1509 delay = recommendedTimeOfNextCheck - DateTimeOffset.UtcNow;
+
+
+
+
1513 var delayTask = asyncDelayer.Delay(
+
+
+
+
1517 var awakeningTask = Task.WhenAny(
+
+
1519 nextForceHealthCheckTask);
-
-
-
-
1528 if (!swarmController)
-
1529 throw new InvalidOperationException(
"NodeIdentifierFromRegistration on node!");
-
-
1531 lock (swarmServers!)
-
-
1533 var registrationIdsAndTimes = this.registrationIdsAndTimes!;
-
1534 var exists = registrationIdsAndTimes.Any(x => x.Value.RegistrationId == registrationId);
-
-
-
1537 logger.LogWarning(
"A node that was to be looked up ({registrationId}) disappeared from our records!", registrationId);
-
-
-
-
1541 return registrationIdsAndTimes.First(x => x.Value.RegistrationId == registrationId).Key;
-
-
+
1521 await awakeningTask;
+
+
1523 if (nextForceHealthCheckTask.IsCompleted && swarmController)
+
+
+
+
+
+
1529 else if (!swarmController && !nextForceHealthCheckTask.IsCompleted)
+
+
1531 if (!lastControllerHealthCheck.HasValue)
+
+
1533 logger.LogTrace(
"Not initially registered with controller, skipping health check.");
+
+
+
+
+
+
1539 logger.LogTrace(
"Controller seems to be active, skipping health check.");
+
+
+
+
+
1544 nextForceHealthCheckTask = forceHealthCheckTcs.Task;
+
+
1546 logger.LogTrace(
"Performing swarm health check...");
+
+
+
1549 if (swarmController)
+
1550 await HealthCheckNodes(cancellationToken);
+
+
1552 await HealthCheckController(cancellationToken);
+
+
1554 catch (
Exception ex) when (ex is not OperationCanceledException)
+
+
1556 logger.LogError(ex,
"Health check error!");
+
+
+
+
1560 catch (OperationCanceledException ex)
+
+
1562 logger.LogTrace(ex,
"Health check loop cancelled!");
+
+
+
1565 logger.LogTrace(
"Stopped HealthCheckLoop");
+
+
+
+
+
+
+
1575 if (!swarmController)
+
1576 throw new InvalidOperationException(
"NodeIdentifierFromRegistration on node!");
+
+
1578 lock (swarmServers!)
+
+
1580 var registrationIdsAndTimes = this.registrationIdsAndTimes!;
+
1581 var exists = registrationIdsAndTimes.Any(x => x.Value.RegistrationId == registrationId);
+
+
+
1584 logger.LogWarning(
"A node that was to be looked up ({registrationId}) disappeared from our records!", registrationId);
+
+
+
+
1588 return registrationIdsAndTimes.First(x => x.Value.RegistrationId == registrationId).Key;
+
+
-
+
-
+
@@ -1534,6 +1577,9 @@
Uri? ControllerAddress
The SwarmServer.Address of the swarm controller. If null, the current server is considered the contro...
override? Uri PublicAddress
A IFileStreamProvider that represents the response of HttpRequestMessages.
+
Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies ...
+
string RawSwarmProtocolVersion
The Version string of the MariaDB server bundled with TGS installs.
+
static MasterVersionsAttribute Instance
Return the Assembly's instance of the MasterVersionsAttribute.
Constants used by the swarm system.
const int ControllerHealthCheckIntervalMinutes
Interval at which the swarm controller makes health checks on nodes.
static JsonSerializerSettings SerializerSettings
See JsonSerializerSettings for the swarm system.
@@ -1545,57 +1591,59 @@
const int UpdateCommitTimeoutMinutes
Number of minutes the controller waits to receive a ready-commit from all nodes before aborting an up...
const int SecondsToDelayForcedHealthChecks
Number of seconds between a health check global::System.Threading.Tasks.TaskCompletionSource triggeri...
A request to register with a swarm controller.
+
Response for a SwarmRegistrationRequest.
A request to update a nodes list of SwarmServers.
-
Helps keep servers connected to the same database in sync by coordinating updates.
-
volatile? TaskCompletionSource forceHealthCheckTcs
A TaskCompletionSource that is used to force a health check.
-
HttpRequestMessage PrepareSwarmRequest(SwarmServerInformation? swarmServer, HttpMethod httpMethod, string route, object? body, Guid? registrationIdOverride=null)
Prepares a HttpRequestMessage for swarm communication.
-
async ValueTask< SwarmPrepareResult > ControllerDistributedPrepareUpdate(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, SwarmUpdateOperation currentUpdateOperation, CancellationToken cancellationToken)
Send a given updateRequest out to nodes from the swarm controller.
-
void UpdateSwarmServersList(IEnumerable< SwarmServerInformation > swarmServers)
Pass in an updated list of swarmServers to the node.
-
string? NodeIdentifierFromRegistration(Guid registrationId)
Gets the SwarmServer.Identifier from a given registrationId .
-
readonly bool swarmController
If the current server is the swarm controller.
-
async ValueTask UnregisterNode(Guid registrationId, CancellationToken cancellationToken)
Attempt to unregister a node with a given registrationId with the controller.A ValueTask representin...
-
bool ValidateRegistration(Guid registrationId)
Validate a given registrationId .true if the registration is valid, false otherwise.
-
readonly IFileTransferTicketProvider transferService
The IFileTransferTicketProvider for the SwarmService.
-
readonly? List< SwarmServerInformation > swarmServers
List<T> of connected SwarmServerInformations.
-
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for the SwarmService.
-
ValueTask RemoteAbortUpdate()
Sends out remote abort update requests.
-
async ValueTask< SwarmCommitResult > CommitUpdate(CancellationToken cancellationToken)
Signal to the swarm that an update is ready to be applied.A ValueTask<TResult> resulting in the Swarm...
-
bool SwarmMode
If the swarm system is enabled.
-
async ValueTask< bool > RemoteCommitReceived(Guid registrationId, CancellationToken cancellationToken)
Notify the controller that the node with the given registrationId is ready to commit or notify the n...
-
bool ExpectedNumberOfNodesConnected
Gets a value indicating if the expected amount of nodes are connected to the swarm.
-
async Task HealthCheckLoop(CancellationToken cancellationToken)
Timed loop for calling HealthCheckNodes(CancellationToken).
-
async ValueTask< SwarmPrepareResult > PrepareUpdateImpl(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, CancellationToken cancellationToken)
Implementation of PrepareUpdate(ISeekableFileStreamProvider, Version, CancellationToken),...
-
async ValueTask< SwarmRegistrationResult > RegisterWithController(CancellationToken cancellationToken)
Attempt to register the node with the controller.
-
async ValueTask Shutdown(CancellationToken cancellationToken)
Deregister with the swarm controller or put clients into querying state.A ValueTask representing the ...
-
async ValueTask< bool > RegisterNode(SwarmServer node, Guid registrationId, CancellationToken cancellationToken)
Attempt to register a given node with the controller.A ValueTask<TResult> resulting in true if the r...
-
readonly IDatabaseContextFactory databaseContextFactory
The IDatabaseContextFactory for the SwarmService.
-
async ValueTask HealthCheckController(CancellationToken cancellationToken)
Ping the swarm controller to see that it is still running. If need be, reregister.
-
SwarmService(IDatabaseContextFactory databaseContextFactory, IDatabaseSeeder databaseSeeder, IAssemblyInformationProvider assemblyInformationProvider, IAbstractHttpClientFactory httpClientFactory, IAsyncDelayer asyncDelayer, IServerUpdater serverUpdater, IFileTransferTicketProvider transferService, IOptions< SwarmConfiguration > swarmConfigurationOptions, ILogger< SwarmService > logger)
Initializes a new instance of the SwarmService class.
-
async ValueTask< bool > PrepareUpdateFromController(SwarmUpdateRequest updateRequest, CancellationToken cancellationToken)
Notify the node of an update request from the controller.A ValueTask<TResult> resulting in true if th...
-
readonly? CancellationTokenSource serverHealthCheckCancellationTokenSource
The CancellationTokenSource for serverHealthCheckTask.
-
async ValueTask< SwarmRegistrationResult > Initialize(CancellationToken cancellationToken)
Attempt to register with the swarm controller if not one, sets up the database otherwise....
-
RequestFileStreamProvider CreateUpdateStreamProvider(SwarmServerInformation sourceNode, FileTicketResponse ticket)
Create the RequestFileStreamProvider for an update package retrieval from a given sourceNode .
-
readonly IAbstractHttpClientFactory httpClientFactory
The IAbstractHttpClientFactory for the SwarmService.
-
async ValueTask SendUpdatedServerListToNodes(CancellationToken cancellationToken)
Sends the controllers list of nodes to all nodes.
-
readonly? Dictionary< string,(Guid RegistrationId, DateTimeOffset RegisteredAt)> registrationIdsAndTimes
Dictionary<TKey, TValue> of SwarmServer.Identifiers to registration Guids and when they were created.
-
ValueTask< SwarmPrepareResult > PrepareUpdate(ISeekableFileStreamProvider fileStreamProvider, Version version, CancellationToken cancellationToken)
Signal to the swarm that an update is requested.A ValueTask<TResult> resulting in true if the update ...
-
async ValueTask< Dictionary< string, FileTicketResponse > > CreateDownloadTickets(ISeekableFileStreamProvider initiatorProvider, IReadOnlyCollection< SwarmServerInformation > involvedServers, CancellationToken cancellationToken)
Create a FileTicketResponse for downloading the content of a given initiatorProvider for the rest of...
-
void MarkServersDirty()
Set serversDirty and complete the current forceHealthCheckTcs.
-
bool serversDirty
If the swarmServers list has been updated and needs to be resent to clients.
-
readonly ILogger< SwarmService > logger
The ILogger for the SwarmService.
-
readonly SwarmConfiguration swarmConfiguration
The SwarmConfiguration for the SwarmService.
-
List< SwarmServerInformation >? GetSwarmServers()
Gets the list of SwarmServerInformations in the swarm, including the current one.A List<T> of SwarmSe...
-
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the SwarmService.
-
Task? serverHealthCheckTask
The Task for the HealthCheckLoop(CancellationToken).
-
async ValueTask AbortUpdate()
Attempt to abort an uncommitted update.A ValueTask representing the running operation....
-
volatile? SwarmUpdateOperation updateOperation
A SwarmUpdateOperation that is currently in progress.
-
Guid? controllerRegistration
The registration Guid provided by the swarm controller.
-
DateTimeOffset? lastControllerHealthCheck
The last DateTimeOffset when the controller checked on this node.
-
readonly IServerUpdater serverUpdater
The IServerUpdater for the SwarmService.
-
readonly IDatabaseSeeder databaseSeeder
The IDatabaseSeeder for the SwarmService.
+
Helps keep servers connected to the same database in sync by coordinating updates.
+
volatile? TaskCompletionSource forceHealthCheckTcs
A TaskCompletionSource that is used to force a health check.
+
HttpRequestMessage PrepareSwarmRequest(SwarmServerInformation? swarmServer, HttpMethod httpMethod, string route, object? body, Guid? registrationIdOverride=null)
Prepares a HttpRequestMessage for swarm communication.
+
async ValueTask< SwarmPrepareResult > ControllerDistributedPrepareUpdate(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, SwarmUpdateOperation currentUpdateOperation, CancellationToken cancellationToken)
Send a given updateRequest out to nodes from the swarm controller.
+
void UpdateSwarmServersList(IEnumerable< SwarmServerInformation > swarmServers)
Pass in an updated list of swarmServers to the node.
+
string? NodeIdentifierFromRegistration(Guid registrationId)
Gets the SwarmServer.Identifier from a given registrationId .
+
readonly bool swarmController
If the current server is the swarm controller.
+
async ValueTask UnregisterNode(Guid registrationId, CancellationToken cancellationToken)
Attempt to unregister a node with a given registrationId with the controller.A ValueTask representin...
+
bool ValidateRegistration(Guid registrationId)
Validate a given registrationId .true if the registration is valid, false otherwise.
+
readonly IFileTransferTicketProvider transferService
The IFileTransferTicketProvider for the SwarmService.
+
readonly? List< SwarmServerInformation > swarmServers
List<T> of connected SwarmServerInformations.
+
readonly IAsyncDelayer asyncDelayer
The IAsyncDelayer for the SwarmService.
+
ValueTask RemoteAbortUpdate()
Sends out remote abort update requests.
+
async ValueTask< SwarmCommitResult > CommitUpdate(CancellationToken cancellationToken)
Signal to the swarm that an update is ready to be applied.A ValueTask<TResult> resulting in the Swarm...
+
bool SwarmMode
If the swarm system is enabled.
+
async ValueTask< bool > RemoteCommitReceived(Guid registrationId, CancellationToken cancellationToken)
Notify the controller that the node with the given registrationId is ready to commit or notify the n...
+
SwarmService(IDatabaseContextFactory databaseContextFactory, IDatabaseSeeder databaseSeeder, IAssemblyInformationProvider assemblyInformationProvider, IAbstractHttpClientFactory httpClientFactory, IAsyncDelayer asyncDelayer, IServerUpdater serverUpdater, IFileTransferTicketProvider transferService, ITokenFactory tokenFactory, IOptions< SwarmConfiguration > swarmConfigurationOptions, ILogger< SwarmService > logger)
Initializes a new instance of the SwarmService class.
+
async ValueTask< SwarmRegistrationResponse?> RegisterNode(SwarmServer node, Guid registrationId, CancellationToken cancellationToken)
Attempt to register a given node with the controller.A ValueTask<TResult> resulting in a SwarmRegist...
+
bool ExpectedNumberOfNodesConnected
Gets a value indicating if the expected amount of nodes are connected to the swarm.
+
async Task HealthCheckLoop(CancellationToken cancellationToken)
Timed loop for calling HealthCheckNodes(CancellationToken).
+
async ValueTask< SwarmPrepareResult > PrepareUpdateImpl(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, CancellationToken cancellationToken)
Implementation of PrepareUpdate(ISeekableFileStreamProvider, Version, CancellationToken),...
+
async ValueTask< SwarmRegistrationResult > RegisterWithController(CancellationToken cancellationToken)
Attempt to register the node with the controller.
+
async ValueTask Shutdown(CancellationToken cancellationToken)
Deregister with the swarm controller or put clients into querying state.A ValueTask representing the ...
+
readonly IDatabaseContextFactory databaseContextFactory
The IDatabaseContextFactory for the SwarmService.
+
async ValueTask HealthCheckController(CancellationToken cancellationToken)
Ping the swarm controller to see that it is still running. If need be, reregister.
+
readonly ITokenFactory tokenFactory
The ITokenFactory for the SwarmService.
+
async ValueTask< bool > PrepareUpdateFromController(SwarmUpdateRequest updateRequest, CancellationToken cancellationToken)
Notify the node of an update request from the controller.A ValueTask<TResult> resulting in true if th...
+
readonly? CancellationTokenSource serverHealthCheckCancellationTokenSource
The CancellationTokenSource for serverHealthCheckTask.
+
async ValueTask< SwarmRegistrationResult > Initialize(CancellationToken cancellationToken)
Attempt to register with the swarm controller if not one, sets up the database otherwise....
+
RequestFileStreamProvider CreateUpdateStreamProvider(SwarmServerInformation sourceNode, FileTicketResponse ticket)
Create the RequestFileStreamProvider for an update package retrieval from a given sourceNode .
+
readonly IAbstractHttpClientFactory httpClientFactory
The IAbstractHttpClientFactory for the SwarmService.
+
async ValueTask SendUpdatedServerListToNodes(CancellationToken cancellationToken)
Sends the controllers list of nodes to all nodes.
+
readonly? Dictionary< string,(Guid RegistrationId, DateTimeOffset RegisteredAt)> registrationIdsAndTimes
Dictionary<TKey, TValue> of SwarmServer.Identifiers to registration Guids and when they were created.
+
ValueTask< SwarmPrepareResult > PrepareUpdate(ISeekableFileStreamProvider fileStreamProvider, Version version, CancellationToken cancellationToken)
Signal to the swarm that an update is requested.A ValueTask<TResult> resulting in true if the update ...
+
async ValueTask< Dictionary< string, FileTicketResponse > > CreateDownloadTickets(ISeekableFileStreamProvider initiatorProvider, IReadOnlyCollection< SwarmServerInformation > involvedServers, CancellationToken cancellationToken)
Create a FileTicketResponse for downloading the content of a given initiatorProvider for the rest of...
+
void MarkServersDirty()
Set serversDirty and complete the current forceHealthCheckTcs.
+
bool serversDirty
If the swarmServers list has been updated and needs to be resent to clients.
+
readonly ILogger< SwarmService > logger
The ILogger for the SwarmService.
+
readonly SwarmConfiguration swarmConfiguration
The SwarmConfiguration for the SwarmService.
+
List< SwarmServerInformation >? GetSwarmServers()
Gets the list of SwarmServerInformations in the swarm, including the current one.A List<T> of SwarmSe...
+
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the SwarmService.
+
Task? serverHealthCheckTask
The Task for the HealthCheckLoop(CancellationToken).
+
async ValueTask AbortUpdate()
Attempt to abort an uncommitted update.A ValueTask representing the running operation....
+
volatile? SwarmUpdateOperation updateOperation
A SwarmUpdateOperation that is currently in progress.
+
Guid? controllerRegistration
The registration Guid provided by the swarm controller.
+
DateTimeOffset? lastControllerHealthCheck
The last DateTimeOffset when the controller checked on this node.
+
readonly IServerUpdater serverUpdater
The IServerUpdater for the SwarmService.
+
readonly IDatabaseSeeder databaseSeeder
The IDatabaseSeeder for the SwarmService.
-
bool TriggerHealthCheck()
Complete the current forceHealthCheckTcs.
-
async ValueTask HealthCheckNodes(CancellationToken cancellationToken)
Ping each node to see that they are still running.
+
bool TriggerHealthCheck()
Complete the current forceHealthCheckTcs.
+
async ValueTask HealthCheckNodes(CancellationToken cancellationToken)
Ping each node to see that they are still running.
Represents the state of a distributed swarm update.
Version TargetVersion
The Version being updated to.
IReadOnlyList< SwarmServerInformation > InvolvedServers
All of the SwarmServers that are involved in the updates.
@@ -1618,6 +1666,8 @@
IFileStreamProvider that provides MemoryStreams.
bool Disposed
If the ISeekableFileStreamProvider has had global::System.IAsyncDisposable.DisposeAsync called on it.
ValueTask< MemoryStream > GetOwnedResult(CancellationToken cancellationToken)
Gets the provided MemoryStream. May be called multiple times, though cancelling any may cause all cal...
+
For creating TokenResponses.
+
ReadOnlySpan< byte > SigningKeyBytes
Gets or sets the ITokenFactory's signing key bytes.
Swarm service operations for the Controllers.SwarmController.
Start and stop controllers for a swarm service.
Used for swarm operations. Functions may be no-op based on configuration.
@@ -1635,6 +1685,8 @@
ServerUpdateResult
The result of a call to start a server update.
+
+
SwarmUpdateAbortResult
Result of attempting to abort a SwarmUpdateOperation.
SwarmCommitResult
How to proceed on the commit step of an update.
diff --git a/_token_factory_8cs_source.html b/_token_factory_8cs_source.html
index 3b1d36a201..c5366010a3 100644
--- a/_token_factory_8cs_source.html
+++ b/_token_factory_8cs_source.html
@@ -84,124 +84,140 @@
Go to the documentation of this file.
2using System.Collections.Generic;
-
3using System.Globalization;
-
4using System.IdentityModel.Tokens.Jwt;
-
-
6using System.Security.Claims;
-
-
8using Microsoft.Extensions.Options;
-
9using Microsoft.IdentityModel.Tokens;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
48 IOptions<SecurityConfiguration> securityConfigurationOptions)
-
-
50 ArgumentNullException.ThrowIfNull(cryptographySuite);
-
51 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
-
-
53 securityConfiguration = securityConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(securityConfigurationOptions));
-
-
-
-
-
-
-
-
61 ValidateIssuerSigningKey =
true,
-
62 IssuerSigningKey =
new SymmetricSecurityKey(signingKeyBytes),
-
-
64 ValidateIssuer =
true,
-
65 ValidIssuer = assemblyInformationProvider.
AssemblyName.Name,
-
-
67 ValidateLifetime =
true,
-
68 ValidateAudience =
true,
-
69 ValidAudience = typeof(
TokenResponse).Assembly.GetName().Name,
-
-
-
-
73 RequireSignedTokens =
true,
+
3using System.Diagnostics.CodeAnalysis;
+
4using System.Globalization;
+
5using System.IdentityModel.Tokens.Jwt;
+
+
7using System.Security.Claims;
+
+
9using Microsoft.Extensions.Options;
+
10using Microsoft.IdentityModel.Tokens;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
33 signingKey =
new SymmetricSecurityKey(value.ToArray());
+
+
35 new SigningCredentials(
+
+
37 SecurityAlgorithms.HmacSha256));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
70 IOptions<SecurityConfiguration> securityConfigurationOptions)
+
+
72 ArgumentNullException.ThrowIfNull(cryptographySuite);
+
73 ArgumentNullException.ThrowIfNull(assemblyInformationProvider);
-
75 RequireExpirationTime =
true,
-
-
-
-
79 new SigningCredentials(
-
-
81 SecurityAlgorithms.HmacSha256));
-
-
+
75 securityConfiguration = securityConfigurationOptions?.Value ??
throw new ArgumentNullException(nameof(securityConfigurationOptions));
+
+
+
+
+
+
+
+
83 ValidateIssuerSigningKey =
true,
+
84 IssuerSigningKeyResolver = (_, _, _, _) => Enumerable.Repeat(
signingKey, 1),
+
+
86 ValidateIssuer =
true,
+
87 ValidIssuer = assemblyInformationProvider.
AssemblyName.Name,
+
+
89 ValidateLifetime =
true,
+
90 ValidateAudience =
true,
+
91 ValidAudience = typeof(
TokenResponse).Assembly.GetName().Name,
+
+
+
+
95 RequireSignedTokens =
true,
+
+
97 RequireExpirationTime =
true,
+
+
+
+
-
-
-
-
-
88 ArgumentNullException.ThrowIfNull(user);
-
-
90 var uid = user.Require(x => x.Id);
-
91 var now = DateTimeOffset.UtcNow;
-
92 var nowUnix = now.ToUnixTimeSeconds();
-
-
-
-
-
-
-
-
100 DateTimeOffset notBefore;
-
101 if (nowUnix == userLastPassworUpdateUnix)
-
102 notBefore = now.AddSeconds(1);
-
-
-
-
106 var expiry = now.AddMinutes(oAuth
-
-
-
-
110 var securityToken =
new JwtSecurityToken(
-
-
-
-
-
115 Enumerable.Empty<Claim>(),
-
116 new Dictionary<string, object>
-
-
118 { JwtRegisteredClaimNames.Sub, uid.ToString(CultureInfo.InvariantCulture) },
-
-
120 notBefore.UtcDateTime,
-
-
+
+
+
+
+
106 ArgumentNullException.ThrowIfNull(user);
+
+
108 var uid = user.Require(x => x.Id);
+
109 var now = DateTimeOffset.UtcNow;
+
110 var nowUnix = now.ToUnixTimeSeconds();
+
+
+
+
+
+
+
+
118 DateTimeOffset notBefore;
+
119 if (nowUnix == userLastPassworUpdateUnix)
+
120 notBefore = now.AddSeconds(1);
+
+
-
-
-
-
-
-
129 return tokenResponse;
-
+
124 var expiry = now.AddMinutes(oAuth
+
+
+
+
128 var securityToken =
new JwtSecurityToken(
+
+
+
+
+
133 Enumerable.Empty<Claim>(),
+
134 new Dictionary<string, object>
+
+
136 { JwtRegisteredClaimNames.Sub, uid.ToString(CultureInfo.InvariantCulture) },
+
+
138 notBefore.UtcDateTime,
+
+
+
+
+
+
+
+
+
147 return tokenResponse;
+
-
+
-
+
Represents a JWT returned by the API.
Configuration options pertaining to user security.
uint TokenSigningKeyByteCount
Amount of bytes to use in the Microsoft.IdentityModel.Tokens.TokenValidationParameters....
@@ -211,16 +227,18 @@
uint TokenExpiryMinutes
Amount of minutes until Api.Models.Response.TokenResponses generated from passwords expire.
DateTimeOffset? LastPasswordUpdate
When PasswordHash was last changed.
-
-
TokenValidationParameters ValidationParameters
The TokenValidationParameters for the ITokenFactory.
-
readonly JwtHeader tokenHeader
The JwtHeader for generating tokens.
-
readonly JwtSecurityTokenHandler tokenHandler
The JwtSecurityTokenHandler used to generate TokenResponse.Bearer strings.
-
readonly SecurityConfiguration securityConfiguration
The SecurityConfiguration for the TokenFactory.
-
TokenFactory(ICryptographySuite cryptographySuite, IAssemblyInformationProvider assemblyInformationProvider, IOptions< SecurityConfiguration > securityConfigurationOptions)
Initializes a new instance of the TokenFactory class.
-
TokenResponse CreateToken(User user, bool oAuth)
Create a TokenResponse for a given user .A new TokenResponse.
+
+
SymmetricSecurityKey signingKey
Backing field for SigningKeyBytes.
+
TokenValidationParameters ValidationParameters
The TokenValidationParameters for the ITokenFactory.
+
ReadOnlySpan< byte > SigningKeyBytes
Gets or sets the ITokenFactory's signing key bytes.
+
readonly JwtSecurityTokenHandler tokenHandler
The JwtSecurityTokenHandler used to generate TokenResponse.Bearer strings.
+
readonly SecurityConfiguration securityConfiguration
The SecurityConfiguration for the TokenFactory.
+
TokenFactory(ICryptographySuite cryptographySuite, IAssemblyInformationProvider assemblyInformationProvider, IOptions< SecurityConfiguration > securityConfigurationOptions)
Initializes a new instance of the TokenFactory class.
+
TokenResponse CreateToken(User user, bool oAuth)
Create a TokenResponse for a given user .A new TokenResponse.
+
JwtHeader tokenHeader
The JwtHeader for generating tokens.
Contains various cryptographic functions.
byte[] GetSecureBytes(uint amount)
Generates a secure set of bytes.
-
For creating TokenResponses.
+
For creating TokenResponses.
diff --git a/_web_host_builder_extensions_8cs_source.html b/_web_host_builder_extensions_8cs_source.html
index 8320c888aa..efdb173dbd 100644
--- a/_web_host_builder_extensions_8cs_source.html
+++ b/_web_host_builder_extensions_8cs_source.html
@@ -150,7 +150,7 @@
Represents a service that may take an updated Host assembly and run it, stopping the current assembly...
Provides access to the server's HttpApiPort.
Interface for using filesystems.
-
For creating TokenResponses.
+
For creating TokenResponses.
Set of objects needed to configure an Core.Application.
diff --git a/annotated.html b/annotated.html
index 5fcea83066..9e201ccbcd 100644
--- a/annotated.html
+++ b/annotated.html
@@ -818,10 +818,11 @@
CISwarmUpdateAborter | Allows aborting a swarm distributed update operation |
CSwarmConstants | Constants used by the swarm system |
CSwarmRegistrationRequest | A request to register with a swarm controller |
-
CSwarmServersUpdateRequest | A request to update a nodes list of SwarmServers |
-
CSwarmService | Helps keep servers connected to the same database in sync by coordinating updates |
-
CSwarmUpdateOperation | Represents the state of a distributed swarm update |
-
CSwarmUpdateRequest | A request to update the swarm's TGS version |
+
CSwarmRegistrationResponse | Response for a SwarmRegistrationRequest |
+
CSwarmServersUpdateRequest | A request to update a nodes list of SwarmServers |
+
CSwarmService | Helps keep servers connected to the same database in sync by coordinating updates |
+
CSwarmUpdateOperation | Represents the state of a distributed swarm update |
+
CSwarmUpdateRequest | A request to update the swarm's TGS version |
►NSystem | |
CAssemblyInformationProvider | |
CDotnetDumpService | |
diff --git a/changelog.yml b/changelog.yml
index fb8bb4904d..6d1e2d3970 100644
--- a/changelog.yml
+++ b/changelog.yml
@@ -158,8 +158,22 @@ Components:
PullRequest: 1070
Core:
- Version: 6.11.0
- ComponentVersions: {}
- Changes: []
+ ComponentVersions:
+ HttpApi: 10.9.0
+ DreamMakerApi: 7.3.0
+ Configuration: 5.2.0
+ InteropApi: 5.10.0
+ HostWatchdog: 1.5.0
+ NugetCommon: 7.0.0
+ NugetApi: 15.0.0
+ NugetClient: 18.0.0
+ WebControlPanel: 6.2.0
+ Changes:
+ - Descriptions:
+ - Swarm server nodes now inherit the token signing key of the controller, meaning that an authentication token generated on one server will work for all servers in the swarm. This behavior occurs for all swarm nodes regardless of `Security` configuration settings.
+ - The swarm protocol is now versioned separately from the TGS core version. This allows for slightly differing servers to group together in a swarm. Updates will still synchronize all servers to the same version. **It is still recommended that all servers in the swarm run the same TGS version.**
+ Author: Cyberboss
+ PullRequest: 1929
Unreleased: true
- Version: 6.10.1
ComponentVersions: {}
@@ -4631,27 +4645,6 @@ Components:
Author: Cyberboss
PullRequest: 1636
NugetApi:
- - Version: 15.0.0
- Changes:
- - Descriptions:
- - '**BREAKING:** Moved `RepositorySettings` out of `Internal` namespace and made abstract.'
- - Added TGS encoded app private key prefix to `RepositorySettings`.
- - Added `DreamDaemonApiBase.LaunchTime`.
- - Added `DreamDaemonApiBase.ClientCount`.
- Author: Cyberboss
- PullRequest: 1920
- - Descriptions:
- - Added `Tgstation.Server.Api.Models.DMApiValidationMode`.
- - Added `DreamMakerSettings.DMApiValidationMode`.
- - '**Deprecation:** Make `DreamMakerSettings.RequireDMApiValidation` obsolete. Use `DreamMakerSettings.DMApiValidationMode` instead.'
- Author: Cyberboss
- PullRequest: 1923
- - Descriptions:
- - '**BREAKING**: Reorganized the internal structure of several classes. Sum of parts remains unchanged.'
- - '**BREAKING**: `SwarmServerResponse` can no longer be constructed directly. Instantiate one of its child classes instead.'
- Author: Cyberboss
- PullRequest: 1924
- Unreleased: true
- Version: 13.5.0
Changes:
- Descriptions:
@@ -4735,20 +4728,4 @@ Components:
- Made `DiscordConnectionStringBuilder.BasedMeme` obsolete.
Author: Cyberboss
PullRequest: 1629
- NugetClient:
- - Version: 18.0.0
- Changes:
- - Descriptions:
- - '**BREAKING:** Updated API definitions library to 14.0.0.'
- Author: Cyberboss
- PullRequest: 1920
- - Descriptions:
- - Updated `Tgstation.Server.Api` dependency to 14.1.0 for TGS API version 10.9.0.
- Author: Cyberboss
- PullRequest: 1923
- - Descriptions:
- - '**BREAKING**: Renamed types similar to "ServerClient" to "RestServerClient"'
- - Added `ITransferClient` and `IRestServerClient.Transfer` to access the underlying raw file transfer API.
- Author: Cyberboss
- PullRequest: 1924
- Unreleased: true
+ NugetClient: []
diff --git a/class_tgstation_1_1_server_1_1_api_1_1_models_1_1_internal_1_1_swarm_server.html b/class_tgstation_1_1_server_1_1_api_1_1_models_1_1_internal_1_1_swarm_server.html
index 8a87cc3b0a..ff2d253240 100644
--- a/class_tgstation_1_1_server_1_1_api_1_1_models_1_1_internal_1_1_swarm_server.html
+++ b/class_tgstation_1_1_server_1_1_api_1_1_models_1_1_internal_1_1_swarm_server.html
@@ -274,7 +274,7 @@
@@ -303,7 +303,7 @@
@@ -332,7 +332,7 @@
diff --git a/class_tgstation_1_1_server_1_1_common_1_1_extensions_1_1_value_task_extensions.html b/class_tgstation_1_1_server_1_1_common_1_1_extensions_1_1_value_task_extensions.html
index b02be95352..9bde79d822 100644
--- a/class_tgstation_1_1_server_1_1_common_1_1_extensions_1_1_value_task_extensions.html
+++ b/class_tgstation_1_1_server_1_1_common_1_1_extensions_1_1_value_task_extensions.html
@@ -165,7 +165,7 @@