Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pusher private-encrypted #263 #264

Merged
merged 3 commits into from Apr 3, 2020
Merged

Conversation

it-can
Copy link
Contributor

@it-can it-can commented Apr 2, 2020

Ok added support for private-encrypted channels (#263) (only for Pusher). Hope this is correct.. I don't use Ts a lot...

@driesvints
Copy link
Member

Seems to be good.

@taylorotwell note that this is to support laravel/framework#31559

@taylorotwell
Copy link
Member

taylorotwell commented Apr 2, 2020

@it-can did you actually build this and test it in a local application using npm link?

@it-can
Copy link
Contributor Author

it-can commented Apr 2, 2020

@taylorotwell yes I just tested this. works perfectly.

In Laravel set in the config/broadcasting.php file, a base64 encoded masterkey.

'pusher' => [
            'driver'  => 'pusher',
            'key'     => env('PUSHER_APP_KEY'),
            'secret'  => env('PUSHER_APP_SECRET'),
            'app_id'  => env('PUSHER_APP_ID'),
            'options' => [
                        'useTLS'       => true,
                        'cluster'      => 'eu',
                        'encryption_master_key_base64' => 'mysecretbase64encodedkey',
            ],
        ],

Broadcast to a EncryptedPrivateChannel channel.

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\EncryptedPrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class CalenderRefresh implements ShouldBroadcast
{
    use InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new EncryptedPrivateChannel('calendar');
    }
}

Subscribe with Echo to a privateEncrypted channel

Echo.privateEncrypted('calendar').listen('CalenderRefresh', function () {
            reloadCalendar();
        });

This works for me

@taylorotwell
Copy link
Member

One thing I notice is a mismatch between backend and frontend. On backend we say "EncryptedPrivate" but on this we say "privateEncrypted"... I would change it to "encryptedPrivate" here in Echo so it matches.

@it-can
Copy link
Contributor Author

it-can commented Apr 2, 2020

One thing I notice is a mismatch between backend and frontend. On backend we say "EncryptedPrivate" but on this we say "privateEncrypted"... I would change it to "encryptedPrivate" here in Echo so it matches.

yeah I also noticed it... Pusher uses private-encrypted... But I guess changing the naming in Laravel is a breaking change... I'll change my PR

@it-can
Copy link
Contributor Author

it-can commented Apr 2, 2020

@taylorotwell ok renamed it

@taylorotwell taylorotwell merged commit f0448c5 into laravel:master Apr 3, 2020
@taylorotwell
Copy link
Member

Released Echo 1.7.0 on NPM.

@it-can
Copy link
Contributor Author

it-can commented Apr 3, 2020

Thanks Taylor!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants