Try to fix boardcasting with Antigravity.
This commit is contained in:
@@ -50,25 +50,23 @@ public static class AuthHelper
|
||||
|
||||
public static bool IsServerTokenValid(HttpContext context, PeerCache peerCache)
|
||||
{
|
||||
var serverUrl = context.Request.Headers["X-Server-Url"].ToString().Trim().TrimEnd('/');
|
||||
var serverId = context.Request.Headers["X-Server-Id"].ToString().Trim();
|
||||
var serverToken = context.Request.Headers["X-Server-Token"].ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(serverUrl) || string.IsNullOrEmpty(serverToken))
|
||||
if (string.IsNullOrEmpty(serverId) || string.IsNullOrEmpty(serverToken))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. Verify if it's a handshaked downstream peer calling us (upstream verification)
|
||||
if (peerCache.VerifySessionToken(serverUrl, serverToken))
|
||||
if (peerCache.VerifySessionToken(serverId, serverToken))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. Verify if it's our configured upstream calling us (downstream verification)
|
||||
var configuration = context.RequestServices.GetRequiredService<IConfiguration>();
|
||||
var destUrl = (configuration["Sync:DestinationServerUrl"] ?? "").Trim().TrimEnd('/');
|
||||
|
||||
if (!string.IsNullOrEmpty(destUrl) && string.Equals(serverUrl, destUrl, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrEmpty(SyncEndpoints.UpstreamServerGuid) &&
|
||||
string.Equals(serverId, SyncEndpoints.UpstreamServerGuid, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// The request is coming from our upstream. Verify the token matches the one we received during handshake!
|
||||
if (!string.IsNullOrEmpty(SyncEndpoints.UpstreamSessionToken) &&
|
||||
|
||||
Reference in New Issue
Block a user