@@ -100,10 +100,7 @@ public function __invoke(callable $handler)
100
100
*/
101
101
private function onBefore (RequestInterface $ request ): RequestInterface
102
102
{
103
- $ oauthparams = self ::getOauthParams (
104
- $ this ->generateNonce ($ request ),
105
- $ this ->config
106
- );
103
+ $ oauthparams = self ::getOauthParams ($ this ->config );
107
104
108
105
$ oauthparams ['oauth_signature ' ] = $ this ->getSignature ($ request , $ oauthparams );
109
106
uksort ($ oauthparams , 'strcmp ' );
@@ -179,19 +176,6 @@ public function getSignature(RequestInterface $request, array $params): string
179
176
return base64_encode ($ signature );
180
177
}
181
178
182
- /**
183
- * Returns a Nonce Based on the unique id and URL.
184
- *
185
- * This will allow for multiple requests in parallel with the same exact
186
- * timestamp to use separate nonce's.
187
- *
188
- * @param RequestInterface $request Request to generate a nonce for
189
- */
190
- private static function generateNonce (RequestInterface $ request ): string
191
- {
192
- return sha1 (uniqid ('' , true ).$ request ->getUri ()->getHost ().$ request ->getUri ()->getPath ());
193
- }
194
-
195
179
/**
196
180
* Creates the Signature Base String.
197
181
*
@@ -296,14 +280,13 @@ private function buildAuthorizationHeader(array $params): array
296
280
/**
297
281
* Get the oauth parameters as named by the oauth spec
298
282
*
299
- * @param string $nonce Unique nonce
300
- * @param array $config Configuration options of the plugin.
283
+ * @param array $config Configuration options of the plugin.
301
284
*/
302
- private static function getOauthParams (string $ nonce , array $ config ): array
285
+ private static function getOauthParams (array $ config ): array
303
286
{
304
287
$ params = [
305
288
'oauth_consumer_key ' => $ config ['consumer_key ' ],
306
- 'oauth_nonce ' => $ nonce ,
289
+ 'oauth_nonce ' => bin2hex ( random_bytes ( 20 )) ,
307
290
'oauth_signature_method ' => $ config ['signature_method ' ],
308
291
'oauth_timestamp ' => time (),
309
292
];
0 commit comments