Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ PublishScripts/

# NuGet Packages
*.nupkg
nupkgs/
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
Expand Down
27 changes: 27 additions & 0 deletions .ultimateauth/pack.bat.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@echo off

echo ==============================
echo Packing UltimateAuth packages
echo ==============================

REM eski paketleri temizle
if exist nupkgs (
echo Cleaning old packages...
rmdir /s /q nupkgs
)

REM pack işlemi
echo Running dotnet pack...
dotnet pack -c Release -o ./nupkgs

REM sonuç kontrol
if %errorlevel% neq 0 (
echo ❌ Pack failed!
pause
exit /b %errorlevel%
)

echo ✅ Pack completed successfully!
echo Packages are in /nupkgs

pause
27 changes: 27 additions & 0 deletions .ultimateauth/package.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@echo off

echo ==============================
echo Packing UltimateAuth packages
echo ==============================

REM eski paketleri temizle
if exist nupkgs (
echo Cleaning old packages...
rmdir /s /q nupkgs
)

REM pack işlemi
echo Running dotnet pack...
dotnet pack -c Release -o ./nupkgs

REM sonuç kontrol
if %errorlevel% neq 0 (
echo ❌ Pack failed!
pause
exit /b %errorlevel%
)

echo ✅ Pack completed successfully!
echo Packages are in /nupkgs

pause
21 changes: 21 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>
<PropertyGroup>
<Version>0.1.0-preview.1</Version>
<NoWarn>$(NoWarn);1591</NoWarn>

<Authors>CodeBeam</Authors>
<Company>CodeBeam</Company>

