aboutsummaryrefslogtreecommitdiff
path: root/lib/Plugins.Essentials/src/Sessions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Plugins.Essentials/src/Sessions')
-rw-r--r--lib/Plugins.Essentials/src/Sessions/ISessionExtensions.cs18
-rw-r--r--lib/Plugins.Essentials/src/Sessions/SessionBase.cs8
-rw-r--r--lib/Plugins.Essentials/src/Sessions/SessionInfo.cs13
3 files changed, 11 insertions, 28 deletions
diff --git a/lib/Plugins.Essentials/src/Sessions/ISessionExtensions.cs b/lib/Plugins.Essentials/src/Sessions/ISessionExtensions.cs
index 81d6ad3..018c9a2 100644
--- a/lib/Plugins.Essentials/src/Sessions/ISessionExtensions.cs
+++ b/lib/Plugins.Essentials/src/Sessions/ISessionExtensions.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2022 Vaughn Nugent
+* Copyright (c) 2023 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Plugins.Essentials
@@ -23,8 +23,8 @@
*/
using System;
-using System.Runtime.CompilerServices;
using System.Security.Authentication;
+using System.Runtime.CompilerServices;
using VNLib.Net.Http;
using VNLib.Utils;
@@ -41,8 +41,7 @@ namespace VNLib.Plugins.Essentials.Sessions
public const string REFER_ENTRY = "__.rfr";
public const string SECURE_ENTRY = "__.sec";
public const string CROSS_ORIGIN = "__.cor";
- public const string LOCAL_TIME_ENTRY = "__.lot";
- public const string LOGIN_TOKEN_ENTRY = "__.lte";
+ public const string LOCAL_TIME_ENTRY = "__.lot";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string GetUserAgent(this ISession session) => session[USER_AGENT_ENTRY];
@@ -61,10 +60,8 @@ namespace VNLib.Plugins.Essentials.Sessions
public static void SetRefer(this ISession session, string refer) => session[REFER_ENTRY] = refer;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static SslProtocols GetSecurityProtocol(this ISession session)
- {
- return (SslProtocols)session.GetValueType<string, int>(SECURE_ENTRY);
- }
+ public static SslProtocols GetSecurityProtocol(this ISession session) => (SslProtocols)session.GetValueType<string, int>(SECURE_ENTRY);
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetSecurityProtocol(this ISession session, SslProtocols protocol) => session[SECURE_ENTRY] = VnEncoding.ToBase32String((int)protocol);
@@ -72,11 +69,6 @@ namespace VNLib.Plugins.Essentials.Sessions
public static bool IsCrossOrigin(this ISession session) => session[CROSS_ORIGIN] == bool.TrueString;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsCrossOrigin(this ISession session, bool crossOrign) => session[CROSS_ORIGIN] = crossOrign.ToString();
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static string GetLoginToken(this ISession session) => session[LOGIN_TOKEN_ENTRY];
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void SetLoginToken(this ISession session, string loginToken) => session[LOGIN_TOKEN_ENTRY] = loginToken;
/// <summary>
/// Initializes a "new" session with initial varaibles from the current connection
diff --git a/lib/Plugins.Essentials/src/Sessions/SessionBase.cs b/lib/Plugins.Essentials/src/Sessions/SessionBase.cs
index bf20b9d..47079a0 100644
--- a/lib/Plugins.Essentials/src/Sessions/SessionBase.cs
+++ b/lib/Plugins.Essentials/src/Sessions/SessionBase.cs
@@ -28,8 +28,6 @@ using System.Runtime.CompilerServices;
using VNLib.Utils;
-#nullable disable
-
namespace VNLib.Plugins.Essentials.Sessions
{
/// <summary>
@@ -73,6 +71,8 @@ namespace VNLib.Plugins.Essentials.Sessions
///<inheritdoc/>
public abstract DateTimeOffset Created { get; set; }
+#nullable disable
+
///<inheritdoc/>
///<exception cref="ObjectDisposedException"></exception>
public string this[string index]
@@ -80,13 +80,14 @@ namespace VNLib.Plugins.Essentials.Sessions
get => IndexerGet(index);
set => IndexerSet(index, value);
}
+
///<inheritdoc/>
public virtual IPAddress UserIP
{
get
{
//try to parse the IP address, otherwise return null
- _ = IPAddress.TryParse(this[IP_ADDRESS_ENTRY], out IPAddress ip);
+ _ = IPAddress.TryParse(this[IP_ADDRESS_ENTRY], out IPAddress? ip);
return ip;
}
protected set
@@ -138,6 +139,7 @@ namespace VNLib.Plugins.Essentials.Sessions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => this[TOKEN_ENTRY] = value;
}
+
///<inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void Invalidate(bool all = false)
diff --git a/lib/Plugins.Essentials/src/Sessions/SessionInfo.cs b/lib/Plugins.Essentials/src/Sessions/SessionInfo.cs
index 6c1141a..527792f 100644
--- a/lib/Plugins.Essentials/src/Sessions/SessionInfo.cs
+++ b/lib/Plugins.Essentials/src/Sessions/SessionInfo.cs
@@ -149,18 +149,7 @@ namespace VNLib.Plugins.Essentials.Sessions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => UserSession.Created;
- }
-
- /// <summary>
- /// Gets or sets the session's login hash, if set to a non-empty/null value, will trigger an upgrade on close
- /// </summary>
- public readonly string LoginHash
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get => UserSession.GetLoginToken();
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set => UserSession.SetLoginToken(value);
- }
+ }
/// <summary>
/// Gets or sets the session's login token, if set to a non-empty/null value, will trigger an upgrade on close