设置后卫订阅验证

发布于 2025-01-21 20:48:01 字数 597 浏览 1 评论 0原文

  • Laravel6
  • Lighthouse-PHP5

我正在使用Lighthouse-PHP进行GraphQL订阅和推动器。 Lighthouse-PHP5给出GraphQL/usivections/auth。但是我找不到如何设置此API。

我的应用程序具有多个身份验证(用户和管理员),因此我想切换Guard。 然后,我创建API路由,

Route::middleware(['guard_xxx'])->group(function(){
    Route::post('xxx/graphql/subscriptions/auth', '\Nuwave\Lighthouse\Subscriptions\SubscriptionController@authorize');
});

config/lighthouse.php

'guard' => 'guard_yyy',

i运行xxx/graphql/subpcriptions/auth,但guard_yyy运行。我想使用guard_xxx。

  • Laravel6
  • lighthouse-php5

I'm using lighthouse-php for GraphQL Subscription and pusher.
lighthouse-php5 gives graphql/subscriptions/auth. But I can't find how to set guard this api.

My app has multiple authentications(user and admin), so I want to switch guard.
Then I create the api route,

Route::middleware(['guard_xxx'])->group(function(){
    Route::post('xxx/graphql/subscriptions/auth', '\Nuwave\Lighthouse\Subscriptions\SubscriptionController@authorize');
});

config/lighthouse.php

'guard' => 'guard_yyy',

I run xxx/graphql/subscriptions/auth, but guard_yyy run. I want to use guard_xxx.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月棠 2025-01-28 20:48:01

您已经手动定义了订阅身份验证路线。我认为正在发生的事情是灯塔覆盖了那个。您将需要禁用一个灯塔正在注册,您可以通过进入config/lighthouse.php配置文件并查找所使用的广播公司来做到这一点,它应该看起来像这样:

    'subscriptions' => [
        // ...
        'broadcasters' => [
            // ...
            'pusher' => [
                'driver' => 'pusher',
                'routes' => \Nuwave\Lighthouse\Subscriptions\SubscriptionRouter::class . '@pusher',
                'connection' => 'pusher',
            ],
        ],

删除路由从广播员配置中键,以阻止灯塔注册广播身份验证路由本身,以便您可以定义它并为其设置不同的后卫。

另请注意,此WIR还会导致不注册您可能需要的Pusher Webhook路由,因此您也需要自己定义一个。

You have manually defined the subscriptions authentication route. I think what is happening is that Lighthouse overrides that one. You will need to disable the one Lighthouse is registering, you can do that by going into your config/lighthouse.php config file and finding the broadcaster you are using, it should look something like this:

    'subscriptions' => [
        // ...
        'broadcasters' => [
            // ...
            'pusher' => [
                'driver' => 'pusher',
                'routes' => \Nuwave\Lighthouse\Subscriptions\SubscriptionRouter::class . '@pusher',
                'connection' => 'pusher',
            ],
        ],

Remove the routes key from the broadcaster configuration to stop Lighthouse from registering the broadcasting authentication route itself so you can define it and set a different guard for it.

Also note that this wil also result in not registering the Pusher webhook route which you might need, so you will need to define that one yourself too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文