Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OpenIddictParameter to offer ImmutableArray<string> conversions instead of string[] and clone JsonNode objects to guarantee immutability #2271

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

kevinchalet
Copy link
Member

@kevinchalet kevinchalet commented Mar 16, 2025

This PR introduces the following changes:

  • It replaces all the OpenIddictMessage/OpenIddictParameter constructors and static operators using string?[]? objects by equivalents using ImmutableArray<string?> or ImmutableArray<string?>?.
  • The OpenIddictRequest.Audiences and OpenIddictRequest.Resources properties have been updated to use ImmutableArray<string?>? instead of string?[]?, which will fully users from trying to do unsupported things like context.Request.Audiences[2] = "overridden audience" (which may or may not currently work depending on the actual CLR type of the parameter value).
  • For similar reasons, JsonNode instances are now cloned by OpenIddictParameter's constructor and cloned by the JsonNode? conversion operator.
  • It removes the OpenIddictParameter.Value property and replaces it by a new OpenIddictParameter.GetRawValue() to discourage using this very-low-level API.
  • The GetDestinations()/SetDestinations() now use ImmutableDictionary<string, ImmutableArray<string>> instead of ImmutableDictionary<string, string[]> for consistency with the previous changes.
  • The OpenIddictParameter structure was updated to use recently-introduced APIs like JsonNode.DeepEquals(), JsonElement.DeepEquals() or JsonElement.GetPropertyCount().
  • New StringValues conversion operators have been added to the OpenIddictParameter primitive.
  • The OpenIddictRequest.Claims and OpenIddictRequest.Registration properties are now of type JsonObject instead of JsonElement, which should make these properties easier to use.

@kevinchalet
Copy link
Member Author

Note: since this PR introduces a bunch of breaking changes, it will need to be properly documented in the 6.x -> 7.x migration guide.

@kevinchalet kevinchalet force-pushed the parameter_primitive branch 2 times, most recently from 5638bf8 to c4351b4 Compare March 16, 2025 20:46
…s instead of string[] and clone JsonNode objects to guarantee immutability
@kevinchalet kevinchalet force-pushed the parameter_primitive branch from c4351b4 to df14981 Compare March 17, 2025 00:00
@kevinchalet kevinchalet merged commit 38e84b8 into openiddict:dev Mar 17, 2025
6 checks passed
@kevinchalet kevinchalet deleted the parameter_primitive branch March 17, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant