Repository navigation
Nested route validators, route-level consumes, encrypted idempotency storage - #3
Merged
Merged
Conversation
…tes use the child
RouteValidators returned the first route parameter implementing HasValidators.
On folders/{folder}/documents/{document} that is the folder, so a GET sent
the folder's ETag and a PATCH checked If-Match against the folder, letting
a stale write to the document through. A URI names parents first, so the
last bound validator is the resource the request is about.
With consumes:application/json on an API group, a PATCH route that took application/merge-patch+json had to lift the group's declaration with withoutMiddleware() first, or the group answered 415 before the route's own middleware ran. Only the last declaration a route lists now applies: group, then route, then controller.
…pply A replay must return the original response, and some responses carry a secret shown once, such as a new API key. They sat in the cache as plain arrays for the whole TTL. Each is now encrypted with AES-256-GCM under a key derived by HKDF from the application key and the client's Idempotency-Key, and stored under a hash of that key, so neither the cache nor the cache plus APP_KEY can read it. Previous application keys still decrypt, and unencrypted entries from earlier versions are read until they expire.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three changes found while building an example application on Kit. Two change behaviour, so this is a minor release: v0.4.0.
Nested routes take validators from the child
RouteValidatorsreturned the first route parameter implementingHasValidators. Onfolders/{folder}/documents/{document}that is the folder, so a GET sent the folder's ETag and a PATCH checkedIf-Matchagainst the folder: a stale write to the document went through. A URI names parents first, so it now returns the last bound validator. Tests cover the GET, a matchingIf-Match, and one that only matches the parent.A route's
consumes:overrides its group'sWith
consumes:application/jsonon an API group, a merge patch route had to lift the group's declaration withwithoutMiddleware()first, or the group answered 415 before the route's own middleware ran. Only the last declaration a route lists now applies: group, then route, then controller. A declaration removed withwithoutMiddleware()does not count.Stored idempotent responses are encrypted
A replay must return the original response, and some carry a secret shown once, such as a new API key. They sat in the cache as plain arrays for the whole TTL. Each is now encrypted with AES-256-GCM under a key derived by HKDF from the application key and the client's
Idempotency-Key, and stored under a hash of that key. Neither the cache nor the cache plusAPP_KEYcan read an entry without the key that wrote it.APP_PREVIOUS_KEYSstill decrypt, so rotatingAPP_KEYkeeps replays working until the TTL passes.IdempotencyStore's methods now take the scope and theIdempotencyKeyinstead of a precomputed storage key, and its constructor takes the application's keys. It is an internal class, but anyone constructing it directly needs to update.Suite, PHPStan and Pint pass locally.