Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve license logging at startup #83

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Changes from 1 commit
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
27 changes: 14 additions & 13 deletions src/IdentityServer/Validation/Default/LicenseValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ public static void ValidateLicense()
if (_license == null)
{
var message = "You do not have a valid license key for Duende IdentityServer. " +
"This is allowed for development and testing scenarios. " +
"If you are running in production you are required to have a licensed version. Please start a conversation with us: https://duendesoftware.com/contact";
"This is allowed for development and testing scenarios. " +
"If you are running in production you are required to have a licensed version. Please start a conversation with us: https://duendesoftware.com/contact";

_logger.LogWarning(message);
return;
}
else
{
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug("The validated licence key details: {@license}", _license);
}

if (_license.Expiration.HasValue)
{
var diff = DateTime.UtcNow.Date.Subtract(_license.Expiration.Value.Date).TotalDays;
Expand Down Expand Up @@ -94,16 +99,11 @@ public static void ValidateLicense()
{
if (_license.Expiration.HasValue)
{
_logger.LogInformation("You have a valid license key for Duende IdentityServer for use at {licenseCompany}. The license expires on {licenseExpiration}.", _license.CompanyName, _license.Expiration.Value.ToLongDateString());
_logger.LogInformation("You have a valid license key for Duende IdentityServer {edition} edition for use at {licenseCompany}. The license expires on {licenseExpiration}.", _license.Edition, _license.CompanyName, _license.Expiration.Value.ToLongDateString());
}
else
{
_logger.LogInformation("You have a valid license key for Duende IdentityServer for use at {licenseCompany}.", _license.CompanyName);
}

if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug("The validated licence details: {@license}", _license);
_logger.LogInformation("You have a valid license key for Duende IdentityServer {edition} edition for use at {licenseCompany}.", _license.Edition, _license.CompanyName);
}
}
}
Expand Down Expand Up @@ -288,10 +288,11 @@ public License(ClaimsPrincipal claims)
public DateTime? Expiration { get; set; }

public LienceEdition Edition { get; set; }
public bool IsEnterprise => Edition == LienceEdition.Enterprise;
public bool IsBusiness => Edition == LienceEdition.Business;
public bool IsStarter => Edition == LienceEdition.Starter;
public bool IsCommunity => Edition == LienceEdition.Community;

internal bool IsEnterprise => Edition == LienceEdition.Enterprise;
internal bool IsBusiness => Edition == LienceEdition.Business;
internal bool IsStarter => Edition == LienceEdition.Starter;
internal bool IsCommunity => Edition == LienceEdition.Community;
brockallen marked this conversation as resolved.
Show resolved Hide resolved

public int? ClientLimit { get; set; }
public int? IssuerLimit { get; set; }
Expand Down