Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Identity;
using RuntimeApps.Authentication.DependencyInjection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

namespace RuntimeApps.Authentication.EF.Extensions {
namespace RuntimeApps.Authentication.EF.DependencyInjection {
public static class RuntimeAppsAuthenticationBuilderExtension {
public static RuntimeAppsAuthenticationBuilder<TUser, TRole, TKey> AddEfStores<TDbContext, TUser, TRole, TKey>(this RuntimeAppsAuthenticationBuilder<TUser, TRole, TKey> builder)
where TDbContext : IdentityDbContext<TUser, TRole, TKey>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using RuntimeApps.Authentication.EF.Store;
using RuntimeApps.Authentication.Interface;

namespace RuntimeApps.Authentication.EF.Extensions {
using RuntimeApps.Authentication.DependencyInjection;
using RuntimeApps.Authentication.EF.Features.RefreshTokens.Stores;
using RuntimeApps.Authentication.Features.RefreshTokens.Contracts;
namespace RuntimeApps.Authentication.EF.DependencyInjection {
public static class RuntimeAppsAuthenticationRefreshTokenBuilderExtensions {
/// <summary>Registers the EF-backed refresh-token store for an Identity DbContext.</summary>
public static RuntimeAppsAuthenticationBuilder<TUser, TRole, TKey> AddEfRefreshTokenStore<TDbContext, TUser, TRole, TKey>(
Expand All @@ -19,4 +18,4 @@ public static RuntimeAppsAuthenticationBuilder<TUser, TRole, TKey> AddEfRefreshT
return builder;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using RuntimeApps.Authentication.EF.Store;
using RuntimeApps.Authentication.Interface;

namespace RuntimeApps.Authentication.EF.Extensions {
using RuntimeApps.Authentication.EF.Features.Verification.Stores;
using RuntimeApps.Authentication.Features.Verification.Contracts;
namespace RuntimeApps.Authentication.EF.DependencyInjection {
public static class VerificationRequestStoreBuilderExtensions {
/// <summary>Registers the EF Core verification-request store.</summary>
public static IServiceCollection AddVerificationRequestStore<TDbContext, TKey>(this IServiceCollection services)
Expand All @@ -15,4 +14,4 @@ public static IServiceCollection AddVerificationRequestStore<TDbContext, TKey>(t
return services;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using RuntimeApps.Authentication.Model;

namespace RuntimeApps.Authentication.EF.Model {
public sealed class RefreshTokenConfiguration<TKey> : IEntityTypeConfiguration<RefreshToken<TKey>>
using RuntimeApps.Authentication.Features.RefreshTokens.Models;
namespace RuntimeApps.Authentication.EF.Features.RefreshTokens.Configurations {
public sealed class RefreshTokenConfiguration<TKey>: IEntityTypeConfiguration<RefreshToken<TKey>>
where TKey : IEquatable<TKey> {
public void Configure(EntityTypeBuilder<RefreshToken<TKey>> builder) {
builder.ToTable("AuthenticationRefreshTokens");
Expand Down Expand Up @@ -32,4 +31,4 @@ public void Configure(EntityTypeBuilder<RefreshToken<TKey>> builder) {
builder.HasIndex(token => token.ExpiresAt);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.EntityFrameworkCore;
using RuntimeApps.Authentication.EF.Model;

namespace RuntimeApps.Authentication.EF.Extensions {
namespace RuntimeApps.Authentication.EF.Features.RefreshTokens.Configurations {
public static class RefreshTokenModelBuilderExtensions {
/// <summary>Adds the refresh-token entity to the consumer application's DbContext model.</summary>
public static ModelBuilder AddRefreshTokenEntity<TKey>(this ModelBuilder modelBuilder)
Expand All @@ -11,4 +9,4 @@ public static ModelBuilder AddRefreshTokenEntity<TKey>(this ModelBuilder modelBu
return modelBuilder;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Microsoft.EntityFrameworkCore;
using RuntimeApps.Authentication.Interface;
using RuntimeApps.Authentication.Model;

namespace RuntimeApps.Authentication.EF.Store {
using RuntimeApps.Authentication.Features.RefreshTokens.Contracts;
using RuntimeApps.Authentication.Features.RefreshTokens.Models;
namespace RuntimeApps.Authentication.EF.Features.RefreshTokens.Stores {
/// <summary>
/// EF Core store. Atomic rotation requires a relational provider with transaction support.
/// </summary>
public sealed class EfRefreshTokenStore<TDbContext, TKey> : IRefreshTokenStore<TKey>
public sealed class EfRefreshTokenStore<TDbContext, TKey>: IRefreshTokenStore<TKey>
where TDbContext : DbContext
where TKey : IEquatable<TKey> {
private readonly TDbContext _dbContext;
Expand Down Expand Up @@ -98,4 +97,4 @@ await _dbContext.Set<RefreshToken<TKey>>()
.Where(token => object.Equals(token.UserId, userId) && token.RevokedAt == null)
.ExecuteUpdateAsync(setters => setters.SetProperty(token => token.RevokedAt, revokedAt), cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using RuntimeApps.Authentication.Model;

namespace RuntimeApps.Authentication.EF.Model {
using RuntimeApps.Authentication.Features.Verification.Models;
namespace RuntimeApps.Authentication.EF.Features.Verification.Configurations {
public sealed class VerificationRequestConfiguration<TKey> : IEntityTypeConfiguration<VerificationRequest<TKey>>
where TKey : IEquatable<TKey> {
public void Configure(EntityTypeBuilder<VerificationRequest<TKey>> builder) {
Expand Down Expand Up @@ -35,4 +34,4 @@ public void Configure(EntityTypeBuilder<VerificationRequest<TKey>> builder) {
builder.HasIndex(request => new { request.Status, request.ExpiresAt });
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.EntityFrameworkCore;
using RuntimeApps.Authentication.EF.Model;

namespace RuntimeApps.Authentication.EF.Extensions {
namespace RuntimeApps.Authentication.EF.Features.Verification.Configurations {
public static class VerificationRequestModelBuilderExtensions {
/// <summary>Adds the verification request and delivery-rate-limit entities to the consumer DbContext.</summary>
public static ModelBuilder AddVerificationRequestEntity<TKey>(this ModelBuilder modelBuilder)
Expand All @@ -12,4 +10,4 @@ public static ModelBuilder AddVerificationRequestEntity<TKey>(this ModelBuilder
return modelBuilder;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using RuntimeApps.Authentication.Model;

namespace RuntimeApps.Authentication.EF.Model {
using RuntimeApps.Authentication.Features.Verification.Models;
namespace RuntimeApps.Authentication.EF.Features.Verification.Configurations {
public sealed class VerificationSendConfiguration : IEntityTypeConfiguration<VerificationSend> {
public void Configure(EntityTypeBuilder<VerificationSend> builder) {
builder.ToTable("AuthenticationVerificationSends");
Expand All @@ -22,4 +21,4 @@ public void Configure(EntityTypeBuilder<VerificationSend> builder) {
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using System.Data;
using Microsoft.EntityFrameworkCore;
using RuntimeApps.Authentication.Interface;
using RuntimeApps.Authentication.Model;

namespace RuntimeApps.Authentication.EF.Store {
using RuntimeApps.Authentication.Features.Verification.Contracts;
using RuntimeApps.Authentication.Features.Verification.Models;
namespace RuntimeApps.Authentication.EF.Features.Verification.Stores {
/// <summary>
/// Relational EF Core implementation. Conditional updates and serializable transactions protect
/// request state transitions and destination-level send limits against concurrent requests.
/// </summary>
public sealed class EfVerificationRequestStore<TDbContext, TKey> : IVerificationRequestStore<TKey>
public sealed class EfVerificationRequestStore<TDbContext, TKey>: IVerificationRequestStore<TKey>
where TDbContext : DbContext
where TKey : IEquatable<TKey> {
private readonly TDbContext _dbContext;
Expand Down Expand Up @@ -234,4 +233,4 @@ private void EnsureRelational() {
throw new NotSupportedException("Atomic verification-request operations require a relational EF Core provider.");
}
}
}
}

This file was deleted.

Loading