流明5.3身份验证 [英] Lumen 5.3 Authentication

查看:74
本文介绍了流明5.3身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Lumen并尝试实现身份验证.

I have installed Lumen and trying to implement authentication.

我正在使用Laravel Framework版本Lumen(5.3.3)(Laravel组件5.3.*).

I am using Laravel Framework version Lumen (5.3.3) (Laravel Components 5.3.*).

在app.php中,我未对以下内容发表评论.

In app.php I have uncommented the following.

$app->withFacades();

$app->routeMiddleware([
     'auth' => App\Http\Middleware\Authenticate::class,
 ]);

$app->register(App\Providers\AuthServiceProvider::class);

\app\Providers\AuthServiceProvider.php

public function boot() {
        $this->app['auth']->viaRequest('api', function ($request) {
            if ($request->input('api_token')) {
                return User::where('api_token', $request->input('api_token'))->first();
            }
        });
}

在调试时,viaRequest方法未执行.

Here when I debugged, viaRequest method is not getting executed.

推荐答案

您是否按照以下方式定义了路线:

Did you define your route as follow:

$app->get('endpoint', ['middleware' => 'auth', function () { /* some code */ }]);

将Auth中间件分配给路由.

assigning the Auth middleware to a route.

这篇关于流明5.3身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