-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Make services private - Add public LicenseSummary - Show how to use LicenseSummary in main host - Remove license usage hosted service - Track used license features by minimum license level that supports them
- Loading branch information
1 parent
bb04af5
commit 87c30c6
Showing
22 changed files
with
247 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Duende Software. All rights reserved. | ||
// See LICENSE in the project root for license information. | ||
|
||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Duende.IdentityServer.Licensing.v2; | ||
|
||
/// <summary> | ||
/// Summarizes the usage of IdentityServer | ||
/// </summary> | ||
public interface ILicenseSummary | ||
{ | ||
/// <summary> | ||
/// Summarizes the usage of IdentityServer, including licensed features, clients, and issuers. | ||
/// </summary> | ||
public string Summary { get; } | ||
|
||
/// <summary> | ||
/// Gets the license edition. | ||
/// </summary> | ||
public string LicenseEdition { get; } | ||
|
||
/// <summary> | ||
/// Gets the licensed enterprise edition features that have been used. | ||
/// </summary> | ||
IEnumerable<string> EnterpriseFeaturesUsed { get; } | ||
|
||
/// <summary> | ||
/// Gets the licensed business edition features that have been used. | ||
/// </summary> | ||
IEnumerable<string> BusinessFeaturesUsed { get; } | ||
|
||
/// <summary> | ||
/// Gets other licensed features that have been used. | ||
/// </summary> | ||
IEnumerable<string> OtherFeaturesUsed { get; } | ||
|
||
/// <summary> | ||
/// Gets the client ids that have been used. | ||
/// </summary> | ||
IEnumerable<string> UsedClients { get; } | ||
|
||
/// <summary> | ||
/// Gets the issuers that have been used. | ||
/// </summary> | ||
IEnumerable<string> UsedIssuers { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Duende Software. All rights reserved. | ||
// See LICENSE in the project root for license information. | ||
|
||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Duende.IdentityServer.Licensing.v2; | ||
|
||
internal class LicenseSummary(ILicenseAccessor license, ILicenseUsageService usage) : ILicenseSummary | ||
{ | ||
public string Summary | ||
{ | ||
get | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.AppendLine("IdentityServer Usage Summary:"); | ||
sb.AppendLine($"\tLicense: {LicenseEdition}"); | ||
|
||
AppendSummary(sb, "Client Ids Used", usage.UsedClients); | ||
AppendSummary(sb, "Business Edition Features Used", usage.BusinessFeaturesUsed); | ||
AppendSummary(sb, "Enterprise Edition Features Used", usage.EnterpriseFeaturesUsed); | ||
AppendSummary(sb, "Other Features Used", usage.OtherFeaturesUsed); | ||
AppendSummary(sb, "Issuers Used", usage.UsedIssuers); | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
|
||
private void AppendSummary<T>(StringBuilder sb, string label, IReadOnlyCollection<T> items) | ||
{ | ||
if (items.Count == 1) | ||
{ | ||
sb.AppendLine($"\t{label}: {items.Single()}"); | ||
} | ||
else if (items.Count > 1) | ||
{ | ||
sb.AppendLine($"\t{label}s: {string.Join(", ", items)}"); | ||
} | ||
} | ||
|
||
public string LicenseEdition => license.Current.Edition?.ToString() ?? "None"; | ||
public IEnumerable<string> UsedClients => usage.UsedClients; | ||
public IEnumerable<string> UsedIssuers => usage.UsedIssuers; | ||
|
||
public IEnumerable<string> EnterpriseFeaturesUsed => usage.EnterpriseFeaturesUsed.Select(f => f.ToString()); | ||
public IEnumerable<string> BusinessFeaturesUsed => usage.BusinessFeaturesUsed.Select(f => f.ToString()); | ||
public IEnumerable<string> OtherFeaturesUsed => usage.OtherFeaturesUsed.Select(f => f.ToString()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.