/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($this->alexaRequest->isAlexaRequest()) { return $this->sendRequestThroughRouter($request); } return $next($request); }
public function __construct(AlexaRequest $alexaRequest, DeviceProvider $deviceProvider, array $alexaConfig) { $this->alexaRequest = $alexaRequest; $this->deviceProvider = $deviceProvider; $this->setupSession(); $this->alexaConfig = $alexaConfig; $this->isAlexaRequest = $this->alexaRequest->isAlexaRequest(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed * * @throws InvalidSignatureChainException * @throws \Exception */ public function handle($request, Closure $next) { if (!$this->alexaRequest->isAlexaRequest()) { return $next($request); } $this->verifyApplicationId(); $this->checkTimestampTolerance(); $certificateResult = $this->verifyCertificate($request); if ($certificateResult === 1) { return $next($request); } elseif ($certificateResult = 0) { throw new InvalidSignatureChainException("The request did not validate against the certificate chain."); } else { throw new \Exception("Something went wrong when validating the request and certificate."); } }