Skip to content

Commit

Permalink
anonymous token provider
Browse files Browse the repository at this point in the history
  • Loading branch information
hugodeco committed Jun 15, 2024
1 parent d21720b commit a40d324
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/Identity/AnonymousTokenProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Text;
using System.Threading.Tasks;

namespace Sufficit.Identity
{
/// <summary>
/// Default use for access non auth methods
/// </summary>
public class AnonymousTokenProvider : ITokenProvider
{
public ValueTask<string?> GetTokenAsync()
{
return new ValueTask<string?>((string?)null);
}
}
}
2 changes: 1 addition & 1 deletion src/Identity/ApiBearerTokenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ApiBearerTokenHandler(ITokenProvider token)
_token = token;
}

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
protected override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
{
if (ShouldAuthenticate(request))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Identity/ITokenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Sufficit.Identity
{
public interface ITokenProvider
{
Task<string?> GetTokenAsync();
ValueTask<string?> GetTokenAsync();
}
}

0 comments on commit a40d324

Please sign in to comment.