Skip to content

Commit

Permalink
chore: Disbale token issuer cache when auth is disabled (#971)
Browse files Browse the repository at this point in the history
Noticed this when attempting to debug on the airplane going back home.

It is not possible to query the api when offline, with auth disabled 
TokenIssuerCache calls times out, results in HTTP500

This disables the TokenIssuerCache when DisableAuth is set


Manually tested on plane ✈️
  • Loading branch information
oskogstad authored Aug 7, 2024
1 parent d7bf888 commit dbd9467
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ public interface ITokenIssuerCache
public Task<string?> GetIssuerForScheme(string schemeName);
}

// ReSharper disable once ClassNeverInstantiated.Global
public sealed class DevelopmentTokenIssuerCache : ITokenIssuerCache
{
public Task<string?> GetIssuerForScheme(string schemeName) => Task.FromResult<string?>(null);
}

public sealed class TokenIssuerCache : ITokenIssuerCache, IDisposable
{
private readonly Dictionary<string, string> _issuerMappings = new();
Expand Down
2 changes: 2 additions & 0 deletions src/Digdir.Domain.Dialogporten.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ static void BuildAndRun(string[] args)
.ReplaceSingleton<IUser, LocalDevelopmentUser>(predicate: localDevelopmentSettings.UseLocalDevelopmentUser)
.ReplaceSingleton<IAuthorizationHandler, AllowAnonymousHandler>(
predicate: localDevelopmentSettings.DisableAuth)
.ReplaceSingleton<ITokenIssuerCache, DevelopmentTokenIssuerCache>(
predicate: localDevelopmentSettings.DisableAuth)
.AddHostedService<
OutboxScheduler>(predicate: !localDevelopmentSettings.DisableShortCircuitOutboxDispatcher);
}
Expand Down

0 comments on commit dbd9467

Please sign in to comment.