Skip to content

Commit

Permalink
Merge pull request #1718 from DuendeSoftware/jmdc/7.1-templates
Browse files Browse the repository at this point in the history
IdentityServer (hosts and templates) - summarize license usage on shutdown
  • Loading branch information
josephdecock authored Jan 9, 2025
2 parents c7764f6 + dcb64d3 commit 2c9ba46
Show file tree
Hide file tree
Showing 32 changed files with 233 additions and 54 deletions.
2 changes: 1 addition & 1 deletion bff/samples/Bff.DPoP/Bff.DPoP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.4" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion bff/samples/Bff/Bff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion bff/samples/IdentityServer/IdentityServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Duende.IdentityServer" />
<PackageReference Include="Duende.IdentityModel" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IdentityModel;
using Duende.IdentityModel;
using IdentityModel.Client;

namespace ConsoleResourceIndicators
Expand Down
29 changes: 27 additions & 2 deletions identity-server/hosts/AspNetIdentity/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.

using Duende.IdentityServer.Licensing;
using IdentityServerHost;
using Serilog;
using System.Globalization;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using System.Globalization;
using System.Text;

Console.Title = "IdentityServer (AspNetIdentity)";

Expand Down Expand Up @@ -36,6 +38,16 @@
.ConfigureServices()
.ConfigurePipeline();

if (app.Environment.IsDevelopment())
{
app.Lifetime.ApplicationStopping.Register(() =>
{
var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
Console.Write(Summary(usage));
Console.ReadKey();
});
}

app.Run();
}
catch (Exception ex)
Expand All @@ -46,4 +58,17 @@
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}
}

static string Summary(LicenseUsageSummary usage)
{
var sb = new StringBuilder();
sb.AppendLine("IdentityServer Usage Summary:");
sb.AppendLine(CultureInfo.InvariantCulture, $" License: {usage.LicenseEdition}");
var features = usage.FeaturesUsed.Count > 0 ? string.Join(", ", usage.FeaturesUsed) : "None";
sb.AppendLine(CultureInfo.InvariantCulture, $" Business and Enterprise Edition Features Used: {features}");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.ClientsUsed.Count} Client Id(s) Used");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.IssuersUsed.Count} Issuer(s) Used");

return sb.ToString();
}
27 changes: 26 additions & 1 deletion identity-server/hosts/Configuration/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.

using Duende.IdentityServer.Licensing;
using IdentityServerHost;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using System.Globalization;
using System.Text;

Console.Title = "IdentityServer (Configuration)";

Expand Down Expand Up @@ -36,6 +38,16 @@
.ConfigureServices()
.ConfigurePipeline();

if (app.Environment.IsDevelopment())
{
app.Lifetime.ApplicationStopping.Register(() =>
{
var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
Console.Write(Summary(usage));
Console.ReadKey();
});
}

app.Run();
}
catch (Exception ex)
Expand All @@ -46,4 +58,17 @@
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}
}

static string Summary(LicenseUsageSummary usage)
{
var sb = new StringBuilder();
sb.AppendLine("IdentityServer Usage Summary:");
sb.AppendLine(CultureInfo.InvariantCulture, $" License: {usage.LicenseEdition}");
var features = usage.FeaturesUsed.Count > 0 ? string.Join(", ", usage.FeaturesUsed) : "None";
sb.AppendLine(CultureInfo.InvariantCulture, $" Business and Enterprise Edition Features Used: {features}");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.ClientsUsed.Count} Client Id(s) Used");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.IssuersUsed.Count} Issuer(s) Used");

return sb.ToString();
}
27 changes: 26 additions & 1 deletion identity-server/hosts/EntityFramework/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.

using Duende.IdentityServer.Licensing;
using IdentityServerHost;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using System.Globalization;
using System.Text;

Console.Title = "IdentityServer (EntityFramework)";

Expand Down Expand Up @@ -36,6 +38,16 @@
.ConfigureServices()
.ConfigurePipeline();

if (app.Environment.IsDevelopment())
{
app.Lifetime.ApplicationStopping.Register(() =>
{
var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
Console.Write(Summary(usage));
Console.ReadKey();
});
}

app.Run();
}
catch (Exception ex)
Expand All @@ -46,4 +58,17 @@
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}
}

static string Summary(LicenseUsageSummary usage)
{
var sb = new StringBuilder();
sb.AppendLine("IdentityServer Usage Summary:");
sb.AppendLine(CultureInfo.InvariantCulture, $" License: {usage.LicenseEdition}");
var features = usage.FeaturesUsed.Count > 0 ? string.Join(", ", usage.FeaturesUsed) : "None";
sb.AppendLine(CultureInfo.InvariantCulture, $" Business and Enterprise Edition Features Used: {features}");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.ClientsUsed.Count} Client Id(s) Used");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.IssuersUsed.Count} Issuer(s) Used");

