mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-09 18:27:36 +00:00
Adds dynamic OS-selected socket port handling and secured Electron/.NET communication. The dotnet-first startup flow now generates the auth token on the .NET side and passes it to Electron through an environment variable. Electron reports the selected socket port through a temporary startup-info file, avoiding any dependency on parsing Electron console output. Also avoids logging backend startup parameters because they include the auth token.
24 lines
972 B
C#
24 lines
972 B
C#
namespace ElectronNET.AspNet.Services
|
|
{
|
|
/// <summary>
|
|
/// Service for validating authentication tokens from Electron clients.
|
|
/// Used to ensure only the Electron process spawned by this .NET instance can connect.
|
|
/// </summary>
|
|
public interface IElectronAuthenticationService
|
|
{
|
|
/// <summary>
|
|
/// Sets the expected authentication token for this instance.
|
|
/// Should be called when launching Electron with the generated token.
|
|
/// </summary>
|
|
/// <param name="token">The authentication token</param>
|
|
void SetExpectedToken(string token);
|
|
|
|
/// <summary>
|
|
/// Validates an incoming token against the expected token.
|
|
/// Uses constant-time comparison to prevent timing attacks.
|
|
/// </summary>
|
|
/// <param name="token">The token to validate</param>
|
|
/// <returns>True if token is valid, false otherwise</returns>
|
|
bool ValidateToken(string token);
|
|
}
|
|
} |