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
@@ -0,0 +1,12 @@
using System.Security.Claims;
using FSH.Framework.Core.Context;

namespace FSH.Modules.Identity.Contracts.Services;

/// <summary>
/// Service interface for managing the current user context.
/// Combines user identity access with initialization capabilities.
/// </summary>
public interface ICurrentUserService : ICurrentUser, ICurrentUserInitializer
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FSH.Framework.Core.Context;

namespace FSH.Modules.Identity.Contracts.Services;

/// <summary>
/// Service interface for accessing HTTP request context information.
/// Provides request metadata for auditing, logging, and other cross-cutting concerns.
/// </summary>
public interface IRequestContextService : IRequestContext
{
}
8 changes: 5 additions & 3 deletions src/Modules/Identity/Modules.Identity/IdentityModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public void ConfigureServices(IHostApplicationBuilder builder)
ArgumentNullException.ThrowIfNull(builder);
var services = builder.Services;
services.AddSingleton<IAuthorizationMiddlewareResultHandler, PathAwareAuthorizationHandler>();
services.AddScoped<ICurrentUser, CurrentUserService>();
services.AddScoped<IRequestContext, RequestContextService>();
services.AddScoped<ICurrentUserService, CurrentUserService>();
services.AddScoped<ICurrentUser>(sp => sp.GetRequiredService<ICurrentUserService>());
services.AddScoped<ICurrentUserInitializer>(sp => sp.GetRequiredService<ICurrentUserService>());
services.AddScoped<IRequestContextService, RequestContextService>();
services.AddScoped<IRequestContext>(sp => sp.GetRequiredService<IRequestContextService>());
services.AddScoped<ITokenService, TokenService>();
services.AddScoped(sp => (ICurrentUserInitializer)sp.GetRequiredService<ICurrentUser>());

// User services - focused single-responsibility services
services.AddTransient<IUserRegistrationService, UserRegistrationService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using FSH.Framework.Core.Context;
using FSH.Framework.Core.Exceptions;
using FSH.Framework.Shared.Identity.Claims;
using FSH.Modules.Identity.Contracts.Services;
using System.Security.Claims;

namespace FSH.Modules.Identity.Services;

public class CurrentUserService : ICurrentUser, ICurrentUserInitializer
internal sealed class CurrentUserService : ICurrentUserService
{
private ClaimsPrincipal? _user;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FSH.Framework.Core.Context;
using FSH.Framework.Web.Origin;
using FSH.Modules.Identity.Contracts.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;

Expand All @@ -9,7 +10,7 @@ namespace FSH.Modules.Identity.Services;
/// Provides HTTP request context information through an abstraction.
/// This allows handlers to access request metadata without direct ASP.NET Core dependencies.
/// </summary>
public sealed class RequestContextService : IRequestContext
internal sealed class RequestContextService : IRequestContextService
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly Uri? _originUrl;
Expand Down
Loading