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
20 changes: 10 additions & 10 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '3.1.x'
- name: Setup .NET 5.0
uses: actions/setup-dotnet@v1
dotnet-version: '8.x'
- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '5.0.x'
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
dotnet-version: '9.x'
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '10.x'
- name: Fix Windows VM bug
shell: bash
if: matrix.os == 'windows-latest'
Expand All @@ -44,7 +44,7 @@ jobs:
run: dotnet pack -c Release
- name: Publish artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: nupkg
path: '**/*.nupkg'
2 changes: 1 addition & 1 deletion NuGet.AzDO.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="rsk-shared" value="https://pkgs.dev.azure.com/rocksolidknowledge/_packaging/RSKTools/nuget/v3/index.json" />
<!-- <add key="rsk-shared" value="https://pkgs.dev.azure.com/rocksolidknowledge/_packaging/RSKTools/nuget/v3/index.json" /> -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="LocalNuget" value="../s/LocalNuget" />
</packageSources>
Expand Down
18 changes: 9 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ variables:
- name: buildConfiguration
value: 'Release'
- name: packageVersion
value: '2.0.0.0'
value: '3.0.0.0'
- name: efPackageVersion
value: '2.0.0.0'
- name: identityPackageVersion
value: '3.0.0.0'
- name: identityPackageVersion
value: '4.0.0.0'
- name: RunSqlServerTest
value: 'true'
stages:
Expand Down Expand Up @@ -40,22 +40,22 @@ stages:
mkdir LocalNuget
workingDirectory: $(Build.SourcesDirectory)
- task: UseDotNet@2
displayName: Install .NET Core sdk version 5.x
displayName: Install .NET Core sdk version 8.x
inputs:
packageType: sdk
version: 5.x
version: 8.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: UseDotNet@2
displayName: Install .NET Core sdk version 3.1.x
displayName: Install .NET Core sdk version 9.x
inputs:
packageType: sdk
version: 3.1.x
version: 9.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: UseDotNet@2
displayName: Install .NET Core sdk version 6.0.x
displayName: Install .NET Core sdk version 10.x
inputs:
packageType: sdk
version: 6.0.x
version: 10.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: NuGetToolInstaller@0
inputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<Authors>Rock Solid Knowledge Ltd</Authors>
<Description>IdentityServer4 event sink to add audit records into AdminUI auditing</Description>
<PackageProjectUrl>https://github.com/RockSolidKnowledge/RSK.IdentityServer4.AuditEventSink</PackageProjectUrl>
<PackageReleaseNotes>Updated to support only ASP.NET Core 3.1 and fixed actor type for consent granted event.</PackageReleaseNotes>
<PackageReleaseNotes>Upgrade to .NET 10</PackageReleaseNotes>
<Copyright>Copyright 2021 (c) Rock Solid Knowledge Ltd. All rights reserved</Copyright>
<PackageTags>Audit AdminUI IdentityServer Events</PackageTags>
<IncludeSymbols>true</IncludeSymbols>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Version>1.1.1</Version>
<Version>2.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IdentityServer4" Version="3.1.0" />
<PackageReference Include="Rsk.Audit" Version="1.1.1" />
<ProjectReference Include="..\Rsk.Audit\Rsk.Audit.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 20 additions & 5 deletions src/Rsk.Audit.EF/AuditDatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ namespace RSK.Audit.EF
internal class AuditDatabseUnitOfWorkFactory : IUnitOfOWorkFactory
{
private readonly DbContextOptions<AuditDatabaseContext> options;
private readonly string dbSchema;

public AuditDatabseUnitOfWorkFactory(DbContextOptions<AuditDatabaseContext> options)
public AuditDatabseUnitOfWorkFactory(DbContextOptions<AuditDatabaseContext> options, string dbSchema = null)
{
this.options = options;

this.dbSchema = dbSchema;
}

public IUnitOfWork Create()
{
if (!string.IsNullOrEmpty(dbSchema))
{
return new AuditDatabaseContext(options, dbSchema);
}
return new AuditDatabaseContext(options);
}
}
Expand All @@ -27,11 +32,23 @@ public AuditDatabaseContext(DbContextOptions<AuditDatabaseContext> options) : ba

}

public AuditDatabaseContext(DbContextOptions<AuditDatabaseContext> options, string schema) : base(options)
{
Schema = schema;
}

public string Schema { get; set; }

public DbSet<AuditEntity> AuditEntries { get; set; }


protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (!string.IsNullOrEmpty(Schema))
{
modelBuilder.Model.SetOrRemoveAnnotation("Relational:DefaultSchema", Schema);
}

modelBuilder.Entity<AuditEntity>()
.HasKey(ae => ae.Id);

Expand All @@ -40,9 +57,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<AuditEntity>()
.Property(e => e.When);





