From 7088c48dd2014364d6b24891b913ff798132e97a Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 10 Mar 2024 16:14:08 -0400 Subject: Squashed commit of the following: commit 720136fef00095c808f9d5c75449e3fd03e82ca0 Author: vnugent Date: Wed Mar 6 21:33:12 2024 -0500 chore: Took a look around commit 71d6fb8c038adafa4a3a943cb0218cd234ef01ae Author: vnugent Date: Mon Feb 12 20:12:28 2024 -0500 refactor: update to latest sql changes and remove untested oauth feature commit 6941b12b44ccb1c184d9b6e33fbe19c72a0b3428 Author: vnugent Date: Sun Feb 4 01:30:26 2024 -0500 submit pending changes --- .../src/Endpoints/AccessTokenEndpoint.cs | 10 +++++----- .../src/Endpoints/RevocationEndpoint.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints') diff --git a/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs b/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs index b73a7eb..ef5ff5c 100644 --- a/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs +++ b/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs @@ -58,7 +58,7 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints public AccessTokenEndpoint(PluginBase pbase, IConfigScope config, IApplicationTokenFactory tokenFactory) { - string? path = config["token_path"].GetString();; + string? path = config.GetRequiredProperty("token_path", p => p.GetString()!); InitPathAndLog(path, pbase.Log); @@ -111,14 +111,14 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints } } - entity.CloseResponseError(HttpStatusCode.BadRequest, ErrorType.InvalidClient, "Invalid grant type"); //Default to bad request + entity.CloseResponseError(HttpStatusCode.BadRequest, ErrorType.InvalidClient, "Invalid grant type"); return VfReturnType.VirtualSkip; } private async Task GenerateTokenAsync(HttpEntity entity, UserApplication? app) { - if (app == null) + if (app is null) { //App was not found or the credentials do not match entity.CloseResponseError(HttpStatusCode.UnprocessableEntity, ErrorType.InvalidClient, "The credentials are invalid or do not exist"); @@ -127,9 +127,9 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints IOAuth2TokenResult? result = await TokenFactory.CreateAccessTokenAsync(entity, app, entity.EventCancellation); - if (result == null) + if (result is null) { - entity.CloseResponseError(HttpStatusCode.TooManyRequests, ErrorType.TemporarilyUnabavailable, "You have reached the maximum number of valid tokens for this application"); + entity.CloseResponseError(HttpStatusCode.TooManyRequests, ErrorType.TemporarilyUnavailable, "You have reached the maximum number of valid tokens for this application"); return VfReturnType.VirtualSkip; } diff --git a/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/RevocationEndpoint.cs b/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/RevocationEndpoint.cs index bdb4e4e..d21761c 100644 --- a/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/RevocationEndpoint.cs +++ b/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/RevocationEndpoint.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials.Sessions.OAuth @@ -38,7 +38,7 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints public RevocationEndpoint(PluginBase pbase, IConfigScope config) { - string? path = config["path"].GetString(); + string? path = config.GetRequiredProperty("path", p => p.GetString()!); InitPathAndLog(path, pbase.Log); } -- cgit