Skip to content

Commit 59343a4

Browse files
authored
Merge pull request #10 from RockSolidKnowledge/feature/custom-schema
Upgrade .net version and support custom dbSchema
2 parents 66fe3ce + d93c2f8 commit 59343a4

17 files changed

Lines changed: 383 additions & 304 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v2
19-
- name: Setup .NET Core 3.1
20-
uses: actions/setup-dotnet@v1
19+
- name: Setup .NET 8
20+
uses: actions/setup-dotnet@v4
2121
with:
22-
dotnet-version: '3.1.x'
23-
- name: Setup .NET 5.0
24-
uses: actions/setup-dotnet@v1
22+
dotnet-version: '8.x'
23+
- name: Setup .NET 9
24+
uses: actions/setup-dotnet@v4
2525
with:
26-
dotnet-version: '5.0.x'
27-
- name: Setup .NET 6.0
28-
uses: actions/setup-dotnet@v1
26+
dotnet-version: '9.x'
27+
- name: Setup .NET 10
28+
uses: actions/setup-dotnet@v4
2929
with:
30-
dotnet-version: '6.0.x'
30+
dotnet-version: '10.x'
3131
- name: Fix Windows VM bug
3232
shell: bash
3333
if: matrix.os == 'windows-latest'
@@ -44,7 +44,7 @@ jobs:
4444
run: dotnet pack -c Release
4545
- name: Publish artifact
4646
if: matrix.os == 'ubuntu-latest'
47-
uses: actions/upload-artifact@v2
47+
uses: actions/upload-artifact@v4
4848
with:
4949
name: nupkg
5050
path: '**/*.nupkg'

NuGet.AzDO.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4-
<add key="rsk-shared" value="https://pkgs.dev.azure.com/rocksolidknowledge/_packaging/RSKTools/nuget/v3/index.json" />
4+
<!-- <add key="rsk-shared" value="https://pkgs.dev.azure.com/rocksolidknowledge/_packaging/RSKTools/nuget/v3/index.json" /> -->
55
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
66
<add key="LocalNuget" value="../s/LocalNuget" />
77
</packageSources>

azure-pipelines.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ variables:
77
- name: buildConfiguration
88
value: 'Release'
99
- name: packageVersion
10-
value: '2.0.0.0'
10+
value: '3.0.0.0'
1111
- name: efPackageVersion
12-
value: '2.0.0.0'
13-
- name: identityPackageVersion
1412
value: '3.0.0.0'
13+
- name: identityPackageVersion
14+
value: '4.0.0.0'
1515
- name: RunSqlServerTest
1616
value: 'true'
1717
stages:
@@ -40,22 +40,22 @@ stages:
4040
mkdir LocalNuget
4141
workingDirectory: $(Build.SourcesDirectory)
4242
- task: UseDotNet@2
43-
displayName: Install .NET Core sdk version 5.x
43+
displayName: Install .NET Core sdk version 8.x
4444
inputs:
4545
packageType: sdk
46-
version: 5.x
46+
version: 8.x
4747
installationPath: $(Agent.ToolsDirectory)/dotnet
4848
- task: UseDotNet@2
49-
displayName: Install .NET Core sdk version 3.1.x
49+
displayName: Install .NET Core sdk version 9.x
5050
inputs:
5151
packageType: sdk
52-
version: 3.1.x
52+
version: 9.x
5353
installationPath: $(Agent.ToolsDirectory)/dotnet
5454
- task: UseDotNet@2
55-
displayName: Install .NET Core sdk version 6.0.x
55+
displayName: Install .NET Core sdk version 10.x
5656
inputs:
5757
packageType: sdk
58-
version: 6.0.x
58+
version: 10.x
5959
installationPath: $(Agent.ToolsDirectory)/dotnet
6060
- task: NuGetToolInstaller@0
6161
inputs:

src/RSK.IdentityServer4.AuditEventSink/RSK.IdentityServer4.AuditEventSink.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

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

1717
<ItemGroup>
1818
<PackageReference Include="IdentityServer4" Version="3.1.0" />
19-
<PackageReference Include="Rsk.Audit" Version="1.1.1" />
19+
<ProjectReference Include="..\Rsk.Audit\Rsk.Audit.csproj" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

src/Rsk.Audit.EF/AuditDatabaseContext.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ namespace RSK.Audit.EF
77
internal class AuditDatabseUnitOfWorkFactory : IUnitOfOWorkFactory
88
{
99
private readonly DbContextOptions<AuditDatabaseContext> options;
10+
private readonly string dbSchema;
1011

11-
public AuditDatabseUnitOfWorkFactory(DbContextOptions<AuditDatabaseContext> options)
12+
public AuditDatabseUnitOfWorkFactory(DbContextOptions<AuditDatabaseContext> options, string dbSchema = null)
1213
{
1314
this.options = options;
14-
15+
this.dbSchema = dbSchema;
1516
}
1617

1718
public IUnitOfWork Create()
1819
{
20+
if (!string.IsNullOrEmpty(dbSchema))
21+
{
22+
return new AuditDatabaseContext(options, dbSchema);
23+
}
1924
return new AuditDatabaseContext(options);
2025
}
2126
}
@@ -27,11 +32,23 @@ public AuditDatabaseContext(DbContextOptions<AuditDatabaseContext> options) : ba
2732

