[1.x] Refine URL signing policy#6
Merged
Merged
Conversation
f968d50 to
62474f5
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the URL signing subsystem toward a “fixed-policy verifier” approach: signed URLs now carry only a signature, while the verifier derives the signature input from its configured policy (UrlSigningConfig) instead of reading per-URL policy from a signature-input query parameter. This also extracts shared utilities for signature-input construction and base64url handling, and updates component derivation behavior and documentation accordingly.
Changes:
- Remove
signature-inputas an emitted URL query parameter; build signature input from verifier/signer configuration viaUrlSignatureInput. - Introduce
Base64UrlandQueryParamComponent, and adjust component derivation for@methodand@query-param. - Update unit tests, README PHP requirements, and bump PHPStan to v2.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Url/UrlVerifierTest.php | Updates verifier tests for config-driven signature input and adds invalid base64url coverage. |
| tests/Unit/Url/UrlSignerTest.php | Updates signer tests to assert only signature is appended and signature changes with configured components/expiration. |
| tests/Unit/ComponentDeriverTest.php | Updates expectations for @method casing and @query-param parsing/edge cases. |
| src/Url/UrlVerifier.php | Removes parsing of signature-input from URL; derives signature input from config and uses Base64Url::decode. |
| src/Url/UrlSigningConfig.php | Removes signatureInputParam option and updates factory accordingly. |
| src/Url/UrlSigner.php | Stops appending signature-input and delegates signature-input creation to UrlSignatureInput; uses Base64Url::encode. |
| src/Url/UrlSignatureInput.php | New helper to construct the structured-field InnerList signature input from config + algorithm. |
| src/Url/Base64Url.php | New base64url encode/decode helper with stricter decode validation. |
| src/Signer.php | Simplifies component identifier parsing for structured-field parameterized identifiers. |
| src/QueryParamComponent.php | New implementation of @query-param derivation using URLSearchParams, with stronger validation. |
| src/ComponentDeriver.php | Switches @query-param derivation to QueryParamComponent and preserves method case. |
| README.md | Updates stated PHP requirement and feature wording. |
| composer.json | Bumps PHPStan to ^2.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+57
to
60
| // Strip any existing signature param | ||
| $cleanUrl = Modifier::wrap($uriString) | ||
| ->removeQueryPairsByKey($this->config->signatureParam, $this->config->signatureInputParam) | ||
| ->removeQueryPairsByKey($this->config->signatureParam) | ||
| ->toString(); |
Comment on lines
+74
to
77
| // Strip signature param to get the clean URL | ||
| $cleanUrl = Modifier::wrap($uriString) | ||
| ->removeQueryPairsByKey($this->config->signatureParam, $this->config->signatureInputParam) | ||
| ->removeQueryPairsByKey($this->config->signatureParam) | ||
| ->toString(); |
Comment on lines
50
to
52
| $this->assertSame('1', $params['keep']); | ||
| $this->assertSame('keep', $params['signature-input']); | ||
| $this->assertNotSame('old', $params['signature']); |
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.
Description
Refines URL signing into a fixed-policy verifier model so signed URLs do not carry their own component policy, while keeping the Cloud transform migration path configurable through
UrlSigningConfig.