Skip to content

Commit

Permalink
Add the named IOptions for AuthenticationTicketOptions to the DI cont…
Browse files Browse the repository at this point in the history
…ainer
  • Loading branch information
melittleman committed Feb 25, 2024
1 parent c1e4a9d commit d4fc219
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ public static IRedisConnectionBuilder AddRedisTicketStore(
ArgumentNullException.ThrowIfNull(builder);

RedisAuthenticationTicketOptions ticketOptions = new();
configure?.Invoke(ticketOptions);

if (configure is not null)
{
builder.Services.Configure(builder.Name, configure);
configure.Invoke(ticketOptions);
}

// TODO: Should we look into 'TryAddKeyedTransient' here?
// Means we could theoretically support multiple different ticket store implementations.
// e.g. External Auth Schemes like GitHub, Microsoft etc. vs the internal Auth Scheme.
builder.Services.TryAddTransient<ITicketStore>(s =>
{
IRedisConnectionProvider provider = s.GetRequiredService<IRedisConnectionProvider>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace RedisKit.DependencyInjection.Options;
using Microsoft.AspNetCore.Identity;

namespace RedisKit.DependencyInjection.Options;

public sealed record RedisAuthenticationTicketOptions
{
public string KeyPrefix { get; set; } = "auth-tickets:";

public string? CookieSchemeName { get; set; }
public string CookieSchemeName { get; set; } = IdentityConstants.ApplicationScheme;
}

0 comments on commit d4fc219

Please sign in to comment.