apache / directory-scimple

Apache Directory - SCIMple
https://directory.apache.org/scimple/
Apache License 2.0
66 stars 38 forks source link

eTag support with If-Match #534

Open symphony-enrico opened 6 months ago

symphony-enrico commented 6 months ago

Hello, I see that If-None-Match is supported well (if etag matches, an exception is throw), but If-Match, very useful for consistency of PUT operation, looks like not working and it is not clear to me if it is a not supported yet feature or a real bug.

I wondering if the version read from If-Match header should be passed to Repository#update (to delegate the implementation to check this) : now there is a version field, but it seems initialized with 'ETag' header, not with If-Match.

Thanks!

bdemers commented 6 months ago

Thanks for the report @symphony-enrico!

ETag support for updates was pushed down to the repository level (the ETag header maps to the version) in the Repository.update(...) method.

The intent was to allow Repository implementations to make more performant checks to see if the etag/version matches. Before #411, this was not the case. Which forced a (potentially expensive) call to repository.get(id) that was then used to calculate the version/etag. Now implementations optimize this how they see fit, e.g. add an index row to a database containing a version field.

As you mentioned, the current implementation may not be accurate (doesn't match for If-Match headers). If you have suggestions on how to improve this please let us know! (Either in this issue, or a PR!)

symphony-enrico commented 6 months ago

Hello @bdemers IMHO there is a really simple modification to do:

https://github.com/apache/directory-scimple/pull/541