From f13193aa928f099c8152653570d2839b46b8f1ee Mon Sep 17 00:00:00 2001 From: vman Date: Wed, 30 Nov 2022 14:59:18 -0500 Subject: Project cleanup + analyzer updates --- .../src/Endpoints/RegistrationEntpoint.cs | 2 +- .../src/RegistrationContext.cs | 39 ++++++++++++++++++++++ .../src/RegistrationEntryPoint.cs | 5 +-- .../src/TokenRevocation/RevocationContext.cs | 38 --------------------- .../src/TokenRevocation/RevokedTokenStore.cs | 6 ++-- ...Plugins.Essentials.Accounts.Registration.csproj | 20 +++-------- 6 files changed, 51 insertions(+), 59 deletions(-) create mode 100644 VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationContext.cs delete mode 100644 VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevocationContext.cs (limited to 'VNLib.Plugins.Essentials.Accounts.Registration') diff --git a/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs b/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs index 19d7ffa..1e983cb 100644 --- a/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs +++ b/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs @@ -102,7 +102,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.Endpoints _ = ts.Result ?? throw new KeyNotFoundException("Missing required key 'reg_sig_key' in 'registration' configuration"); return Convert.FromBase64String(ts.Result); - }); + }, TaskScheduler.Default); //Register timeout for cleanup _ = plugin.ScheduleInterval(this, TimeSpan.FromSeconds(60)); diff --git a/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationContext.cs b/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationContext.cs new file mode 100644 index 0000000..611e30e --- /dev/null +++ b/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationContext.cs @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2022 Vaughn Nugent +* +* Library: VNLib +* Package: VNLib.Plugins.Essentials.Accounts.Registration +* File: RevocationContext.cs +* +* RevocationContext.cs is part of VNLib.Plugins.Essentials.Accounts.Registration which is part of the larger +* VNLib collection of libraries and utilities. +* +* VNLib.Plugins.Essentials.Accounts.Registration 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.Accounts.Registration 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 Microsoft.EntityFrameworkCore; + +using VNLib.Plugins.Extensions.Data; +using VNLib.Plugins.Essentials.Accounts.Registration.TokenRevocation; + +namespace VNLib.Plugins.Essentials.Accounts.Registration +{ + internal class RegistrationContext : TransactionalDbContext + { + public DbSet RevokedRegistrationTokens { get; set; } + + public RegistrationContext(DbContextOptions options) : base(options) + {} + } +} \ No newline at end of file diff --git a/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationEntryPoint.cs b/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationEntryPoint.cs index 1851cf2..c24e7e0 100644 --- a/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationEntryPoint.cs +++ b/VNLib.Plugins.Essentials.Accounts.Registration/src/RegistrationEntryPoint.cs @@ -25,6 +25,7 @@ using VNLib.Utils.Logging; using VNLib.Plugins.Extensions.Loading; +using VNLib.Plugins.Extensions.Loading.Sql; using VNLib.Plugins.Extensions.Loading.Routing; using VNLib.Plugins.Essentials.Accounts.Registration.Endpoints; @@ -40,7 +41,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration { //Route reg endpoint this.Route(); - + Log.Information("Plugin loaded"); } catch(KeyNotFoundException kne) @@ -48,7 +49,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration Log.Error("Missing required configuration variables: {ex}", kne.Message); } } - + protected override void OnUnLoad() { Log.Information("Plugin unloaded"); diff --git a/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevocationContext.cs b/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevocationContext.cs deleted file mode 100644 index 4ff64b9..0000000 --- a/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevocationContext.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials.Accounts.Registration -* File: RevocationContext.cs -* -* RevocationContext.cs is part of VNLib.Plugins.Essentials.Accounts.Registration which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials.Accounts.Registration 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.Accounts.Registration 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 Microsoft.EntityFrameworkCore; - -using VNLib.Plugins.Extensions.Data; - -namespace VNLib.Plugins.Essentials.Accounts.Registration.TokenRevocation -{ - internal class RevocationContext : TransactionalDbContext - { - public DbSet RevokedRegistrationTokens { get; set; } - - public RevocationContext(DbContextOptions options) : base(options) - {} - } -} \ No newline at end of file diff --git a/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevokedTokenStore.cs b/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevokedTokenStore.cs index c9217be..89f4bd6 100644 --- a/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevokedTokenStore.cs +++ b/VNLib.Plugins.Essentials.Accounts.Registration/src/TokenRevocation/RevokedTokenStore.cs @@ -41,7 +41,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.TokenRevocation public async Task IsRevokedAsync(string token, CancellationToken cancellation) { - await using RevocationContext context = new (Options); + await using RegistrationContext context = new (Options); await context.OpenTransactionAsync(cancellation); //Select any that match tokens @@ -55,7 +55,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.TokenRevocation public async Task RevokeAsync(string token, CancellationToken cancellation) { - await using RevocationContext context = new (Options); + await using RegistrationContext context = new (Options); await context.OpenTransactionAsync(cancellation); //Add to table @@ -80,7 +80,7 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.TokenRevocation { DateTime expiredBefore = DateTime.UtcNow.Subtract(validFor); - await using RevocationContext context = new (Options); + await using RegistrationContext context = new (Options); await context.OpenTransactionAsync(cancellation); //Select any that match tokens diff --git a/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj b/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj index 25699c0..5a8597f 100644 --- a/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj +++ b/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj @@ -4,39 +4,29 @@ net6.0 enable enable - x64 False VNLib.Plugins.Essentials.Accounts.Registration Vaughn Nugent Copyright © 2022 Vaughn Nugent - www.vaughnnugent.com/resources + https://www.vaughnnugent.com/resources False False 1.0.0.1 Essentials.EmailRegistration - AnyCPU;x64 + False true + latest-all - - True - - - - True + False - - True - - - - True + False -- cgit