Skip to content

Update the query used for authorizations pruning to exclude all authorizations that still have tokens attached#2251

Merged
kevinchalet merged 1 commit intoopeniddict:devfrom
kevinchalet:authorization_pruning
Feb 12, 2025
Merged

Update the query used for authorizations pruning to exclude all authorizations that still have tokens attached#2251
kevinchalet merged 1 commit intoopeniddict:devfrom
kevinchalet:authorization_pruning

Conversation

@kevinchalet
Copy link
Member

Currently, permanent authorizations that are not valid and still have tokens attached are not excluded by the query used in OpenIddict*AuthorizationStore.PruneAsync(): it's not a problem at all for MongoDB (which isn't relational), but for the EF Core-based store, it's now problematic since recent versions use batched deletes by default: if a token is still attached to an authorization, an exception is thrown when the DB detects an authorization still has children entities attached.

By changing the logic used in all the stores to always exclude authorizations (no matter the type) that still have tokens attached, this PR should greatly reduce that risk.

Related discussion: https://matrix.to/#/!DYBDMbtjENXaKIMiCN:gitter.im/$yOUcTNT72_AgmjK9vHKlg1kCpR776CsjDMLpWIIQYWA?via=gitter.im&via=matrix.org

@kevinchalet kevinchalet added this to the 6.1.0 milestone Feb 12, 2025
@kevinchalet kevinchalet self-assigned this Feb 12, 2025
@kevinchalet kevinchalet merged commit 6cb8af0 into openiddict:dev Feb 12, 2025
6 checks passed
@kevinchalet kevinchalet deleted the authorization_pruning branch February 12, 2025 21:05
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