-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] [OvhCloud] “Invalid signature” for message with slashes #39871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Notifier] [OvhCloud] “Invalid signature” for message with slashes #39871
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
@OneT0uch Are you working on a fix? |
Then I think we are going to close as the core team is not able to fix provider issues. The only to get a fix is by users of the providers. You can also ping the various contributors (especially the one who submitted the provider in the first place) if they can help. |
I will have a detailed look 👍 |
@OskarStark Can't we just remove the unescaped slashes flag? Do you know why we need it? |
I think not, based on their official PHP client they use it too: It would be maybe you can open an issue in their repo how they handle your case or if they have a recommendation 🤔 Can you ping me on the symfony slack ? |
Can you please try to apply the following diff in this PR and see if the tests pass? diff --git a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php
index 4d737019c3..a6f41bc6b3 100644
--- a/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php
+++ b/src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php
@@ -76,7 +76,13 @@ final class OvhCloudTransport extends AbstractTransport
$headers['X-Ovh-Application'] = $this->applicationKey;
$headers['X-Ovh-Timestamp'] = $now;
- $toSign = $this->applicationSecret.'+'.$this->consumerKey.'+POST+'.$endpoint.'+'.json_encode($content, \JSON_UNESCAPED_SLASHES).'+'.$now;
+ if (false !== strpos($message->getSubject(), '/')) {
+ $body = json_encode($content);
+ } else {
+ $body = json_encode($content, \JSON_UNESCAPED_SLASHES);
+ }
+
+ $toSign = $this->applicationSecret.'+'.$this->consumerKey.'+POST+'.$endpoint.'+'.$body.'+'.$now;
$headers['X-Ovh-Consumer'] = $this->consumerKey;
$headers['X-Ovh-Signature'] = '$1$'.sha1($toSign); |
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
Your solution is working but i think it will be better to follow official sdk : // Add Content type
$headers['Content-Type'] = 'application/json';
// Store json encode content
$body = json_encode($content, \JSON_UNESCAPED_SLASHES);
$toSign = $this->applicationSecret.'+'.$this->consumerKey.'+POST+'.$endpoint.'+'.$body.'+'.$now;
$response = $this->client->request('POST', $endpoint, [
'headers' => $headers,
'body' => $body, // Use it here
]); |
That makes sense, can you please change the code accordingly? |
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php
Outdated
Show resolved
Hide resolved
Thanks for fixing this bug @OneT0uch. |
Test to show issue of invalid signature when message contains slash.