aboutsummaryrefslogtreecommitdiff
path: root/plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-05-22 16:48:31 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-05-22 16:48:31 -0400
commit31220eaf6583c28f2df5070c3c8841a02a17cdbe (patch)
treec88dd0c4144d3340925445f751ce88207dedaf57 /plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs
parentb3516162529cf876057fad37c5a155b6b097b0bd (diff)
Functionality error patches
Diffstat (limited to 'plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs')
-rw-r--r--plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs13
1 files changed, 2 insertions, 11 deletions
diff --git a/plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs b/plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs
index c63304a..f8b0401 100644
--- a/plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs
+++ b/plugins/VNLib.Plugins.Essentials.Accounts/src/SecurityProvider/AccountSecProvider.cs
@@ -59,7 +59,6 @@ namespace VNLib.Plugins.Essentials.Accounts.SecurityProvider
private const int PUB_KEY_JWT_NONCE_SIZE = 16;
//Session entry keys
- private const string CLIENT_PUB_KEY_ENTRY = "acnt.pbk";
private const string PUBLIC_KEY_SIG_KEY_ENTRY = "acnt.pbsk";
private const HashAlg ClientTokenHmacType = HashAlg.SHA256;
@@ -203,16 +202,8 @@ namespace VNLib.Plugins.Essentials.Accounts.SecurityProvider
ERRNO IAccountSecurityProvider.TryEncryptClientData(HttpEntity entity, ReadOnlySpan<byte> data, Span<byte> outputBuffer)
{
- //Session must be enabled and not new
- if (!entity.Session.IsSet || entity.Session.IsNew)
- {
- return false;
- }
-
- //try to get the public key from the client
- string base64PubKey = entity.Session[CLIENT_PUB_KEY_ENTRY];
-
- return TryEncryptClientData(base64PubKey, data, outputBuffer);
+ //Recover the signed public key, already does session checks
+ return TryGetPublicKey(entity, out string? pubKey) ? TryEncryptClientData(pubKey, data, outputBuffer) : ERRNO.E_FAIL;
}
ERRNO IAccountSecurityProvider.TryEncryptClientData(IClientSecInfo entity, ReadOnlySpan<byte> data, Span<byte> outputBuffer)