<RepositoryUrl>https://github.com/CodeBeamOrg/UltimateAuth</RepositoryUrl>
<PackageProjectUrl>https://github.com/CodeBeamOrg/UltimateAuth</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
14 changes: 11 additions & 3 deletions UltimateAuth.slnx
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
<Solution>
<Folder Name="/Packages/">
<Project Path="nuget/CodeBeam.UltimateAuth.EntityFrameworkCore/CodeBeam.UltimateAuth.EntityFrameworkCoreReference.csproj" Id="764569b4-dd5b-4a18-a332-7307d20ee21a" />
<Project Path="nuget/CodeBeam.UltimateAuth.InMemory/CodeBeam.UltimateAuth.InMemoryReference.csproj" />
</Folder>
<Folder Name="/Samples/">
<Project Path="samples/blazor-server/CodeBeam.UltimateAuth.Sample.BlazorServer/CodeBeam.UltimateAuth.Sample.BlazorServer.csproj" />
<Project Path="samples/blazor-standalone-wasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm/CodeBeam.UltimateAuth.Sample.BlazorStandaloneWasm.csproj" Id="27bd3c4d-65a9-4c70-a6c9-4178b1897730" />
<Project Path="samples/resource-api/CodeBeam.UltimateAuth.Sample.ResourceApi/CodeBeam.UltimateAuth.Sample.ResourceApi.csproj" Id="3d877c9b-65eb-45be-b259-431b2d386736" />
<Project Path="samples/UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub/CodeBeam.UltimateAuth.Sample.UAuthHub.csproj" Id="ae5368ee-10aa-4c75-9653-a7f481849834" />
</Folder>
<Folder Name="/Solution Items/">
<File Path="Directory.Build.props" />
<File Path="Readme.md" />
<File Path="Roadmap.md" />
</Folder>
<Folder Name="/Tests/">
<Project Path="tests/CodeBeam.UltimateAuth.Tests.Unit/CodeBeam.UltimateAuth.Tests.Unit.csproj" Id="6f4b22da-849a-4a79-b5c5-aee7cb1429a6" />
</Folder>
<Project Path="src/authentication/CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore/CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore.csproj" Id="a8d758ad-052e-4331-9bf7-280ea9a55981" />
<Project Path="src/authentication/CodeBeam.UltimateAuth.Authentication.InMemory/CodeBeam.UltimateAuth.Authentication.InMemory.csproj" Id="bd87e254-0565-4fc5-950d-ee5bbb416079" />
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Contracts/CodeBeam.UltimateAuth.Authorization.Contracts.csproj" Id="40a23002-f885-42a8-bdd9-fd962ab28742" />
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore/CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.csproj" Id="8572d1e8-db32-42a1-b61c-e8805e59c019" />
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.InMemory/CodeBeam.UltimateAuth.Authorization.InMemory.csproj" Id="a1e6d007-bdc0-4574-b549-ec863757edd3" />
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization.Reference/CodeBeam.UltimateAuth.Authorization.Reference.csproj" Id="84b784d0-bb48-406a-a0d1-c600da667597" />
<Project Path="src/authorization/CodeBeam.UltimateAuth.Authorization/CodeBeam.UltimateAuth.Authorization.csproj" Id="28b1d647-fb0b-4cc3-8503-2680c4a9b28f" />
<Project Path="src/CodeBeam.UltimateAuth.Client.JsMinifier/CodeBeam.UltimateAuth.Client.JsMinifier.csproj" Id="ef5cfc86-bfd3-4f81-a973-ce7ef58e7525" />
<Project Path="src/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj" Id="eb60a3b7-ba9d-48c9-98ad-b28e879b23bf" />
<Project Path="src/client/CodeBeam.UltimateAuth.Client/CodeBeam.UltimateAuth.Client.csproj" Id="fa128a9b-613c-4762-993a-2886280d3051" />
<Project Path="src\client/CodeBeam.UltimateAuth.Client.JsMinifier/CodeBeam.UltimateAuth.Client.JsMinifier.csproj" Id="ef5cfc86-bfd3-4f81-a973-ce7ef58e7525" />
<Project Path="src/client/CodeBeam.UltimateAuth.Client.Blazor/CodeBeam.UltimateAuth.Client.Blazor.csproj" Id="eb60a3b7-ba9d-48c9-98ad-b28e879b23bf" />
<Project Path="src/CodeBeam.UltimateAuth.Core/CodeBeam.UltimateAuth.Core.csproj" />
<Project Path="src/CodeBeam.UltimateAuth.Server/CodeBeam.UltimateAuth.Server.csproj" Id="0a8cdd12-a8c4-4530-87e8-ae778c46322b" />
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.Contracts/CodeBeam.UltimateAuth.Credentials.Contracts.csproj" Id="88b70848-fa74-40ea-bf34-3fa2f70f4f37" />
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore/CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.csproj" Id="1fd362d5-864b-4bb3-97be-9095d94cfdba" />
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.InMemory/CodeBeam.UltimateAuth.Credentials.InMemory.csproj" Id="62ee7b1d-46ce-4f2e-985d-1e794f891b8b" />
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials.Reference/CodeBeam.UltimateAuth.Credentials.Reference.csproj" Id="ca03a140-f3dc-4a21-9b7d-895a3b10808b" />
<Project Path="src/credentials/CodeBeam.UltimateAuth.Credentials/CodeBeam.UltimateAuth.Credentials.csproj" Id="2281c3b5-1d60-4542-a673-553f96eed25b" />
<Project Path="src/persistence/CodeBeam.UltimateAuth.EntityFrameworkCore.Abstractions/CodeBeam.UltimateAuth.EntityFrameworkCore.Abstractions.csproj" Id="8867767d-bd1b-4d51-ac3f-0979038165c9" />
<Project Path="src/persistence/CodeBeam.UltimateAuth.EntityFrameworkCore/CodeBeam.UltimateAuth.EntityFrameworkCore.csproj" Id="8867767d-bd1b-4d51-ac3f-0979038165c9" />
<Project Path="src/persistence/CodeBeam.UltimateAuth.InMemory/CodeBeam.UltimateAuth.InMemory.csproj" Id="68de660f-3eb8-4922-b8eb-7ad7c97217ab" />
<Project Path="src/policies/CodeBeam.UltimateAuth.Policies/CodeBeam.UltimateAuth.Policies.csproj" Id="b37c337f-2446-4f54-8684-b72fa83ac444" />
<Project Path="src/security/CodeBeam.UltimateAuth.Security.Argon2/CodeBeam.UltimateAuth.Security.Argon2.csproj" Id="6abfb7a6-ea36-42db-a843-38054dd40fd8" />
<Project Path="src/sessions/CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore/CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.csproj" Id="5b9a090d-1689-4a81-9dfa-3ba69f0bda38" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.0-preview.1</Version>
<InformationalVersion>0.1.0-preview.1</InformationalVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\authentication\CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore\CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore\CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\authorization\CodeBeam.UltimateAuth.Authorization.Reference\CodeBeam.UltimateAuth.Authorization.Reference.csproj" />
<ProjectReference Include="..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore\CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\credentials\CodeBeam.UltimateAuth.Credentials.Reference\CodeBeam.UltimateAuth.Credentials.Reference.csproj" />
<ProjectReference Include="..\..\src\sessions\CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore\CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\tokens\CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore\CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\users\CodeBeam.UltimateAuth.Users.EntityFrameworkCore\CodeBeam.UltimateAuth.Users.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\users\CodeBeam.UltimateAuth.Users.Reference\CodeBeam.UltimateAuth.Users.Reference.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Microsoft.EntityFrameworkCore;

