aboutsummaryrefslogtreecommitdiff
path: root/Libs
diff options
context:
space:
mode:
Diffstat (limited to 'Libs')
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/AccessTokenEndpoint.cs2
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/RevocationEndpoint.cs4
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2AuthenticationPluginEntry.cs60
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2SessionProviderEntry.cs39
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.OAuth/OAuth2SessionProvider.cs9
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.OAuth/VNLib.Plugins.Essentials.Sessions.OAuth.csproj24
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VNLib.Plugins.Essentials.Sessions.Runtime.csproj24
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VnCacheClient.cs30
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.VNCache/VNLib.Plugins.Essentials.Sessions.VNCache.csproj32
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProviderEntry.cs8
-rw-r--r--Libs/VNLib.Plugins.Essentials.Sessions/VNLib.Plugins.Essentials.Sessions.Memory.csproj29
-rw-r--r--Libs/VNLib.Plugins.Sessions.Cache.Client/RemoteSession.cs2
-rw-r--r--Libs/VNLib.Plugins.Sessions.Cache.Client/SessionCacheClient.cs2
-rw-r--r--Libs/VNLib.Plugins.Sessions.Cache.Client/VNLib.Plugins.Sessions.Cache.Client.csproj18
14 files changed, 191 insertions, 92 deletions
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/AccessTokenEndpoint.cs b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/AccessTokenEndpoint.cs
index 5c09697..a159456 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/AccessTokenEndpoint.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/AccessTokenEndpoint.cs
@@ -49,7 +49,7 @@ namespace VNLib.Plugins.Essentials.Sessions.OAuth.Endpoints
{
private readonly CreateTokenImpl CreateToken;
- private readonly Applications Applications;
+ private readonly ApplicationStore Applications;
private readonly Task<JsonDocument?> JWTVerificationKey;
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/RevocationEndpoint.cs b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/RevocationEndpoint.cs
index 3c65056..d981f69 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/RevocationEndpoint.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/Endpoints/RevocationEndpoint.cs
@@ -34,13 +34,13 @@ namespace VNLib.Plugins.Essentials.Sessions.OAuth.Endpoints
/// An OAuth2 authorized endpoint for revoking the access token
/// held by the current connection
/// </summary>
- [ConfigurationName("oauth2")]
+ [ConfigurationName("o2_revocation_endpoint")]
internal class RevocationEndpoint : O2EndpointBase
{
public RevocationEndpoint(PluginBase pbase, IReadOnlyDictionary<string, JsonElement> config)
{
- string? path = config["revocation_path"].GetString();
+ string? path = config["path"].GetString();
InitPathAndLog(path, pbase.Log);
}
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2AuthenticationPluginEntry.cs b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2AuthenticationPluginEntry.cs
new file mode 100644
index 0000000..4a48f8b
--- /dev/null
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2AuthenticationPluginEntry.cs
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2022 Vaughn Nugent
+*
+* Library: VNLib
+* Package: VNLib.Plugins.Essentials.Sessions.OAuth
+* File: O2AuthenticationPluginEntry.cs
+*
+* O2AuthenticationPluginEntry.cs is part of VNLib.Plugins.Essentials.Sessions.OAuth which is part of the larger
+* VNLib collection of libraries and utilities.
+*
+* VNLib.Plugins.Essentials.Sessions.OAuth is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as
+* published by the Free Software Foundation, either version 3 of the
+* License, or (at your option) any later version.
+*
+* VNLib.Plugins.Essentials.Sessions.OAuth is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see https://www.gnu.org/licenses/.
+*/
+
+using VNLib.Utils.Logging;
+using VNLib.Plugins.Essentials.Sessions.Runtime;
+
+
+namespace VNLib.Plugins.Essentials.Sessions.Oauth
+{
+ public sealed class O2AuthenticationPluginEntry : PluginBase
+ {
+ public override string PluginName => "Essentials.Oauth.Authentication";
+
+ private readonly O2SessionProviderEntry SessionProvider = new();
+
+ protected override void OnLoad()
+ {
+ try
+ {
+ //Load the session provider, that will only load the endpoints
+ (SessionProvider as IRuntimeSessionProvider).Load(this, Log);
+ }
+ catch(KeyNotFoundException kne)
+ {
+ Log.Error("Missing required configuration keys {err}", kne.Message);
+ }
+ }
+
+ protected override void OnUnLoad()
+ {
+ Log.Information("Plugin unloaded");
+ }
+
+ protected override void ProcessHostCommand(string cmd)
+ {
+ throw new NotImplementedException();
+ }
+ }
+} \ No newline at end of file
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2SessionProviderEntry.cs b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2SessionProviderEntry.cs
index e7c7f29..07b6530 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2SessionProviderEntry.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/O2SessionProviderEntry.cs
@@ -27,6 +27,7 @@ using System.Text.Json;
using VNLib.Net.Http;
using VNLib.Utils.Logging;
using VNLib.Utils.Extensions;
+using VNLib.Plugins.Essentials.Oauth.Tokens;
using VNLib.Plugins.Essentials.Oauth.Applications;
using VNLib.Plugins.Essentials.Sessions.OAuth;
using VNLib.Plugins.Essentials.Sessions.OAuth.Endpoints;
@@ -35,10 +36,11 @@ using VNLib.Plugins.Extensions.Loading.Routing;
using VNLib.Plugins.Extensions.Loading.Sql;
using VNLib.Plugins.Extensions.Loading.Events;
using VNLib.Plugins.Essentials.Sessions.Runtime;
-using VNLib.Plugins.Essentials.Oauth.Tokens;
+using VNLib.Data.Caching.Extensions;
namespace VNLib.Plugins.Essentials.Sessions.Oauth
{
+
public sealed class O2SessionProviderEntry : IRuntimeSessionProvider
{
const string VNCACHE_CONFIG_KEY = "vncache";
@@ -49,7 +51,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Oauth
bool IRuntimeSessionProvider.CanProcess(IHttpEvent entity)
{
//If authorization header is set try to process as oauth2 session
- return entity.Server.Headers.HeaderSet(System.Net.HttpRequestHeader.Authorization);
+ return _sessions != null && entity.Server.Headers.HeaderSet(System.Net.HttpRequestHeader.Authorization);
}
ValueTask<SessionHandle> ISessionProvider.GetSessionAsync(IHttpEvent entity, CancellationToken cancellationToken)
@@ -65,23 +67,30 @@ namespace VNLib.Plugins.Essentials.Sessions.Oauth
IReadOnlyDictionary<string, JsonElement> oauth2Config = plugin.GetConfig(OAUTH2_CONFIG_KEY);
- string tokenEpPath = oauth2Config["token_path"].GetString() ?? throw new KeyNotFoundException($"Missing required 'token_path' in '{OAUTH2_CONFIG_KEY}' config");
-
//Optional application jwt token
Task<JsonDocument?> jwtTokenSecret = plugin.TryGetSecretAsync("application_token_key")
- .ContinueWith(static t => t.Result == null ? null : JsonDocument.Parse(t.Result));
+ .ContinueWith(static t => t.Result == null ? null : JsonDocument.Parse(t.Result), TaskScheduler.Default);
- //Init auth endpoint
- AccessTokenEndpoint authEp = new(tokenEpPath, plugin, CreateTokenDelegateAsync, jwtTokenSecret);
+ //Access token endpoint is optional
+ if (oauth2Config.TryGetValue("token_path", out JsonElement el))
+ {
+ //Init auth endpoint
+ AccessTokenEndpoint authEp = new(el.GetString()!, plugin, CreateTokenDelegateAsync, jwtTokenSecret);
- //route auth endpoint
- plugin.Route(authEp);
-
- //Route revocation endpoint
- plugin.Route<RevocationEndpoint>();
+ //route auth endpoint
+ plugin.Route(authEp);
+ }
+
+ //Optional revocation endpoint
+ if (plugin.HasConfigForType<RevocationEndpoint>())
+ {
+ //Route revocation endpoint
+ plugin.Route<RevocationEndpoint>();
+ }
//Run
- _ = CacheWokerDoWorkAsync(plugin, localized, cacheConfig, oauth2Config);
+ _ = plugin.DeferTask(() => CacheWokerDoWorkAsync(plugin, localized, cacheConfig, oauth2Config), 100);
+
}
private async Task<IOAuth2TokenResult?> CreateTokenDelegateAsync(HttpEntity entity, UserApplication app, CancellationToken cancellation)
@@ -133,6 +142,10 @@ namespace VNLib.Plugins.Essentials.Sessions.Oauth
{
localized.Error("Missing required configuration variable for VnCache client: {0}", e.Message);
}
+ catch(FBMServerNegiationException fne)
+ {
+ localized.Error("Failed to negotiate connection with cache server {reason}", fne.Message);
+ }
catch (Exception ex)
{
localized.Error(ex, "Cache client error occured in session provider");
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/OAuth2SessionProvider.cs b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/OAuth2SessionProvider.cs
index 5f9fc7e..d698c81 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/OAuth2SessionProvider.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/OAuth2SessionProvider.cs
@@ -27,6 +27,7 @@ using System.Net;
using Microsoft.EntityFrameworkCore;
+using VNLib.Net.Http;
using VNLib.Utils;
using VNLib.Utils.Logging;
using VNLib.Data.Caching;
@@ -37,8 +38,6 @@ using VNLib.Plugins.Essentials.Oauth;
using VNLib.Plugins.Essentials.Oauth.Tokens;
using VNLib.Plugins.Essentials.Oauth.Applications;
using VNLib.Plugins.Extensions.Loading.Events;
-using VNLib.Net.Http.Core;
-using VNLib.Net.Http;
namespace VNLib.Plugins.Essentials.Sessions.OAuth
{
@@ -200,8 +199,10 @@ namespace VNLib.Plugins.Essentials.Sessions.OAuth
{}
catch (Exception ex)
{
- errors ??= new();
- errors.Add(ex);
+ errors = new()
+ {
+ ex
+ };
}
}
if (errors?.Count > 0)
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/VNLib.Plugins.Essentials.Sessions.OAuth.csproj b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/VNLib.Plugins.Essentials.Sessions.OAuth.csproj
index 4cfcd86..d75a1c0 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/VNLib.Plugins.Essentials.Sessions.OAuth.csproj
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.OAuth/VNLib.Plugins.Essentials.Sessions.OAuth.csproj
@@ -4,20 +4,38 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
- <PlatformTarget>x64</PlatformTarget>
- <GenerateDocumentationFile>False</GenerateDocumentationFile>
+ <GenerateDocumentationFile>True</GenerateDocumentationFile>
<Authors>Vaughn Nugent</Authors>
<Copyright>Copyright © 2022 Vaughn Nugent</Copyright>
<EnableDynamicLoading>true</EnableDynamicLoading>
+ <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
+ <Version>1.0.1.1</Version>
+ <PackageProjectUrl>https://www.vaughnugent.com</PackageProjectUrl>
+ <AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+ <Deterministic>False</Deterministic>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <Deterministic>False</Deterministic>
+ </PropertyGroup>
+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="start xcopy &quot;$(TargetDir)&quot; &quot;F:\Programming\Web Plugins\DevPlugins\RuntimeAssets\$(TargetName)&quot; /E /Y /R" />
</Target>
-
+ <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
+ <Exec Command="erase &quot;F:\Programming\Web Plugins\DevPlugins\RuntimeAssets\$(TargetName)&quot; /q &gt; nul" />
+ </Target>
<ItemGroup>
+ <ProjectReference Include="..\..\..\..\VNLib\Http\VNLib.Net.Http.csproj" />
+ <ProjectReference Include="..\..\..\..\VNLib\Plugins\src\VNLib.Plugins.csproj" />
+ <ProjectReference Include="..\..\..\..\VNLib\Utils\src\VNLib.Utils.csproj" />
+ <ProjectReference Include="..\..\..\DataCaching\VNLib.Data.Caching.Extensions\VNLib.Data.Caching.Extensions.csproj" />
+ <ProjectReference Include="..\..\..\DataCaching\VNLib.Data.Caching\src\VNLib.Data.Caching.csproj" />
<ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Loading.Sql\VNLib.Plugins.Extensions.Loading.Sql.csproj" />
<ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Loading\VNLib.Plugins.Extensions.Loading.csproj" />
<ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Validation\VNLib.Plugins.Extensions.Validation.csproj" />
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VNLib.Plugins.Essentials.Sessions.Runtime.csproj b/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VNLib.Plugins.Essentials.Sessions.Runtime.csproj
index 5924b93..d72d6b9 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VNLib.Plugins.Essentials.Sessions.Runtime.csproj
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VNLib.Plugins.Essentials.Sessions.Runtime.csproj
@@ -4,29 +4,13 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
- <Platforms>AnyCPU;x64</Platforms>
<Authors>Vaughn Nugent</Authors>
<Copyright>Copyright © 2022 Vaughn Nugent</Copyright>
- <Version>1.0.0.1</Version>
- <PlatformTarget>x64</PlatformTarget>
+ <Version>1.0.1.1</Version>
<SignAssembly>False</SignAssembly>
- <PackageProjectUrl>www.vaughnnugent.com/resources</PackageProjectUrl>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
- <Deterministic>True</Deterministic>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Deterministic>True</Deterministic>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
- <Deterministic>False</Deterministic>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Deterministic>False</Deterministic>
+ <PackageProjectUrl>https://www.vaughnnugent.com/resources</PackageProjectUrl>
+ <GenerateDocumentationFile>True</GenerateDocumentationFile>
+ <AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VnCacheClient.cs b/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VnCacheClient.cs
index fd14098..3b348d2 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VnCacheClient.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.Runtime/VnCacheClient.cs
@@ -81,6 +81,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Runtime
/// Loads required configuration variables from the config store and
/// intializes the interal client
/// </summary>
+ /// <param name="pbase"></param>
/// <param name="config">A dictionary of configuration varables</param>
/// <exception cref="KeyNotFoundException"></exception>
public async Task LoadConfigAsync(PluginBase pbase, IReadOnlyDictionary<string, JsonElement> config)
@@ -107,10 +108,11 @@ namespace VNLib.Plugins.Essentials.Sessions.Runtime
_client = new(conf);
//Add the configuration
- _client.UseBroker(brokerUri)
- .ImportBrokerPublicKey(brokerPub)
- .ImportClientPrivateKey(privKey)
- .UseTls(brokerUri.Scheme == Uri.UriSchemeHttps);
+ _client.GetCacheConfiguration()
+ .WithBroker(brokerUri)
+ .ImportVerificationKey(brokerPub)
+ .ImportSigningKey(privKey)
+ .WithTls(brokerUri.Scheme == Uri.UriSchemeHttps);
//Zero the key memory
Memory.InitializeBlock(privKey.AsSpan());
@@ -139,7 +141,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Runtime
{
Log.Debug("Discovering cluster nodes in broker");
//Get server list
- servers = await Resource.DiscoverNodesAsync(cancellationToken);
+ servers = await Resource.DiscoverCacheNodesAsync(cancellationToken);
break;
}
catch (HttpRequestException re) when (re.InnerException is SocketException)
@@ -150,6 +152,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Runtime
{
Log.Warn("Failed to get server list from broker, reason {r}", ex.Message);
}
+
//Gen random ms delay
int randomMsDelay = RandomNumberGenerator.GetInt32(1000, 2000);
await Task.Delay(randomMsDelay, cancellationToken);
@@ -160,13 +163,18 @@ namespace VNLib.Plugins.Essentials.Sessions.Runtime
await Task.Delay(RetryInterval, cancellationToken);
continue;
}
- //select random server from the list of servers
- ActiveServer selected = servers!.SelectRandom();
+
try
{
- Log.Debug("Connecting to server {server}", selected.ServerId);
- //Try to connect to server
- await Resource.ConnectAndWaitForExitAsync(selected, cancellationToken);
+ Log.Debug("Connecting to random cache server");
+
+ //Connect to a random server
+ ActiveServer selected = await Resource.ConnectToRandomCacheAsync(cancellationToken);
+ Log.Debug("Connected to cache server {s}", selected.ServerId);
+
+ //Wait for disconnect
+ await Resource.WaitForExitAsync(cancellationToken);
+
Log.Debug("Cache server disconnected");
}
catch (WebSocketException wse)
@@ -176,7 +184,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Runtime
}
catch (HttpRequestException he) when (he.InnerException is SocketException)
{
- Log.Debug("Failed to connect to recommended server {server}", selected.ServerId);
+ Log.Debug("Failed to connect to random cache server server");
//Continue next loop
continue;
}
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/VNLib.Plugins.Essentials.Sessions.VNCache.csproj b/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/VNLib.Plugins.Essentials.Sessions.VNCache.csproj
index 25b5223..8c3e23a 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/VNLib.Plugins.Essentials.Sessions.VNCache.csproj
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/VNLib.Plugins.Essentials.Sessions.VNCache.csproj
@@ -4,31 +4,16 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
- <Platforms>AnyCPU;x64</Platforms>
<Authors>Vaughn Nugent</Authors>
<Copyright>Copyright © 2022 Vaughn Nugent</Copyright>
- <Version>1.0.0.1</Version>
- <PlatformTarget>x64</PlatformTarget>
+ <Version>1.0.1.1</Version>
<SignAssembly>False</SignAssembly>
- <PackageProjectUrl>www.vaughnnugent.com/resources</PackageProjectUrl>
+ <PackageProjectUrl>https://www.vaughnnugent.com/resources</PackageProjectUrl>
<EnableDynamicLoading>true</EnableDynamicLoading>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
- <Deterministic>True</Deterministic>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Deterministic>True</Deterministic>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
- <Deterministic>False</Deterministic>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Deterministic>False</Deterministic>
+ <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
+ <GenerateDocumentationFile>True</GenerateDocumentationFile>
+ <AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
@@ -37,6 +22,9 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\VNLib\Http\VNLib.Net.Http.csproj" />
+ <ProjectReference Include="..\..\..\..\VNLib\Utils\src\VNLib.Utils.csproj" />
+ <ProjectReference Include="..\..\..\DataCaching\VNLib.Data.Caching.Extensions\VNLib.Data.Caching.Extensions.csproj" />
+ <ProjectReference Include="..\..\..\DataCaching\VNLib.Data.Caching\src\VNLib.Data.Caching.csproj" />
<ProjectReference Include="..\..\..\Extensions\VNLib.Plugins.Extensions.Loading\VNLib.Plugins.Extensions.Loading.csproj" />
<ProjectReference Include="..\..\..\PluginBase\VNLib.Plugins.PluginBase.csproj" />
<ProjectReference Include="..\VNLib.Plugins.Essentials.Sessions.Runtime\VNLib.Plugins.Essentials.Sessions.Runtime.csproj" />
@@ -46,5 +34,9 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="start xcopy &quot;$(TargetDir)&quot; &quot;F:\Programming\Web Plugins\DevPlugins\RuntimeAssets\$(TargetName)&quot; /E /Y /R" />
</Target>
+
+ <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
+ <Exec Command="erase &quot;F:\Programming\Web Plugins\DevPlugins\RuntimeAssets\$(TargetName)&quot; /q &gt; nul" />
+ </Target>
</Project>
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProviderEntry.cs b/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProviderEntry.cs
index cf46c2b..382717b 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProviderEntry.cs
+++ b/Libs/VNLib.Plugins.Essentials.Sessions.VNCache/WebSessionProviderEntry.cs
@@ -30,6 +30,7 @@ using VNLib.Utils.Logging;
using VNLib.Utils.Extensions;
using VNLib.Plugins.Extensions.Loading;
using VNLib.Plugins.Essentials.Sessions.Runtime;
+using VNLib.Data.Caching.Extensions;
namespace VNLib.Plugins.Essentials.Sessions.VNCache
{
@@ -63,12 +64,11 @@ namespace VNLib.Plugins.Essentials.Sessions.VNCache
string cachePrefix = webSessionConfig["cache_prefix"].GetString() ?? throw new KeyNotFoundException($"Missing required element 'cache_prefix' for config '{WEB_SESSION_CONFIG}'");
TimeSpan validFor = webSessionConfig["valid_for_sec"].GetTimeSpan(TimeParseType.Seconds);
-
//Init id factory
WebSessionIdFactoryImpl idFactory = new(cookieSize, cookieName, cachePrefix, validFor);
//Run client connection
- _ = WokerDoWorkAsync(plugin, localized, idFactory, cacheConfig, webSessionConfig);
+ _ = plugin.DeferTask(() => WokerDoWorkAsync(plugin, localized, idFactory, cacheConfig, webSessionConfig));
}
@@ -110,6 +110,10 @@ namespace VNLib.Plugins.Essentials.Sessions.VNCache
{
localized.Error("Missing required configuration variable for VnCache client: {0}", e.Message);
}
+ catch (FBMServerNegiationException fne)
+ {
+ localized.Error("Failed to negotiate connection with cache server {reason}", fne.Message);
+ }
catch (Exception ex)
{
localized.Error(ex, "Cache client error occured in session provider");
diff --git a/Libs/VNLib.Plugins.Essentials.Sessions/VNLib.Plugins.Essentials.Sessions.Memory.csproj b/Libs/VNLib.Plugins.Essentials.Sessions/VNLib.Plugins.Essentials.Sessions.Memory.csproj
index ca90155..0d3cb40 100644
--- a/Libs/VNLib.Plugins.Essentials.Sessions/VNLib.Plugins.Essentials.Sessions.Memory.csproj
+++ b/Libs/VNLib.Plugins.Essentials.Sessions/VNLib.Plugins.Essentials.Sessions.Memory.csproj
@@ -2,23 +2,28 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
- <Platforms>AnyCPU;x64</Platforms>
-
- <EnableDynamicLoading>true</EnableDynamicLoading>
- </PropertyGroup>
-
- <!-- Resolve nuget dll files and store them in the output dir -->
- <PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>VNLib.Plugins.Essentials.Sessions.Memory</AssemblyName>
<RootNamespace>VNLib.Plugins.Essentials.Sessions.Memory</RootNamespace>
<Authors>Vaughn Nugent</Authors>
<Copyright>Copyright © 2022 Vaughn Nugent</Copyright>
- <PackageProjectUrl>www.vaughnnugent.com/resources</PackageProjectUrl>
+ <PackageProjectUrl>https://www.vaughnnugent.com/resources</PackageProjectUrl>
+ </PropertyGroup>
+
+ <!-- Resolve nuget dll files and store them in the output dir -->
+ <PropertyGroup>
+ <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
+ <EnableDynamicLoading>true</EnableDynamicLoading>
+ <GenerateDocumentationFile>True</GenerateDocumentationFile>
+ <AnalysisLevel>latest-all</AnalysisLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+ <Deterministic>False</Deterministic>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <DocumentationFile></DocumentationFile>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <Deterministic>False</Deterministic>
</PropertyGroup>
+
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
<ItemGroup>
<PackageReference Include="ErrorProne.NET.CoreAnalyzers" Version="0.1.2">
@@ -37,9 +42,13 @@
<ProjectReference Include="..\..\..\PluginBase\VNLib.Plugins.PluginBase.csproj" />
<ProjectReference Include="..\VNLib.Plugins.Essentials.Sessions.Runtime\VNLib.Plugins.Essentials.Sessions.Runtime.csproj" />
</ItemGroup>
+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="start xcopy &quot;$(TargetDir)&quot; &quot;F:\Programming\Web Plugins\DevPlugins\RuntimeAssets\$(TargetName)&quot; /E /Y /R" />
</Target>
+ <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
+ <Exec Command="erase &quot;F:\Programming\Web Plugins\DevPlugins\RuntimeAssets\$(TargetName)&quot; /q &gt; nul" />
+ </Target>
</Project>
diff --git a/Libs/VNLib.Plugins.Sessions.Cache.Client/RemoteSession.cs b/Libs/VNLib.Plugins.Sessions.Cache.Client/RemoteSession.cs
index e2a9725..d2d4200 100644
--- a/Libs/VNLib.Plugins.Sessions.Cache.Client/RemoteSession.cs
+++ b/Libs/VNLib.Plugins.Sessions.Cache.Client/RemoteSession.cs
@@ -59,7 +59,7 @@ namespace VNLib.Plugins.Sessions.Cache.Client
/// </summary>
protected Dictionary<string, string>? DataStore;
- public RemoteSession(string sessionId, FBMClient client, TimeSpan backgroundTimeOut)
+ protected RemoteSession(string sessionId, FBMClient client, TimeSpan backgroundTimeOut)
{
SessionID = sessionId;
UpdateTimeout = backgroundTimeOut;
diff --git a/Libs/VNLib.Plugins.Sessions.Cache.Client/SessionCacheClient.cs b/Libs/VNLib.Plugins.Sessions.Cache.Client/SessionCacheClient.cs
index 40dafa6..8eed404 100644
--- a/Libs/VNLib.Plugins.Sessions.Cache.Client/SessionCacheClient.cs
+++ b/Libs/VNLib.Plugins.Sessions.Cache.Client/SessionCacheClient.cs
@@ -74,7 +74,7 @@ namespace VNLib.Plugins.Sessions.Cache.Client
/// </summary>
/// <param name="client"></param>
/// <param name="maxCacheItems">The maximum number of sessions to keep in memory</param>
- public SessionCacheClient(FBMClient client, int maxCacheItems)
+ protected SessionCacheClient(FBMClient client, int maxCacheItems)
{
MaxLoadedEntires = maxCacheItems;
CacheLock = new();
diff --git a/Libs/VNLib.Plugins.Sessions.Cache.Client/VNLib.Plugins.Sessions.Cache.Client.csproj b/Libs/VNLib.Plugins.Sessions.Cache.Client/VNLib.Plugins.Sessions.Cache.Client.csproj
index 4b4cd89..fc99bbf 100644
--- a/Libs/VNLib.Plugins.Sessions.Cache.Client/VNLib.Plugins.Sessions.Cache.Client.csproj
+++ b/Libs/VNLib.Plugins.Sessions.Cache.Client/VNLib.Plugins.Sessions.Cache.Client.csproj
@@ -1,15 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
- <Platforms>AnyCPU;x64</Platforms>
+ <TargetFramework>net6.0</TargetFramework>
<Authors>Vaughn Nugent</Authors>
<Copyright>Copyright © 2022 Vaughn Nugent</Copyright>
- <Version>1.0.0.1</Version>
+ <Version>1.0.1.1</Version>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <PropertyGroup>
<DocumentationFile></DocumentationFile>
+ <GenerateDocumentationFile>True</GenerateDocumentationFile>
+ <PackageProjectUrl>https://www.vaughnnugent.com/resources</PackageProjectUrl>
+ <AnalysisLevel>latest-all</AnalysisLevel>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+ <Deterministic>False</Deterministic>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <Deterministic>False</Deterministic>
</PropertyGroup>
<ItemGroup>