From 1b48d9691006c0dd450c1bab5b7f4a4f4db485ca Mon Sep 17 00:00:00 2001 From: Dennis Haney Date: Mon, 23 Oct 2023 19:33:45 +0700 Subject: [PATCH] Update the client authentication results to expose the access token expiration date --- .../OpenIddictClientModels.cs | 30 +++++++++++++++++++ .../OpenIddictClientService.cs | 6 ++++ 2 files changed, 36 insertions(+) diff --git a/src/OpenIddict.Client/OpenIddictClientModels.cs b/src/OpenIddict.Client/OpenIddictClientModels.cs index 24740a1d..617a0edb 100644 --- a/src/OpenIddict.Client/OpenIddictClientModels.cs +++ b/src/OpenIddict.Client/OpenIddictClientModels.cs @@ -66,6 +66,11 @@ public static class OpenIddictClientModels /// public required string? BackchannelAccessToken { get; init; } + /// + /// Gets or sets the expiration date of the backchannel access token, if available. + /// + public required DateTimeOffset? BackchannelAccessTokenExpirationDate { get; init; } + /// /// Gets or sets the backchannel identity token, if available. /// @@ -82,6 +87,11 @@ public static class OpenIddictClientModels /// public required string? FrontchannelAccessToken { get; init; } + /// + /// Gets or sets the expiration date of the frontchannel access token, if available. + /// + public required DateTimeOffset? FrontchannelAccessTokenExpirationDate { get; init; } + /// /// Gets or sets the frontchannel identity token, if available. /// @@ -253,6 +263,11 @@ public static class OpenIddictClientModels /// public required string AccessToken { get; init; } + /// + /// Gets or sets the expiration date of the access token, if available. + /// + public required DateTimeOffset? AccessTokenExpirationDate { get; init; } + /// /// Gets or sets the identity token, if available. /// @@ -394,6 +409,11 @@ public static class OpenIddictClientModels /// public required string AccessToken { get; init; } + /// + /// Gets or sets the expiration date of the access token, if available. + /// + public required DateTimeOffset? AccessTokenExpirationDate { get; init; } + /// /// Gets or sets the identity token, if available. /// @@ -605,6 +625,11 @@ public static class OpenIddictClientModels /// public required string AccessToken { get; init; } + /// + /// Gets or sets the expiration date of the access token, if available. + /// + public required DateTimeOffset? AccessTokenExpirationDate { get; init; } + /// /// Gets or sets the identity token, if available. /// @@ -714,6 +739,11 @@ public static class OpenIddictClientModels /// public required string AccessToken { get; init; } + /// + /// Gets or sets the expiration date of the access token, if available. + /// + public required DateTimeOffset? AccessTokenExpirationDate { get; init; } + /// /// Gets or sets the identity token, if available. /// diff --git a/src/OpenIddict.Client/OpenIddictClientService.cs b/src/OpenIddict.Client/OpenIddictClientService.cs index 6deb99ed..ffa117a5 100644 --- a/src/OpenIddict.Client/OpenIddictClientService.cs +++ b/src/OpenIddict.Client/OpenIddictClientService.cs @@ -343,9 +343,11 @@ public sealed class OpenIddictClientService AuthorizationCode = context.AuthorizationCode, AuthorizationResponse = context.Request is not null ? new(context.Request.GetParameters()) : new(), BackchannelAccessToken = context.BackchannelAccessToken, + BackchannelAccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate, BackchannelIdentityToken = context.BackchannelIdentityToken, BackchannelIdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal, FrontchannelAccessToken = context.FrontchannelAccessToken, + FrontchannelAccessTokenExpirationDate = context.FrontchannelAccessTokenExpirationDate, FrontchannelIdentityToken = context.FrontchannelIdentityToken, FrontchannelIdentityTokenPrincipal = context.FrontchannelIdentityTokenPrincipal, Principal = context.MergedPrincipal, @@ -590,6 +592,7 @@ public sealed class OpenIddictClientService return new() { AccessToken = context.BackchannelAccessToken!, + AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate, IdentityToken = context.BackchannelIdentityToken, IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal, Principal = context.MergedPrincipal, @@ -763,6 +766,7 @@ public sealed class OpenIddictClientService return new() { AccessToken = context.BackchannelAccessToken!, + AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate, IdentityToken = context.BackchannelIdentityToken, IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal, Principal = context.MergedPrincipal, @@ -1107,6 +1111,7 @@ public sealed class OpenIddictClientService return new() { AccessToken = context.BackchannelAccessToken!, + AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate, IdentityToken = context.BackchannelIdentityToken, IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal, Principal = context.MergedPrincipal, @@ -1268,6 +1273,7 @@ public sealed class OpenIddictClientService return new() { AccessToken = context.BackchannelAccessToken!, + AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate, IdentityToken = context.BackchannelIdentityToken, IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal, Principal = context.MergedPrincipal,