namespace CodeBeam.UltimateAuth.EntityFrameworkCore
{
/// <summary>
/// Provides configuration options for setting up Entity Framework Core database contexts used by the UltimateAuth
/// system.
/// </summary>
/// <remarks>Use this class to specify delegates that configure the options for various DbContext
/// instances, such as Users, Credentials, Authorization, Sessions, Tokens, and Authentication. Each property allows
/// customization of the corresponding context's setup, including database provider and connection details. If a
/// specific configuration delegate is not set for a context, the default configuration is applied. This class is
/// typically configured during application startup to ensure consistent and flexible database context
/// initialization.</remarks>
public sealed class UAuthEfCoreOptions
{
/// <summary>
/// Gets or sets the default action to configure the database context options builder.
/// </summary>
/// <remarks>Use this property to specify a delegate that applies default configuration to a
/// DbContextOptionsBuilder instance. This action is typically invoked when setting up a new database context to
/// ensure consistent configuration across the application.</remarks>
public Action<DbContextOptionsBuilder>? Default { get; set; }


/// <summary>
/// Gets or sets the delegate used to configure options for the Users DbContext.
/// If not set, default option will implement.
/// </summary>
/// <remarks>Assign a delegate to customize the configuration of the Users DbContext, such as
/// specifying the database provider or connection string. This property is typically used during application
/// startup to control how the Users context is set up.</remarks>
public Action<DbContextOptionsBuilder>? Users { get; set; }

/// <summary>
/// Gets or sets the delegate used to configure options for the Credentials DbContext.
/// If not set, default option will implement.
/// </summary>
/// <remarks>Assign a delegate to customize the configuration of the Credentials DbContext, such as
/// specifying the database provider or connection string. This property is typically used during application
/// startup to control how the Credentials context is set up.</remarks>
public Action<DbContextOptionsBuilder>? Credentials { get; set; }

/// <summary>
/// Gets or sets the delegate used to configure options for the Authorization DbContext.
/// If not set, default option will implement.
/// </summary>
/// <remarks>Assign a delegate to customize the configuration of the Authorization DbContext, such as
/// specifying the database provider or connection string. This property is typically used during application
/// startup to control how the Authorization context is set up.</remarks>
public Action<DbContextOptionsBuilder>? Authorization { get; set; }

/// <summary>
/// Gets or sets the delegate used to configure options for the Sessions DbContext.
/// If not set, default option will implement.
/// </summary>
/// <remarks>Assign a delegate to customize the configuration of the Sessions DbContext, such as
/// specifying the database provider or connection string. This property is typically used during application
/// startup to control how the Sessions context is set up.</remarks>
public Action<DbContextOptionsBuilder>? Sessions { get; set; }

/// <summary>
/// Gets or sets the delegate used to configure options for the Tokens DbContext.
/// If not set, default option will implement.
/// </summary>
/// <remarks>Assign a delegate to customize the configuration of the Tokens DbContext, such as
/// specifying the database provider or connection string. This property is typically used during application
/// startup to control how the Tokens context is set up.</remarks>
public Action<DbContextOptionsBuilder>? Tokens { get; set; }

/// <summary>
/// Gets or sets the delegate used to configure options for the Authentication DbContext.
/// If not set, default option will implement.
/// </summary>
/// <remarks>Assign a delegate to customize the configuration of the Authentication DbContext, such as
/// specifying the database provider or connection string. This property is typically used during application
/// startup to control how the Authentication context is set up.</remarks>
public Action<DbContextOptionsBuilder>? Authentication { get; set; }

internal Action<DbContextOptionsBuilder> Resolve(Action<DbContextOptionsBuilder>? specific)
=> specific ?? Default ?? throw new InvalidOperationException("No database configuration provided for UltimateAuth EFCore. Use options.Default or configure specific DbContext options.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using CodeBeam.UltimateAuth.Authentication.EntityFrameworkCore.Extensions;
using CodeBeam.UltimateAuth.Authorization.EntityFrameworkCore.Extensions;
using CodeBeam.UltimateAuth.Authorization.Reference.Extensions;
using CodeBeam.UltimateAuth.Credentials.EntityFrameworkCore.Extensions;
using CodeBeam.UltimateAuth.Credentials.Reference.Extensions;
using CodeBeam.UltimateAuth.Sessions.EntityFrameworkCore.Extensions;
using CodeBeam.UltimateAuth.Tokens.EntityFrameworkCore.Extensions;
using CodeBeam.UltimateAuth.Users.EntityFrameworkCore.Extensions;
using CodeBeam.UltimateAuth.Users.Reference.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace CodeBeam.UltimateAuth.EntityFrameworkCore;

/// <summary>
/// Provides extension methods for registering UltimateAuth with Entity Framework Core-based persistence using reference
/// domain implementations.
/// </summary>
public static class UltimateAuthEntityFrameworkCoreExtensions
{
/// <summary>
/// Registers UltimateAuth with Entity Framework Core based persistence using reference domain implementations.
/// </summary>
/// <param name="services">The service collection.</param>
/// <param name="configureDb">
/// A delegate used to configure the <see cref="DbContextOptionsBuilder"/> for all UltimateAuth DbContexts.
///
/// This is required and must specify a database provider such as:
/// <list type="bullet">
/// <item><description>UseSqlServer</description></item>
/// <item><description>UseNpgsql</description></item>
/// <item><description>UseSqlite</description></item>
/// </list>
/// </param>
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
/// <remarks>
/// This method wires up all Entity Framework Core stores along with reference domain implementations.
///
/// Example:
/// <code>
/// services.AddUltimateAuthServer()
/// .AddEntityFrameworkReference(options =>
/// {
/// options.UseSqlServer("connection-string");
/// });
/// </code>
///
/// Note:
/// This method does not configure migrations automatically. You are responsible for managing migrations.
/// </remarks>
public static IServiceCollection AddEntityFrameworkReference(this IServiceCollection services, Action<DbContextOptionsBuilder> configureDb)
{
services
.AddUltimateAuthUsersEntityFrameworkCore(configureDb)
.AddUltimateAuthUsersReference()
.AddUltimateAuthCredentialsEntityFrameworkCore(configureDb)
.AddUltimateAuthCredentialsReference()
.AddUltimateAuthAuthorizationEntityFrameworkCore(configureDb)
.AddUltimateAuthAuthorizationReference()
.AddUltimateAuthSessionsEntityFrameworkCore(configureDb)
.AddUltimateAuthTokensEntityFrameworkCore(configureDb)
.AddUltimateAuthAuthenticationEntityFrameworkCore(configureDb);

return services;
}

/// <summary>
/// Adds and configures Entity Framework Core-based UltimateAuth services and related references to the specified
/// service collection.
/// </summary>
/// <remarks>This method registers all required UltimateAuth services for users, credentials,
/// authorization, sessions, tokens, and authentication using Entity Framework Core. It should be called during
/// application startup as part of service configuration.</remarks>
/// <param name="services">The service collection to which the UltimateAuth Entity Framework Core services and references will be added.</param>
/// <param name="configure">A delegate that configures the options for UltimateAuth Entity Framework Core integration.</param>
/// <returns>The same service collection instance, enabling method chaining.</returns>
public static IServiceCollection AddEntityFrameworkReference(this IServiceCollection services, Action<UAuthEfCoreOptions> configure)
{
var options = new UAuthEfCoreOptions();
configure(options);

services
.AddUltimateAuthUsersEntityFrameworkCore(options.Resolve(options.Users))
.AddUltimateAuthUsersReference()
.AddUltimateAuthCredentialsEntityFrameworkCore(options.Resolve(options.Credentials))
.AddUltimateAuthCredentialsReference()
.AddUltimateAuthAuthorizationEntityFrameworkCore(options.Resolve(options.Authorization))
.AddUltimateAuthAuthorizationReference()
.AddUltimateAuthSessionsEntityFrameworkCore(options.Resolve(options.Sessions))
.AddUltimateAuthTokensEntityFrameworkCore(options.Resolve(options.Tokens))
.AddUltimateAuthAuthenticationEntityFrameworkCore(options.Resolve(options.Authentication));

return services;
}
}
Loading
Loading