mirror of
https://github.com/DuendeSoftware/products
synced 2026-05-24 09:28:24 +00:00
Merge pull request #1951 from DuendeSoftware/beh/sourcegenerators-for-v2license-logs
This commit is contained in:
commit
bcb46fa645
4 changed files with 34 additions and 3 deletions
|
|
@ -90,7 +90,7 @@ internal class LicenseAccessor(IdentityServerOptions options, ILogger<LicenseAcc
|
|||
var validateResult = handler.ValidateTokenAsync(licenseKey, parms).Result;
|
||||
if (!validateResult.IsValid)
|
||||
{
|
||||
logger.LogCritical(validateResult.Exception, "Error validating the Duende software license key");
|
||||
logger.ErrorValidatingLicenseKey(validateResult.Exception);
|
||||
}
|
||||
|
||||
return validateResult.ClaimsIdentity?.Claims.ToArray() ?? [];
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ internal class LicenseExpirationChecker(
|
|||
if (!_expiredLicenseWarned && !license.Current.Redistribution && IsExpired)
|
||||
{
|
||||
_expiredLicenseWarned = true;
|
||||
_logger.LogError("The IdentityServer license is expired. In a future version of IdentityServer, license expiration will be enforced after a grace period.");
|
||||
_logger.LicenseHasExpired();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
29
identity-server/src/IdentityServer/Licensing/V2/Log.cs
Normal file
29
identity-server/src/IdentityServer/Licensing/V2/Log.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Duende Software. All rights reserved.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Duende.IdentityServer.Licensing.V2;
|
||||
|
||||
internal static class LicenseLogParameters
|
||||
{
|
||||
public const string Threshold = "Threshold";
|
||||
}
|
||||
|
||||
internal static partial class Log
|
||||
{
|
||||
[LoggerMessage(
|
||||
LogLevel.Critical,
|
||||
message: "Error validating the Duende software license key")]
|
||||
public static partial void ErrorValidatingLicenseKey(this ILogger logger, Exception ex);
|
||||
|
||||
[LoggerMessage(
|
||||
LogLevel.Error,
|
||||
message: "The IdentityServer license is expired. In a future version of IdentityServer, license expiration will be enforced after a grace period.")]
|
||||
public static partial void LicenseHasExpired(this ILogger logger);
|
||||
|
||||
[LoggerMessage(LogLevel.Error,
|
||||
Message =
|
||||
$"You are using IdentityServer in trial mode and have exceeded the trial threshold of {{{LicenseLogParameters.Threshold}}} requests handled by IdentityServer. In a future version, you will need to restart the server or configure a license key to continue testing. For more information, please see https://docs.duendesoftware.com/trial-mode.")]
|
||||
public static partial void TrialModeRequestCountExceeded(this ILogger logger, ulong threshold);
|
||||
}
|
||||
|
|
@ -28,12 +28,14 @@ internal class ProtocolRequestCounter(
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var total = Interlocked.Increment(ref _requestCount);
|
||||
if (total <= Threshold || _warned)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogError($"You are using IdentityServer in trial mode and have exceeded the trial threshold of {Threshold} requests handled by IdentityServer. In a future version, you will need to restart the server or configure a license key to continue testing. For more information, please see https://docs.duendesoftware.com/trial-mode.");
|
||||
|
||||
_logger.TrialModeRequestCountExceeded(Threshold);
|
||||
_warned = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue