Skip to content

Commit

Permalink
Update the client authentication results to expose the access token e…
Browse files Browse the repository at this point in the history
…xpiration date
  • Loading branch information
davhdavh authored Oct 23, 2023
1 parent b9e5a33 commit 327cf8e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/OpenIddict.Client/OpenIddictClientModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public sealed record class InteractiveAuthenticationResult
/// </summary>
public required string? BackchannelAccessToken { get; init; }

/// <summary>
/// Gets or sets the expiration date of the backchannel access token, if available.
/// </summary>
public required DateTimeOffset? BackchannelAccessTokenExpirationDate { get; init; }

/// <summary>
/// Gets or sets the backchannel identity token, if available.
/// </summary>
Expand All @@ -82,6 +87,11 @@ public sealed record class InteractiveAuthenticationResult
/// </summary>
public required string? FrontchannelAccessToken { get; init; }

/// <summary>
/// Gets or sets the expiration date of the frontchannel access token, if available.
/// </summary>
public required DateTimeOffset? FrontchannelAccessTokenExpirationDate { get; init; }

/// <summary>
/// Gets or sets the frontchannel identity token, if available.
/// </summary>
Expand Down Expand Up @@ -253,6 +263,11 @@ public sealed record class ClientCredentialsAuthenticationResult
/// </summary>
public required string AccessToken { get; init; }

/// <summary>
/// Gets or sets the expiration date of the access token, if available.
/// </summary>
public required DateTimeOffset? AccessTokenExpirationDate { get; init; }

/// <summary>
/// Gets or sets the identity token, if available.
/// </summary>
Expand Down Expand Up @@ -394,6 +409,11 @@ public sealed record class DeviceAuthenticationResult
/// </summary>
public required string AccessToken { get; init; }

/// <summary>
/// Gets or sets the expiration date of the access token, if available.
/// </summary>
public required DateTimeOffset? AccessTokenExpirationDate { get; init; }

/// <summary>
/// Gets or sets the identity token, if available.
/// </summary>
Expand Down Expand Up @@ -605,6 +625,11 @@ public sealed record class PasswordAuthenticationResult
/// </summary>
public required string AccessToken { get; init; }

/// <summary>
/// Gets or sets the expiration date of the access token, if available.
/// </summary>
public required DateTimeOffset? AccessTokenExpirationDate { get; init; }

/// <summary>
/// Gets or sets the identity token, if available.
/// </summary>
Expand Down Expand Up @@ -714,6 +739,11 @@ public sealed record class RefreshTokenAuthenticationResult
/// </summary>
public required string AccessToken { get; init; }

/// <summary>
/// Gets or sets the expiration date of the access token, if available.
/// </summary>
public required DateTimeOffset? AccessTokenExpirationDate { get; init; }

/// <summary>
/// Gets or sets the identity token, if available.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/OpenIddict.Client/OpenIddictClientService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,11 @@ public async ValueTask<InteractiveAuthenticationResult> AuthenticateInteractivel
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,
Expand Down Expand Up @@ -448,6 +450,7 @@ public async ValueTask<ClientCredentialsAuthenticationResult> AuthenticateWithCl
return new()
{
AccessToken = context.BackchannelAccessToken!,
AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate,
IdentityToken = context.BackchannelIdentityToken,
IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal,
Principal = context.MergedPrincipal,
Expand Down Expand Up @@ -551,6 +554,7 @@ public async ValueTask<DeviceAuthenticationResult> AuthenticateWithDeviceAsync(D
return new()
{
AccessToken = context.BackchannelAccessToken!,
AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate,
IdentityToken = context.BackchannelIdentityToken,
IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal,
Principal = context.MergedPrincipal,
Expand Down Expand Up @@ -753,6 +757,7 @@ public async ValueTask<PasswordAuthenticationResult> AuthenticateWithPasswordAsy
return new()
{
AccessToken = context.BackchannelAccessToken!,
AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate,
IdentityToken = context.BackchannelIdentityToken,
IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal,
Principal = context.MergedPrincipal,
Expand Down Expand Up @@ -846,6 +851,7 @@ public async ValueTask<RefreshTokenAuthenticationResult> AuthenticateWithRefresh
return new()
{
AccessToken = context.BackchannelAccessToken!,
AccessTokenExpirationDate = context.BackchannelAccessTokenExpirationDate,
IdentityToken = context.BackchannelIdentityToken,
IdentityTokenPrincipal = context.BackchannelIdentityTokenPrincipal,
Principal = context.MergedPrincipal,
Expand Down

0 comments on commit 327cf8e

Please sign in to comment.