base.OnModelCreating(modelBuilder);
}
Expand Down
12 changes: 9 additions & 3 deletions src/Rsk.Audit.EF/AuditProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ namespace RSK.Audit.EF
public class AuditProviderFactory : Audit.AuditProviderFactory
{
private readonly DbContextOptions<AuditDatabaseContext> options;
private readonly string dbSchema;

public AuditProviderFactory(DbContextOptions<AuditDatabaseContext> options)
public AuditProviderFactory(DbContextOptions<AuditDatabaseContext> options, string dbSchema = null)
{
this.options = options;
this.dbSchema = dbSchema;
}

public override IRecordAuditableActions CreateAuditSource(string source)
{
var uwf = new AuditDatabseUnitOfWorkFactory(options);
var uwf = !string.IsNullOrWhiteSpace(dbSchema) ?
new AuditDatabseUnitOfWorkFactory(options, dbSchema) :
new AuditDatabseUnitOfWorkFactory(options);

return new AuditRecorder(source,uwf);
}

public override IQueryableAuditableActions CreateAuditQuery()
{
var uwf = new AuditDatabseUnitOfWorkFactory(options);
var uwf = !string.IsNullOrWhiteSpace(dbSchema) ?
new AuditDatabseUnitOfWorkFactory(options, dbSchema) :
new AuditDatabseUnitOfWorkFactory(options);

return new AuditQueryFactory(uwf);
}
Expand Down
22 changes: 9 additions & 13 deletions src/Rsk.Audit.EF/Rsk.Audit.EF.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<PackageId>RSK.Audit.EF</PackageId>
<Authors>Rock Solid Knowledge Ltd</Authors>
<Description>Provides audting API to record audit records and query api to find audit records with EntityFramework Core</Description>
Expand All @@ -14,34 +14,30 @@
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RootNamespace>RSK.Audit.EF</RootNamespace>
<Version>2.0.0</Version>
<Version>3.0.0</Version>
</PropertyGroup>

<!--don't warn about missing comments-->
<PropertyGroup>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[3.1.0,4.0.0)" />
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.22" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(LOCALNUGET)' != 'true'">
<ItemGroup>
<ProjectReference Include="..\Rsk.Audit\Rsk.Audit.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(LOCALNUGET)' == 'true'">
<PackageReference Include="Rsk.Audit" Version="$(coreVersion)" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath="icon.png" />
</ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/Rsk.Audit/Rsk.Audit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<PackageId>RSK.Audit</PackageId>
<Authors>Rock Solid Knowledge Ltd</Authors>
<Product>RSK.Audit</Product>
Expand All @@ -15,24 +15,24 @@
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RootNamespace>RSK.Audit</RootNamespace>
<Version>2.0.0</Version>
<Version>3.0.0</Version>
</PropertyGroup>

<!--don't warn about missing comments-->
<PropertyGroup>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="[3.1.0,4.0.0)" />
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.22" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="5.0.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="6.0.2" />
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<Authors>Rock Solid Knowledge Ltd</Authors>
<Description>Duende IdentityServer event sink to add audit records into AdminUI auditing</Description>
<PackageProjectUrl>https://github.com/RockSolidKnowledge/RSK.IdentityServer4.AuditEventSink</PackageProjectUrl>
<PackageReleaseNotes>Initial Duende IdentityServer release.</PackageReleaseNotes>
<PackageReleaseNotes>Upgrade to .NET 10</PackageReleaseNotes>
<Copyright>Copyright 2022 (c) Rock Solid Knowledge Ltd. All rights reserved</Copyright>
<PackageTags>Audit AdminUI IdentityServer Events</PackageTags>
<IncludeSymbols>true</IncludeSymbols>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Version>3.0.0</Version>
<Version>4.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" Version="6.0.0" />
<PackageReference Include="Rsk.Audit" Version="1.1.1" />
<PackageReference Include="Rsk.Audit" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/Rsk.Audit.Tests.Common/Rsk.Audit.Tests.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
45 changes: 45 additions & 0 deletions tests/Rsk.Audit.Tests.Integration/EF/AuditDatabaseContextTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using RSK.Audit.EF;
using Xunit;

namespace Rsk.Audit.Tests.Integration.EF;

[Collection("AuditDatabaseContextTests")]

public class AuditDatabaseContextTests
{
[Fact]
public void Ctor_WhenCalledWithSchema_ExpectThatSchemaSetInTheDatabase()
{
string schema = "guest";

var dbContextOptions = new DbContextOptionsBuilder<AuditDatabaseContext>()
.ReplaceService<IModelCacheKeyFactory, TestModelCacheKeyFactory>()
.UseInMemoryDatabase(nameof(AuditQueryIntegrationTests) + "WithSchema")
.Options;

var databaseContext = new AuditDatabaseContext(dbContextOptions, schema);
databaseContext.Database.EnsureDeleted();
databaseContext.Database.EnsureCreated();

Assert.Equal(schema, databaseContext.Schema);
Assert.Equal(schema, databaseContext.Model["Relational:DefaultSchema"]!.ToString());
}

[Fact]
public void Ctor_WhenCalledWithoutSchema_ExpectNoSchemaSetInTheDatabase()
{
var dbContextOptions = new DbContextOptionsBuilder<AuditDatabaseContext>()
.ReplaceService<IModelCacheKeyFactory, TestModelCacheKeyFactory>()
.UseInMemoryDatabase(nameof(AuditQueryIntegrationTests) + "WithoutSchema")
.Options;

var databaseContext = new AuditDatabaseContext(dbContextOptions);
databaseContext.Database.EnsureDeleted();
databaseContext.Database.EnsureCreated();

Assert.Null(databaseContext.Schema);
Assert.Null(databaseContext.Model["Relational:DefaultSchema"]?.ToString());
}
}
Loading