2833
}
2934

35+
public AuditDatabaseContext(DbContextOptions<AuditDatabaseContext> options, string schema) : base(options)
36+
{
37+
Schema = schema;
38+
}
39+
40+
public string Schema { get; set; }
41+
3042
public DbSet<AuditEntity> AuditEntries { get; set; }
3143

3244

3345
protected override void OnModelCreating(ModelBuilder modelBuilder)
3446
{
47+
if (!string.IsNullOrEmpty(Schema))
48+
{
49+
modelBuilder.Model.SetOrRemoveAnnotation("Relational:DefaultSchema", Schema);
50+
}
51+
3552
modelBuilder.Entity<AuditEntity>()
3653
.HasKey(ae => ae.Id);
3754

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

4158
modelBuilder.Entity<AuditEntity>()
4259
.Property(e => e.When);
43-
44-
45-
60+
4661

4762
base.OnModelCreating(modelBuilder);
4863
}

src/Rsk.Audit.EF/AuditProviderFactory.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@ namespace RSK.Audit.EF
55
public class AuditProviderFactory : Audit.AuditProviderFactory
66
{
77
private readonly DbContextOptions<AuditDatabaseContext> options;
8+
private readonly string dbSchema;
89

9-
public AuditProviderFactory(DbContextOptions<AuditDatabaseContext> options)
10+
public AuditProviderFactory(DbContextOptions<AuditDatabaseContext> options, string dbSchema = null)
1011
{
1112
this.options = options;
13+
this.dbSchema = dbSchema;
1214
}
1315

1416
public override IRecordAuditableActions CreateAuditSource(string source)
1517
{
16-
var uwf = new AuditDatabseUnitOfWorkFactory(options);
18+
var uwf = !string.IsNullOrWhiteSpace(dbSchema) ?
19+
new AuditDatabseUnitOfWorkFactory(options, dbSchema) :
20+
new AuditDatabseUnitOfWorkFactory(options);
1721

1822
return new AuditRecorder(source,uwf);
1923
}
2024

2125
public override IQueryableAuditableActions CreateAuditQuery()
2226
{
23-
var uwf = new AuditDatabseUnitOfWorkFactory(options);
27+
var uwf = !string.IsNullOrWhiteSpace(dbSchema) ?
28+
new AuditDatabseUnitOfWorkFactory(options, dbSchema) :
29+
new AuditDatabseUnitOfWorkFactory(options);
2430

2531
return new AuditQueryFactory(uwf);
2632
}

src/Rsk.Audit.EF/Rsk.Audit.EF.csproj

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

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

2020
<!--don't warn about missing comments-->
2121
<PropertyGroup>
2222
<NoWarn>1591</NoWarn>
2323
</PropertyGroup>
2424

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

29-
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
30-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
29+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
30+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
3131
</ItemGroup>
3232

33-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
34-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
33+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
34+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
3535
</ItemGroup>
3636

37-
<ItemGroup Condition="'$(LOCALNUGET)' != 'true'">
37+
<ItemGroup>
3838
<ProjectReference Include="..\Rsk.Audit\Rsk.Audit.csproj" />
3939
</ItemGroup>
4040

41-
<ItemGroup Condition="'$(LOCALNUGET)' == 'true'">
42-
<PackageReference Include="Rsk.Audit" Version="$(coreVersion)" />
43-
</ItemGroup>
44-
4541
<ItemGroup>
4642
<None Include="..\..\icon.png" Pack="true" PackagePath="icon.png" />
4743
</ItemGroup>

src/Rsk.Audit/Rsk.Audit.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<PackageId>RSK.Audit</PackageId>
66
<Authors>Rock Solid Knowledge Ltd</Authors>
77
<Product>RSK.Audit</Product>
@@ -15,24 +15,24 @@
1515
<PackageIcon>icon.png</PackageIcon>
1616
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1717
<RootNamespace>RSK.Audit</RootNamespace>
18-
<Version>2.0.0</Version>
18+
<Version>3.0.0</Version>
1919
</PropertyGroup>
2020

2121
<!--don't warn about missing comments-->
2222
<PropertyGroup>
2323
<NoWarn>1591</NoWarn>
2424
</PropertyGroup>
2525

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

30-
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
31-
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="5.0.0" />
30+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
31+
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.11" />
3232
</ItemGroup>
33-
34-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
35-
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="6.0.2" />
33+
34+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
35+
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.0" />
3636
</ItemGroup>
3737

3838
<ItemGroup>

src/Rsk.DuendeIdentityServer.AuditEventSink/Rsk.DuendeIdentityServer.AuditEventSink.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

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

1717
<ItemGroup>
1818
<PackageReference Include="Duende.IdentityServer" Version="6.0.0" />
19-
<PackageReference Include="Rsk.Audit" Version="1.1.1" />
19+
<PackageReference Include="Rsk.Audit" Version="2.0.0" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

tests/Rsk.Audit.Tests.Common/Rsk.Audit.Tests.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>

0 commit comments

Comments
 (0)