diff options
author | vnugent <public@vaughnnugent.com> | 2024-09-02 01:30:23 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-09-02 01:30:23 -0400 |
commit | 9ef232ba29fd42c856c51fe7ae1b1765dcc498ea (patch) | |
tree | 61894e09ccaadf4cefbdefa78f02d1c735ef0a20 /libs/VNLib.Plugins.Sessions.OAuth/src | |
parent | ccfdae6cb505cf0d2d5e7021418b2ded22335349 (diff) |
push pending changesdevelop
Diffstat (limited to 'libs/VNLib.Plugins.Sessions.OAuth/src')
-rw-r--r-- | libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs | 40 | ||||
-rw-r--r-- | libs/VNLib.Plugins.Sessions.OAuth/src/OauthTokenResponseMessage.cs | 6 |
2 files changed, 32 insertions, 14 deletions
diff --git a/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs b/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs index ef5ff5c..c251212 100644 --- a/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs +++ b/libs/VNLib.Plugins.Sessions.OAuth/src/Endpoints/AccessTokenEndpoint.cs @@ -56,15 +56,19 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints DisableSessionsRequired = true }; - public AccessTokenEndpoint(PluginBase pbase, IConfigScope config, IApplicationTokenFactory tokenFactory) + public AccessTokenEndpoint(PluginBase plugin, IConfigScope config, IApplicationTokenFactory tokenFactory) { - string? path = config.GetRequiredProperty("token_path", p => p.GetString()!); - - InitPathAndLog(path, pbase.Log); + InitPathAndLog( + path: config.GetRequiredProperty<string>("token_path"), + log: plugin.Log.CreateScope("Token Endpoint") + ); TokenFactory = tokenFactory; - Applications = new(pbase.GetContextOptions(), pbase.GetOrCreateSingleton<ManagedPasswordHashing>()); + Applications = new( + plugin.GetContextOptions(), + plugin.GetOrCreateSingleton<ManagedPasswordHashing>() + ); } @@ -121,7 +125,12 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints 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"); + entity.CloseResponseError( + HttpStatusCode.UnprocessableEntity, + ErrorType.InvalidClient, + description: "The credentials are invalid or do not exist" + ); + return VfReturnType.VirtualSkip; } @@ -129,19 +138,24 @@ namespace VNLib.Plugins.Sessions.OAuth.Endpoints if (result is null) { - entity.CloseResponseError(HttpStatusCode.TooManyRequests, ErrorType.TemporarilyUnavailable, "You have reached the maximum number of valid tokens for this application"); + entity.CloseResponseError( + HttpStatusCode.TooManyRequests, + ErrorType.TemporarilyUnavailable, + description: "You have reached the maximum number of valid tokens for this application" + ); + return VfReturnType.VirtualSkip; } //Create the new response message OauthTokenResponseMessage tokenMessage = new() { - AccessToken = result.AccessToken, - IdToken = result.IdentityToken, - //set expired as seconds in int form - Expires = result.ExpiresSeconds, - RefreshToken = result.RefreshToken, - TokenType = result.TokenType + //set expired as seconds in int form + Expires = result.ExpiresSeconds, + AccessToken = result.AccessToken, + IdToken = result.IdentityToken, + RefreshToken = result.RefreshToken, + TokenType = result.TokenType }; //Respond with the token message diff --git a/libs/VNLib.Plugins.Sessions.OAuth/src/OauthTokenResponseMessage.cs b/libs/VNLib.Plugins.Sessions.OAuth/src/OauthTokenResponseMessage.cs index 2a063b0..8241663 100644 --- a/libs/VNLib.Plugins.Sessions.OAuth/src/OauthTokenResponseMessage.cs +++ b/libs/VNLib.Plugins.Sessions.OAuth/src/OauthTokenResponseMessage.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials.Sessions.OAuth @@ -30,12 +30,16 @@ namespace VNLib.Plugins.Sessions.OAuth { [JsonPropertyName("access_token")] public string? AccessToken { get; set; } + [JsonPropertyName("refresh_token")] public string? RefreshToken { get; set; } + [JsonPropertyName("token_type")] public string? TokenType { get; set; } + [JsonPropertyName("expires_in")] public int Expires { get; set; } + [JsonPropertyName("id_token")] public string? IdToken { get; set; } } |