Skip to content

Commit

Permalink
Update the client service to attach the additional parameters to the …
Browse files Browse the repository at this point in the history
…correct request instances
  • Loading branch information
kevinchalet committed Dec 2, 2023
1 parent d069c0d commit f541dcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/OpenIddict.Client/OpenIddictClientModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed record class InteractiveAuthenticationRequest
/// <summary>
/// Gets or sets the parameters that will be added to the token request.
/// </summary>
[Obsolete("This property is no longer supported and will be removed in a future version.")]
public Dictionary<string, OpenIddictParameter>? AdditionalTokenRequestParameters { get; init; }

/// <summary>
Expand All @@ -43,6 +44,7 @@ public sealed record class InteractiveAuthenticationRequest
/// <summary>
/// Gets the scopes that will be sent to the authorization server.
/// </summary>
[Obsolete("This property is no longer supported and will be removed in a future version.")]
public List<string>? Scopes { get; init; }
}

Expand Down
16 changes: 12 additions & 4 deletions src/OpenIddict.Client/OpenIddictClientService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ public async ValueTask<InteractiveAuthenticationResult> AuthenticateInteractivel
Nonce = request.Nonce
};

if (request.Properties is { Count: > 0 })
{
foreach (var property in request.Properties)
{
context.Properties[property.Key] = property.Value;
}
}

await dispatcher.DispatchAsync(context);

if (context.IsRejected)
Expand Down Expand Up @@ -733,7 +741,7 @@ public async ValueTask<DeviceAuthenticationResult> AuthenticateWithDeviceAsync(D
Issuer = request.Issuer,
ProviderName = request.ProviderName,
RegistrationId = request.RegistrationId,
Request = request.AdditionalTokenRequestParameters
TokenRequest = request.AdditionalTokenRequestParameters
is Dictionary<string, OpenIddictParameter> parameters ? new(parameters) : new(),
};

Expand Down Expand Up @@ -912,13 +920,13 @@ public async ValueTask<DeviceChallengeResult> ChallengeUsingDeviceAsync(DeviceCh
var context = new ProcessChallengeContext(transaction)
{
CancellationToken = request.CancellationToken,
DeviceAuthorizationRequest = request.AdditionalDeviceAuthorizationRequestParameters
is Dictionary<string, OpenIddictParameter> parameters ? new(parameters) : new(),
GrantType = GrantTypes.DeviceCode,
Issuer = request.Issuer,
Principal = new ClaimsPrincipal(new ClaimsIdentity()),
ProviderName = request.ProviderName,
RegistrationId = request.RegistrationId,
Request = request.AdditionalDeviceAuthorizationRequestParameters
is Dictionary<string, OpenIddictParameter> parameters ? new(parameters) : new(),
RegistrationId = request.RegistrationId
};

if (request.Scopes is { Count: > 0 })
Expand Down

0 comments on commit f541dcd

Please sign in to comment.