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,4 +1,5 @@
using CodeBeam.UltimateAuth.Client.Options;
using CodeBeam.UltimateAuth.Server.Domain;
using CodeBeam.UltimateAuth.Server.Options;
using Microsoft.Extensions.Options;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CodeBeam.UltimateAuth.Core.Options;
using CodeBeam.UltimateAuth.Core.Domain;

namespace CodeBeam.UltimateAuth.Core.Abstractions;

Expand Down
19 changes: 4 additions & 15 deletions src/CodeBeam.UltimateAuth.Core/CodeBeam.UltimateAuth.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,17 @@
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.23" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.23" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.23" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.23" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="10.0.15" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.Extensions.Configuration" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.15" />
</ItemGroup>
<!--.NET 11 has this package-->

<ItemGroup>
<None Include="uauthlogo.png" Pack="true" PackagePath="\" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CodeBeam.UltimateAuth.Core.Options;
namespace CodeBeam.UltimateAuth.Core.Domain;

public enum CredentialChangeReason
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CodeBeam.UltimateAuth.Core.Options;
namespace CodeBeam.UltimateAuth.Core.Domain;

public enum CredentialSessionBehavior
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CodeBeam.UltimateAuth.Core.Options;
namespace CodeBeam.UltimateAuth.Core.Domain;

/// <summary>
/// Identifies the type of application participating in the UltimateAuth ecosystem.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CodeBeam.UltimateAuth.Core;
namespace CodeBeam.UltimateAuth.Core.Domain;

/// <summary>
/// Defines the authentication execution model for UltimateAuth.
Expand Down Expand Up @@ -34,7 +34,7 @@ public enum UAuthMode

/// <summary>
/// Pure JWT mode.
/// Fully stateless authentication.
/// Fully stateless authentication with stateful refresh.
/// No session, no server-side lookup.
/// Revocation only via token expiration.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,78 +1,27 @@
using CodeBeam.UltimateAuth.Core.Abstractions;
using CodeBeam.UltimateAuth.Core.Infrastructure;
using CodeBeam.UltimateAuth.Core.Options;
using CodeBeam.UltimateAuth.Core.Runtime;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;

namespace CodeBeam.UltimateAuth.Core.Extensions;

/// <summary>
/// Provides extension methods for registering UltimateAuth core services into the application's dependency injection container.
///
/// These methods configure options, validators, converters, and factories required for the authentication subsystem.
/// These methods required for the authentication subsystem.
///
/// IMPORTANT:
/// This extension registers only CORE services — session stores, token factories, PKCE handlers, and any server-specific
/// logic must be added from the Server package (e.g., AddUltimateAuthServer()).
/// </summary>
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddUltimateAuth(this IServiceCollection services, Action<UAuthOptions>? configure = null)
public static IServiceCollection AddUltimateAuth(this IServiceCollection services)
{
ArgumentNullException.ThrowIfNull(services);

var optionsBuilder = services.AddOptions<UAuthOptions>();

if (configure is not null)
{
optionsBuilder.Configure<DirectCoreConfigurationMarker>((options, marker) =>
{
marker.MarkConfigured();
configure(options);
});
}

optionsBuilder.BindConfiguration("UltimateAuth:Core");

services.TryAddSingleton<IPostConfigureOptions<UAuthOptions>>(sp =>
{
var marker = sp.GetRequiredService<DirectCoreConfigurationMarker>();
var config = sp.GetService<IConfiguration>();

return new CoreConfigurationIntentDetector(marker, config);
});

return services.AddUltimateAuthInternal();
}

/// <summary>
/// Internal shared registration pipeline invoked by all AddUltimateAuth overloads.
/// Registers validators, user ID converters, and placeholder factories.
/// Core-level invariant validation.
/// Server layer may add additional validators.
/// NOTE:
/// This method does not register session stores or server-side services.
/// A server project must explicitly call:
/// "services.AddUltimateAuthSessionStore'TStore'();"
/// to provide a concrete ISessionStore implementation.
/// </summary>
private static IServiceCollection AddUltimateAuthInternal(this IServiceCollection services)
{
services.TryAddSingleton<DirectCoreConfigurationMarker>();
services.AddSingleton<IPostConfigureOptions<UAuthOptions>, UAuthOptionsPostConfigureGuard>();


services.AddSingleton<IValidateOptions<UAuthOptions>, UAuthOptionsValidator>();
services.AddSingleton<IValidateOptions<UAuthSessionOptions>, UAuthSessionOptionsValidator>();
services.AddSingleton<IValidateOptions<UAuthTokenOptions>, UAuthTokenOptionsValidator>();
services.AddSingleton<IValidateOptions<UAuthLoginOptions>, UAuthLoginOptionsValidator>();
services.AddSingleton<IValidateOptions<UAuthPkceOptions>, UAuthPkceOptionsValidator>();
services.AddSingleton<IValidateOptions<UAuthMultiTenantOptions>, UAuthMultiTenantOptionsValidator>();

services.AddSingleton<IUserIdConverterResolver, UAuthUserIdConverterResolver>();
services.TryAddSingleton<IUserIdConverterResolver, UAuthUserIdConverterResolver>();
services.TryAddSingleton<IUAuthProductInfoProvider, UAuthProductInfoProvider>();
services.TryAddSingleton<IUserAgentParser, UAuthUserAgentParser>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CodeBeam.UltimateAuth.Core.Abstractions;
using CodeBeam.UltimateAuth.Core.Contracts;
using CodeBeam.UltimateAuth.Core.Options;
using CodeBeam.UltimateAuth.Core.Domain;

namespace CodeBeam.UltimateAuth.Core.Infrastructure;

Expand Down

This file was deleted.

55 changes: 0 additions & 55 deletions src/CodeBeam.UltimateAuth.Core/Options/UAuthOptions.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading