public async Task Invoke(HttpContext context) { if (!context.WebSockets.IsWebSocketRequest) { return; } BasicAuthenticator basicAuthn = new BasicAuthenticator(); SkunkLab.Security.Tokens.SecurityTokenType tokenType = Enum.Parse <SkunkLab.Security.Tokens.SecurityTokenType>(config.ClientTokenType, true); basicAuthn.Add(tokenType, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience, context); IAuthenticator authn = basicAuthn; WebSocket socket = await context.WebSockets.AcceptWebSocketAsync(); source = new CancellationTokenSource(); ProtocolAdapter adapter = ProtocolAdapterFactory.Create(config, graphManager, context, socket, logger, authn, source.Token); container.Add(adapter.Channel.Id, adapter); adapter.OnClose += Adapter_OnClose; adapter.OnError += Adapter_OnError; adapter.Init(); await adapter.Channel.OpenAsync(); await _next(context); Console.WriteLine("Exiting WS Invoke"); }
public ConnectController(PiraeusConfig config, IClusterClient client, ILogger logger) { this.config = config; BasicAuthenticator basicAuthn = new BasicAuthenticator(); SkunkLab.Security.Tokens.SecurityTokenType tokenType = Enum.Parse <SkunkLab.Security.Tokens.SecurityTokenType>(config.ClientTokenType, true); basicAuthn.Add(tokenType, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience); authn = basicAuthn; this.graphManager = new GraphManager(client); this.logger = logger; }
public ConnectController(PiraeusConfig config, IClusterClient client) { this.config = config; BasicAuthenticator basicAuthn = new BasicAuthenticator(); SkunkLab.Security.Tokens.SecurityTokenType tokenType = Enum.Parse<SkunkLab.Security.Tokens.SecurityTokenType>(config.ClientTokenType, true); basicAuthn.Add(tokenType, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience); authn = basicAuthn; if (!GraphManager.IsInitialized) { GraphManager.Initialize(client); } }
public async Task Invoke(HttpContext context) { if (!context.WebSockets.IsWebSocketRequest) { return; } BasicAuthenticator basicAuthn = new BasicAuthenticator(); SkunkLab.Security.Tokens.SecurityTokenType tokenType = Enum.Parse <SkunkLab.Security.Tokens.SecurityTokenType>(config.ClientTokenType, true); basicAuthn.Add(tokenType, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience, context); IAuthenticator authn = basicAuthn; socket = await context.WebSockets.AcceptWebSocketAsync(); source = new CancellationTokenSource(); //adapter = ProtocolAdapterFactory.Create(config, context, socket, authn, source.Token); adapter = ProtocolAdapterFactory.Create(config, context, socket, null, authn, source.Token); adapter.OnClose += Adapter_OnClose; adapter.OnError += Adapter_OnError; adapter.Init(); await adapter.Channel.OpenAsync(); //blocking until closed }