Skip to content

Commit 5bfce63

Browse files
committed
Rename TimeSpan properties
1 parent 52506f2 commit 5bfce63

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

examples/Umbraco.AuthorizedServices.TestSite/appsettings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@
492492
"RequestTokenPath": "/access_token",
493493
"TokenGrantType": "ig_exchange_token",
494494
"RequestRefreshTokenPath": "/refresh_access_token",
495-
"RefreshTokenGrantType": "ig_refresh_token"
495+
"RefreshTokenGrantType": "ig_refresh_token",
496+
"ExchangeTokenWhenExpiresWithin": "25.00:00:00"
496497
},
497-
"AccessTokenExpirationInterval": "00.00:00:40",
498-
"ExchangeTokenExpirationInterval": "25.00:00:00"
498+
"RefreshAccessTokenWhenExpiresWithin": "00.00:00:40"
499499
}
500500
}
501501
}

src/Umbraco.AuthorizedServices/Configuration/AuthorizedServiceSettings.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public class ExchangeTokenProvision
9797
public string RequestRefreshTokenPath { get; set; } = string.Empty;
9898

9999
public string RefreshTokenGrantType { get; set; } = string.Empty;
100+
101+
/// <summary>
102+
/// Gets or sets the time interval for expiration of exchange tokens.
103+
/// </summary>
104+
public TimeSpan ExchangeTokenWhenExpiresWithin { get; set; } = TimeSpan.FromDays(30);
100105
}
101106

102107
/// <summary>
@@ -256,12 +261,7 @@ public class ServiceDetail : ServiceSummary
256261
/// <summary>
257262
/// Gets or sets the time interval for expiration of access tokens.
258263
/// </summary>
259-
public TimeSpan AccessTokenExpirationInterval { get; set; } = TimeSpan.FromSeconds(30);
260-
261-
/// <summary>
262-
/// Gets or sets the time interval for expiration of exchange tokens.
263-
/// </summary>
264-
public TimeSpan ExchangeTokenExpirationInterval { get; set; } = TimeSpan.FromDays(30);
264+
public TimeSpan RefreshAccessTokenWhenExpiresWithin { get; set; } = TimeSpan.FromSeconds(30);
265265

266266
internal string GetTokenHost() => string.IsNullOrWhiteSpace(TokenHost)
267267
? IdentityHost

src/Umbraco.AuthorizedServices/Services/Implement/AuthorizedServiceCaller.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public async Task<string> SendRequestRawAsync<TRequest>(string serviceAlias, str
145145
private async Task<Token> EnsureAccessToken(string serviceAlias, Token token)
146146
{
147147
ServiceDetail serviceDetail = GetServiceDetail(serviceAlias);
148-
if (token.WillBeExpiredAfter(serviceDetail.AccessTokenExpirationInterval))
148+
if (token.WillBeExpiredAfter(serviceDetail.RefreshAccessTokenWhenExpiresWithin))
149149
{
150150
if (string.IsNullOrEmpty(token.RefreshToken))
151151
{
@@ -186,7 +186,8 @@ private async Task<Token> EnsureAccessToken(string serviceAlias, Token token)
186186
private async Task<Token> EnsureExchangeAccessToken(string serviceAlias, Token token)
187187
{
188188
ServiceDetail serviceDetail = GetServiceDetail(serviceAlias);
189-
if (token.WillBeExpiredAfter(serviceDetail.ExchangeTokenExpirationInterval))
189+
if (serviceDetail.ExchangeTokenProvision is not null
190+
&& token.WillBeExpiredAfter(serviceDetail.ExchangeTokenProvision.ExchangeTokenWhenExpiresWithin))
190191
{
191192
return await RefreshExchangeAccessToken(serviceAlias, token.AccessToken)
192193
?? throw new AuthorizedServiceException($"Cannot request service '{serviceAlias}' as the access token will expire and it's not been possible to exchange it for a new access token.");

src/Umbraco.AuthorizedServices/appsettings-schema.Umbraco.AuthorizedServices.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,9 @@
148148
"type": "string",
149149
"description": "Gets or sets the path to a GET request used as a sample for verifying the service in the backoffice."
150150
},
151-
"AccessTokenExpirationInterval": {
151+
"RefreshAccessTokenWhenExpiresWithin": {
152152
"type": "string",
153153
"description": "Gets or sets the time interval for expiration of access tokens."
154-
},
155-
"ExchangeTokenExpirationInterval": {
156-
"type": "string",
157-
"description": "Gets or sets the time interval for expiration of exchange tokens."
158154
}
159155
}
160156
},
@@ -195,6 +191,10 @@
195191
"RefreshTokenGrantType": {
196192
"type": "string",
197193
"description": "Gets or set the grant type used for refreshing the access token."
194+
},
195+
"ExchangeTokenWhenExpiresWithin": {
196+
"type": "string",
197+
"description": "Gets or sets the time interval for expiration of exchange tokens."
198198
}
199199
}
200200
}

0 commit comments

Comments
 (0)