meemalabs /
laravel-media-recognition
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Meema\MediaRecognition\Http\Middleware; |
||
| 4 | |||
| 5 | use Aws\Sns\Message; |
||
| 6 | use Aws\Sns\MessageValidator; |
||
| 7 | use Closure; |
||
| 8 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
| 9 | |||
| 10 | class VerifySignature |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Handle an incoming request. |
||
| 14 | * |
||
| 15 | * @param \Illuminate\Http\Request $request |
||
| 16 | * @param \Closure $next |
||
| 17 | * @return mixed |
||
| 18 | */ |
||
| 19 | public function handle($request, Closure $next) |
||
| 20 | { |
||
| 21 | try { |
||
| 22 | // Create a message from the post data and validate its signature |
||
| 23 | $message = Message::fromRawPostData(); |
||
| 24 | // Validate the message |
||
| 25 | $validator = new MessageValidator(); |
||
| 26 | |||
| 27 | if ($validator->isValid($message)) { |
||
| 28 | return $next($request); |
||
| 29 | } |
||
| 30 | } catch (\Exception $e) { |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||
| 31 | } |
||
| 32 | |||
| 33 | // If you get this far it means the request is not found |
||
| 34 | throw new NotFoundHttpException(); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |