Skip to content

Commit 8fab76f

Browse files
Pr comments.
1 parent 893bc6c commit 8fab76f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

api/Infrastructure/Authentication/KeycloakTokenService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public async Task<string> GetServiceAccountTokenAsync(KeycloakClientOptions opti
6464
var token = await RequestServiceAccountTokenAsync(options, cancellationToken);
6565
var cacheDuration = GetCacheDuration(token.ExpiresAt, options.RefreshSkewSeconds);
6666

67-
if (cacheDuration.Seconds <= options.RefreshSkewSeconds)
67+
if (cacheDuration.TotalSeconds > options.RefreshSkewSeconds)
6868
{
6969
_cache.Set(cacheKey, token, cacheDuration);
7070
}
7171
else
7272
{
73-
_logger.LogWarning("Unable to set valid cache duration, below skew thereshold.");
73+
_logger.LogWarning("Unable to set valid cache duration, below skew threshold.");
7474
}
7575

7676

@@ -110,8 +110,8 @@ private async Task<ServiceAccountToken> RequestServiceAccountTokenAsync(
110110
if (response.IsError || string.IsNullOrWhiteSpace(response.AccessToken))
111111
{
112112
_logger.LogError(
113-
"Failed to retrieve Keycloak service account token. Error: {Error}.",
114-
response.Error ?? "unknown");
113+
"Failed to retrieve Keycloak service account token. Error: {Error}. Description: {ErrorDescription}",
114+
response.Error ?? "unknown", response.ErrorDescription);
115115
throw new InvalidOperationException("Unable to retrieve service account token from Keycloak.");
116116
}
117117

api/Infrastructure/Options/KeycloakClientOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public sealed class KeycloakClientOptions
2828
/// <summary>
2929
/// Service account secret used to retrieve tokens. Value is expected from environment variables.
3030
/// </summary>
31+
[Required]
3132
public string ServiceAccountSecret { get; set; } = default!;
3233

3334
/// <summary>

cso-client/CsoClient.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ public async Task<bool> SendOrderAsync(OrderActionDto order, CancellationToken c
5959
: await response.Content.ReadAsStringAsync(cancellationToken);
6060

6161
_logger.LogWarning(
62-
"CSO order submit failed with status {StatusCode} {ReasonPhrase}. Response: {ResponseBody}",
62+
"CSO order submit failed with status {StatusCode} {ReasonPhrase}.",
6363
(int)response.StatusCode,
64-
response.ReasonPhrase,
65-
body);
64+
response.ReasonPhrase);
6665
}
6766

6867
return response.IsSuccessStatusCode;

0 commit comments

Comments
 (0)