diff --git a/OpenAI-DotNet-Proxy/OpenAI-DotNet-Proxy.csproj b/OpenAI-DotNet-Proxy/OpenAI-DotNet-Proxy.csproj index 5cccc098..782b8fe8 100644 --- a/OpenAI-DotNet-Proxy/OpenAI-DotNet-Proxy.csproj +++ b/OpenAI-DotNet-Proxy/OpenAI-DotNet-Proxy.csproj @@ -22,8 +22,10 @@ true false false - 8.1.1 + 8.2.0 +Version 8.2.0 +- Deprecated ValidateAuthentication for ValidateAuthenticationAsync Version 8.1.1 - Renamed OpenAIProxyStartup to OpenAIProxy Version 7.7.10 diff --git a/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs b/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs index 44fa8829..c0d7ca75 100644 --- a/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs +++ b/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs @@ -1,6 +1,7 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using Microsoft.AspNetCore.Http; +using System; using System.Threading.Tasks; namespace OpenAI.Proxy @@ -8,8 +9,8 @@ namespace OpenAI.Proxy /// public abstract class AbstractAuthenticationFilter : IAuthenticationFilter { - /// - public abstract void ValidateAuthentication(IHeaderDictionary request); + [Obsolete("Use ValidateAuthenticationAsync")] + public virtual void ValidateAuthentication(IHeaderDictionary request) { } /// public abstract Task ValidateAuthenticationAsync(IHeaderDictionary request); diff --git a/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs b/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs index fc1bd624..1d54ce5f 100644 --- a/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs +++ b/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs @@ -1,6 +1,7 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using Microsoft.AspNetCore.Http; +using System; using System.Security.Authentication; using System.Threading.Tasks; @@ -11,12 +12,7 @@ namespace OpenAI.Proxy /// public interface IAuthenticationFilter { - /// - /// Checks the headers for your user issued token. - /// If it's not valid, then throw . - /// - /// - /// + [Obsolete("Use ValidateAuthenticationAsync")] void ValidateAuthentication(IHeaderDictionary request); /// diff --git a/OpenAI-DotNet-Proxy/Readme.md b/OpenAI-DotNet-Proxy/Readme.md index 40c45c1c..dd2e3eff 100644 --- a/OpenAI-DotNet-Proxy/Readme.md +++ b/OpenAI-DotNet-Proxy/Readme.md @@ -59,19 +59,9 @@ public partial class Program { private class AuthenticationFilter : AbstractAuthenticationFilter { - public override void ValidateAuthentication(IHeaderDictionary request) - { - // You will need to implement your own class to properly test - // custom issued tokens you've setup for your end users. - if (!request.Authorization.ToString().Contains(TestUserToken)) - { - throw new AuthenticationException("User is not authorized"); - } - } - public override async Task ValidateAuthenticationAsync(IHeaderDictionary request) { - await Task.CompletedTask; // remote resource call + await Task.CompletedTask; // remote resource call to verify token // You will need to implement your own class to properly test // custom issued tokens you've setup for your end users. diff --git a/OpenAI-DotNet-Tests-Proxy/Program.cs b/OpenAI-DotNet-Tests-Proxy/Program.cs index ed20e322..06fd684e 100644 --- a/OpenAI-DotNet-Tests-Proxy/Program.cs +++ b/OpenAI-DotNet-Tests-Proxy/Program.cs @@ -17,19 +17,10 @@ public partial class Program private class AuthenticationFilter : AbstractAuthenticationFilter { - public override void ValidateAuthentication(IHeaderDictionary request) - { - // You will need to implement your own class to properly test - // custom issued tokens you've setup for your end users. - if (!request.Authorization.ToString().Contains(TestUserToken)) - { - throw new AuthenticationException("User is not authorized"); - } - } - + /// public override async Task ValidateAuthenticationAsync(IHeaderDictionary request) { - await Task.CompletedTask; // remote resource call + await Task.CompletedTask; // remote resource call to verify token // You will need to implement your own class to properly test // custom issued tokens you've setup for your end users. diff --git a/README.md b/README.md index 71d94491..2a73e987 100644 --- a/README.md +++ b/README.md @@ -315,19 +315,9 @@ public partial class Program { private class AuthenticationFilter : AbstractAuthenticationFilter { - public override void ValidateAuthentication(IHeaderDictionary request) - { - // You will need to implement your own class to properly test - // custom issued tokens you've setup for your end users. - if (!request.Authorization.ToString().Contains(TestUserToken)) - { - throw new AuthenticationException("User is not authorized"); - } - } - public override async Task ValidateAuthenticationAsync(IHeaderDictionary request) { - await Task.CompletedTask; // remote resource call + await Task.CompletedTask; // remote resource call to verify token // You will need to implement your own class to properly test // custom issued tokens you've setup for your end users.