Skip to content

Commit

Permalink
OpenAI-DotNet-Proxy 8.2.0
Browse files Browse the repository at this point in the history
- Deprecated ValidateAuthentication for ValidateAuthenticationAsync
  • Loading branch information
StephenHodgson committed Aug 17, 2024
1 parent 48d7d8a commit 6f3da5f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 42 deletions.
4 changes: 3 additions & 1 deletion OpenAI-DotNet-Proxy/OpenAI-DotNet-Proxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
<IncludeSymbols>true</IncludeSymbols>
<SignAssembly>false</SignAssembly>
<ImplicitUsings>false</ImplicitUsings>
<Version>8.1.1</Version>
<Version>8.2.0</Version>
<PackageReleaseNotes>
Version 8.2.0
- Deprecated ValidateAuthentication for ValidateAuthenticationAsync
Version 8.1.1
- Renamed OpenAIProxyStartup to OpenAIProxy
Version 7.7.10
Expand Down
5 changes: 3 additions & 2 deletions OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// 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
{
/// <inheritdoc />
public abstract class AbstractAuthenticationFilter : IAuthenticationFilter
{
/// <inheritdoc />
public abstract void ValidateAuthentication(IHeaderDictionary request);
[Obsolete("Use ValidateAuthenticationAsync")]
public virtual void ValidateAuthentication(IHeaderDictionary request) { }

/// <inheritdoc />
public abstract Task ValidateAuthenticationAsync(IHeaderDictionary request);
Expand Down
8 changes: 2 additions & 6 deletions OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -11,12 +12,7 @@ namespace OpenAI.Proxy
/// </summary>
public interface IAuthenticationFilter
{
/// <summary>
/// Checks the headers for your user issued token.
/// If it's not valid, then throw <see cref="AuthenticationException"/>.
/// </summary>
/// <param name="request"></param>
/// <exception cref="AuthenticationException"></exception>
[Obsolete("Use ValidateAuthenticationAsync")]
void ValidateAuthentication(IHeaderDictionary request);

/// <summary>
Expand Down
12 changes: 1 addition & 11 deletions OpenAI-DotNet-Proxy/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 2 additions & 11 deletions OpenAI-DotNet-Tests-Proxy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

/// <inheritdoc />
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.
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6f3da5f

Please sign in to comment.