-
-
Notifications
You must be signed in to change notification settings - Fork 574
Description
Confirm you've already contributed to this project or that you sponsor it
- I confirm I'm a sponsor or a contributor
Version
6.1.1
Describe the bug
When using Pomelo with EF Core and OpenIddict, the following query fails to return the expected results when PostLogoutRedirectUris is stored as a JSON array (e.g. ["mytitlehere:\logout"]):
SELECT `o`.`Id`, `o`.`ApplicationType`, `o`.`ClientId`, `o`.`ClientSecret`, ...
FROM `OpenIddictApplications` AS `o`
WHERE `o`.`PostLogoutRedirectUris` LIKE @_uri_0_containsT
This is likely because Pomelo (MySQL provider) doesn’t automatically translate EF Core LINQ queries to use JSON_CONTAINS or equivalent for JSON columns.
Additionally, I originally had the column type for "PostLogoutRedirectUris" set to LONGTEXT, but the query doesn't include wildcards on the front or back (it looks the same as the above query).
In either case, as a result, OpenIddict fails to match the logout URL and throws an error during sign-out.
Likely location in code (but I'm not certain):
OpenIddictEntityFrameworkCoreApplicationStore.cs
Suggested Fix:
Add provider-specific handling (e.g., using EF.Functions.JsonContains() or raw SQL) to ensure proper querying of JSON arrays in MySQL via Pomelo. Or give me the ability to override the query so I can write it correctly for my infrastructure.
To reproduce
Not sure I need to provide a whole repo, but here are the dependencies:
- MySQL 8
- Dotnet 8
- OpenIdDict.AspNetCore 6.1.1
- OpenIddict.EntityFrameworkCore 6.1.1
- Pomelo.EntityFrameworkCore.MySql 8.0.3
Here is my table definition:
CREATE TABLE `OpenIddictApplications` (
`Id` VARCHAR(450) NOT NULL,
`ClientId` VARCHAR(100) NOT NULL,
`ClientSecret` LONGTEXT NULL,
`ConcurrencyToken` VARCHAR(50) NULL,
`ConsentType` VARCHAR(50) NULL,
`DisplayName` VARCHAR(100) NULL,
`DisplayNames` LONGTEXT NULL,
`Permissions` LONGTEXT NULL,
`PostLogoutRedirectUris` LONGTEXT NULL,
`Properties` LONGTEXT NULL,
`RedirectUris` LONGTEXT NULL,
`Requirements` LONGTEXT NULL,
`Type` VARCHAR(50) NOT NULL,
`ApplicationType` VARCHAR(50) NULL,
`JsonWebKeySet` LONGTEXT NULL,
`Settings` LONGTEXT NULL,
`ClientType` VARCHAR(50) NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `IX_OpenIddictApplications_ClientId` (`ClientId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I've also tried "PostLogoutRedirecUris" as a JSON column type.
Exceptions (if any)
The exception I get is that the PostLogoutURL cannot be found and therefore it errors and doesn't allow the logout.