return sb.ToString();
}
2 changes: 1 addition & 1 deletion templates/src/BffLocalApi/BffLocalApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Duende.BFF.Yarp" Version="2.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />

<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.3" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" version="7.0.6" />
<PackageReference Include="Duende.IdentityServer.AspNetIdentity" version="7.1.0-rc.2" />

<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.11" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />

<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.11" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Services;
using IdentityModel;
using Duende.IdentityModel;
using IdentityServerHost.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Duende.IdentityServer.Models;
using Duende.IdentityServer.Services;
using Duende.IdentityServer.Validation;
using IdentityModel;
using Duende.IdentityModel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.

using IdentityModel;
using Duende.IdentityModel;
using Microsoft.AspNetCore.Authentication;
using System.Text;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Duende.IdentityServer;
using Duende.IdentityServer.Events;
using Duende.IdentityServer.Services;
using IdentityModel;
using Duende.IdentityModel;
using IdentityServerHost.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
Expand Down
30 changes: 28 additions & 2 deletions templates/src/IdentityServerAspNetIdentity/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using IdentityServerAspNetIdentity;
using Duende.IdentityServer.Licensing;
using IdentityServerAspNetIdentity;
using Serilog;
using System.Globalization;
using System.Text;

Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
Expand Down Expand Up @@ -30,6 +33,16 @@
return;
}

if (app.Environment.IsDevelopment())
{
app.Lifetime.ApplicationStopping.Register(() =>
{
var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
Console.Write(Summary(usage));
Console.ReadKey();
});
}

app.Run();
}
catch (Exception ex) when (ex is not HostAbortedException)
Expand All @@ -40,4 +53,17 @@
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}
}

static string Summary(LicenseUsageSummary usage)
{
var sb = new StringBuilder();
sb.AppendLine("IdentityServer Usage Summary:");
sb.AppendLine(CultureInfo.InvariantCulture, $" License: {usage.LicenseEdition}");
var features = usage.FeaturesUsed.Count > 0 ? string.Join(", ", usage.FeaturesUsed) : "None";
sb.AppendLine(CultureInfo.InvariantCulture, $" Business and Enterprise Edition Features Used: {features}");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.ClientsUsed.Count} Client Id(s) Used");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.IssuersUsed.Count} Issuer(s) Used");

return sb.ToString();
}
2 changes: 1 addition & 1 deletion templates/src/IdentityServerAspNetIdentity/SeedData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Security.Claims;
using IdentityModel;
using Duende.IdentityModel;
using IdentityServerAspNetIdentity.Data;
using IdentityServerHost.Models;
using Microsoft.AspNetCore.Identity;
Expand Down
4 changes: 2 additions & 2 deletions templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer" version="7.0.6" />
<PackageReference Include="Duende.IdentityServer" version="7.1.0-rc.2" />

<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
</ItemGroup>
</Project>
32 changes: 29 additions & 3 deletions templates/src/IdentityServerEmpty/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using IdentityServerEmpty;
using Duende.IdentityServer.Licensing;
using IdentityServerEmpty;
using Serilog;
using System.Globalization;
using System.Text;

Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
Expand All @@ -19,7 +22,17 @@
var app = builder
.ConfigureServices()
.ConfigurePipeline();


if (app.Environment.IsDevelopment())
{
app.Lifetime.ApplicationStopping.Register(() =>
{
var usage = app.Services.GetRequiredService<LicenseUsageSummary>();
Console.Write(Summary(usage));
Console.ReadKey();
});
}

app.Run();
}
catch (Exception ex)
Expand All @@ -30,4 +43,17 @@
{
Log.Information("Shut down complete");
Log.CloseAndFlush();
}
}

static string Summary(LicenseUsageSummary usage)
{
var sb = new StringBuilder();
sb.AppendLine("IdentityServer Usage Summary:");
sb.AppendLine(CultureInfo.InvariantCulture, $" License: {usage.LicenseEdition}");
var features = usage.FeaturesUsed.Count > 0 ? string.Join(", ", usage.FeaturesUsed) : "None";
sb.AppendLine(CultureInfo.InvariantCulture, $" Business and Enterprise Edition Features Used: {features}");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.ClientsUsed.Count} Client Id(s) Used");
sb.AppendLine(CultureInfo.InvariantCulture, $" {usage.IssuersUsed.Count} Issuer(s) Used");

return sb.ToString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Duende.IdentityServer.EntityFramework" version="7.0.6" />
<PackageReference Include="Duende.IdentityServer.EntityFramework" version="7.1.0-rc.2" />

<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.11" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />

<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.11" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 2c9ba46

Please sign in to comment.