/**
  * Validates the signature if useSecureURLs in enabled
  */
 protected function validateSignature()
 {
     foreach ($this->request->all() as $parameter => $value) {
         if (empty($value) === true) {
             $this->request->query->remove($parameter);
         }
     }
     if ($this->glideConfig['useSecureURLs']) {
         SignatureFactory::create($this->app['config']->get('app.key'))->validateRequest($this->request);
     }
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('spatie/laravel-glide');
     $glideConfig = $this->app['config']->get('laravel-glide::config');
     $this->app['router']->get($glideConfig['baseURL'] . '/{all}', function () use($glideConfig) {
         $request = $this->app['request'];
         SignatureFactory::create($this->app['config']->get('app.key'))->validateRequest($request);
         // Set image source
         $source = new Filesystem(new Local($glideConfig['source']['path']));
         // Set image cache
         $cache = new Filesystem(new Local($glideConfig['cache']['path']));
         $this->writeIgnoreFile($glideConfig['cache']['path']);
         $api = GlideApiFactory::create();
         // Setup Glide server
         $server = new Server($source, $cache, $api);
         $server->setBaseUrl($glideConfig['baseURL']);
         echo $server->outputImage($request);
     })->where('all', '.*');
 }
Example #3
0
 /**
  * @return \League\Glide\Http\Signature
  * @throws InvalidConfigException
  */
 public function getHttpSignature()
 {
     if ($this->httpSignature === null) {
         if ($this->signKey === null) {
             throw new InvalidConfigException();
         }
         $this->httpSignature = SignatureFactory::create($this->signKey);
     }
     return $this->httpSignature;
 }