mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-04-21 21:50:31 +00:00
Phase 1.1: Generate authentication token in RuntimeController
- Add authenticationToken field to store GUID
- Generate secure token using Guid.NewGuid().ToString('N')
- Pass token to Electron via --authtoken command-line parameter
- Token is 32 hex characters with 128 bits of entropy
This commit is contained in:
@@ -31,6 +31,7 @@ namespace ElectronNET.AspNet.Runtime
|
||||
private int? port;
|
||||
private string actualUrl;
|
||||
private bool electronLaunched;
|
||||
private string authenticationToken;
|
||||
|
||||
public RuntimeControllerAspNetDotnetFirstSignalR(
|
||||
AspNetLifetimeAdapter aspNetLifetimeAdapter,
|
||||
@@ -108,9 +109,12 @@ namespace ElectronNET.AspNet.Runtime
|
||||
|
||||
private void LaunchElectron()
|
||||
{
|
||||
// Generate secure authentication token
|
||||
this.authenticationToken = Guid.NewGuid().ToString("N"); // 32 hex chars, no hyphens
|
||||
|
||||
var isUnPacked = ElectronNetRuntime.StartupMethod.IsUnpackaged();
|
||||
var flag = isUnPacked ? "--unpackeddotnetsignalr" : "--dotnetpackedsignalr";
|
||||
var args = $"{flag} --electronurl={this.actualUrl}";
|
||||
var args = $"{flag} --electronurl={this.actualUrl} --authtoken={this.authenticationToken}";
|
||||
|
||||
this.electronProcess = new ElectronProcessActive(isUnPacked, ElectronNetRuntime.ElectronExecutable, args, this.port.Value);
|
||||
// Note: We do NOT subscribe to electronProcess.Ready in SignalR mode.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using ElectronNET.API;
|
||||
using ElectronNET.API.Entities;
|
||||
using ElectronNET.Samples.BlazorSignalR.Components;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user