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

[6.x] RedisBroadcaster - Ignore Redis Prefix When Verifying Channel Access #30597

Merged
merged 2 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function __construct(Redis $redis, $connection = null)
*/
public function auth($request)
{
$channelName = $this->normalizeChannelName($request->channel_name);
$channelName = str_replace(config('database.redis.options.prefix', ''), '', $request->channel_name);
$channelName = $this->normalizeChannelName($channelName);

if ($this->isGuardedChannel($request->channel_name) &&
! $this->retrieveUser($request, $channelName)) {
Expand Down
21 changes: 21 additions & 0 deletions tests/Broadcasting/RedisBroadcasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Illuminate\Tests\Broadcasting;

use Illuminate\Broadcasting\Broadcasters\RedisBroadcaster;
use Illuminate\Config\Repository as Config;
use Illuminate\Container\Container;
use Illuminate\Http\Request;
use Mockery as m;
use PHPUnit\Framework\TestCase;
Expand All @@ -20,6 +22,11 @@ protected function setUp(): void
parent::setUp();

$this->broadcaster = m::mock(RedisBroadcaster::class)->makePartial();
$container = Container::setInstance(new Container);

$container->singleton('config', function () {
return $this->createConfig();
});
}

protected function tearDown(): void
Expand Down Expand Up @@ -139,6 +146,20 @@ public function testValidAuthenticationResponseWithPresenceChannel()
);
}

/**
* Create a new config repository instance.
*
* @return \Illuminate\Config\Repository
*/
protected function createConfig()
{
return new Config([
'redis' => [
'options' => ['prefix' => 'laravel_database_'],
],
]);
}

/**
* @param string $channel
* @return \Illuminate\Http\Request
Expand Down