title: How to configure Channel Authorization for Broadcasting in Laravel 5.3 using Pusher Driver?
body: <ul>
  <li>Laravel Version: 5.3.*</li>
  <li>PHP Version: 5.6.17</li>
  <li>Database Driver &amp; Version:
  mysql</li>
  </ul>
  
  <h3>Description:</h3>
  
  <p>According to Laravel 5.3 documentation when broadcasting events on private or presence channels, in the boot method of the <code>BroadcastServiceProvider</code> one must provide a callback that resolves if an user has authorization to listen to that channel to the Broadcast facade method <code>channel</code>. This method should return a boolean. In the the <code>BroadcastServiceProvider</code> method <code>boot</code> we should also include <code>Broadcast::routes()</code> that will define the auth route that the client will call to check for permission on the channel. This routes method can receive an array of attributes to apply to the route. Now it's where it gets weird. When the client call this route no matter what callback I passed to the <code>Broadcast::channel</code> method it will give me a 403 forbidden unless (and now comes the weirdest part) I provide an array to the <code>Broadcast::routes</code> with a key named <code>prefix</code> and a value of whatever. If the key is not prefix it will go back to 403 forbidden. </p>
  
  <blockquote>
    <p>HttpException in PusherBroadcaster.php line 42:</p>
  </blockquote>
  
  <p>My setup follows. I'm for sure doing something wrong but after a lot of ours trying to understand I can't figure it out. Can someone give an hint?</p>
  
  <h3>Steps To Reproduce:</h3>
  
  <p>I have created a simple event:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Events;
  
  use App\Models\Presentation;
  use Illuminate\Broadcasting\Channel;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Broadcasting\PrivateChannel;
  use Illuminate\Broadcasting\PresenceChannel;
  use Illuminate\Broadcasting\InteractsWithSockets;
  use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  
  class PresentationCreated implements ShouldBroadcast
  {
      use InteractsWithSockets, SerializesModels;
  
      public $presentation;
  
      /**
       * Create a new event instance.
       *
       * @return void
       */
      public function __construct(Presentation $presentation)
      {
          $this-&gt;presentation = $presentation;
      }
  
      /**
       * Get the channels the event should broadcast on.
       *
       * @return Channel|array
       */
      public function broadcastOn()
      {
          return new PrivateChannel('presentation');
      }
  }
  </code></pre>
  
  <p>that i trigger by calling <code>event(new PresentationCreated($presentation));</code></p>
  
  <p>I have installed <code>"pusher/pusher-php-server": "^2.5.0"</code> and created an account in pusher. 
  I put my pusher credentials in <code>.env</code>:</p>
  
  <pre><code>BROADCAST_DRIVER=pusher
  PUSHER_APP_ID=*****
  PUSHER_APP_KEY=*****************
  PUSHER_APP_SECRET=****************
  PUSHER_APP_CLUSTER=**
  </code></pre>
  
  <p>in my <code>config\broadcast.php</code> I have:</p>
  
  <pre><code>'pusher' =&gt; [
          'driver' =&gt; 'pusher',
          'key' =&gt; env('PUSHER_APP_KEY'),
          'secret' =&gt; env('PUSHER_APP_SECRET'),
          'app_id' =&gt; env('PUSHER_APP_ID'),
          'options' =&gt; [
            'cluster' =&gt; 'eu',
            'encrypted' =&gt; true,
          ],
      ],
  </code></pre>
  
  <p>My client side:</p>
  
  <pre><code>this.Echo = new Echo({
              broadcaster: 'pusher',
              key: typeof handover.pak !== 'undefined' ? handover.pak : '',
              cluster: 'eu'
          });
  
          this.Echo.private(`presentation`)
          .listen('PresentationCreated', (e) =&gt; {
              console.log(e, 'raposa')
          });
  </code></pre>
  
  <p>And finally the BroadcastServiceProvider:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Providers;
  
  use Illuminate\Support\ServiceProvider;
  use Illuminate\Support\Facades\Broadcast;
  
  class BroadcastServiceProvider extends ServiceProvider
  {
      /**
       * Bootstrap any application services.
       *
       * @return void
       */
      public function boot()
      {
          Broadcast::routes();
  
          //The commented line would make the authorization pass even if I return false bellow
          //Broadcast::routes(['prefix' =&gt; 'I do not know what I am doing']);
  
          /*
           * Authenticate the user's personal channel...
           */
          Broadcast::channel('presentation', function ($user) {
              return false;
          });
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to @yazfield answer I was able to understand what was going on. The http error was due to the <code>$request-&gt;user()</code> being null. That was because I was not passing the additional middlewares that my route namespace was using. By doing <code>Broadcast::routes(['middleware' =&gt; ['web', 'clumsy', 'admin-extra']]);</code> I was able to solve the problem.</p>
  
  <p><a href="https://github.com/laravel/framework/issues/16151" rel="nofollow noreferrer">This</a> Laravel issue also helped me getting the grasp of the thing.</p>