在没有 Lumen/Laravel 会话的情况下使用 Lumen + Dingo + JWT
Using Lumen + Dingo + JWT without Lumen/Laravel Session
我们正在使用基于以下存储库 lumen-dingo 的 Lumen/Dingo 实现。我们正在现有框架之上构建它,这会带来一些小问题。
我们的框架在整个应用程序中使用它自己的会话对象,无法更改它。我们最理想的是更改 Lumen + Dingo + JWT 设置,以便它使用我们的会话。
我不知道在这里做什么最好。我可以想到三种可能的解决方案:
- 在 Lumen 中创建一个自定义会话驱动程序,它将初始化我们的框架会话。
- 完全忽略 Lumen 会话
在正常会话旁边使用流明会话,因此它们同时处于活动状态,但我不知道这是否有效。
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
| NOTE: "token" driver is not supported in JWT Auth
|
*/
'guards' => [
'api' => [
'driver' => 'session',
'provider' => 'users'
],
],
我正在尝试编辑这些详细信息,但我一直 运行 出错。不知道是我做错了什么,还是完全走错了路
您为什么使用 Lumen 会话?
Lumen 仅用于构建 API,因此应该是无状态的!
在 Lumen 5.2 中,他们完全取消了对会话的支持。
Lumen 5.2 represents a shift on slimming Lumen to focus solely focusing serving stateless, JSON APIs. As such, sessions and views are no longer included with the framework.
我们正在使用基于以下存储库 lumen-dingo 的 Lumen/Dingo 实现。我们正在现有框架之上构建它,这会带来一些小问题。
我们的框架在整个应用程序中使用它自己的会话对象,无法更改它。我们最理想的是更改 Lumen + Dingo + JWT 设置,以便它使用我们的会话。
我不知道在这里做什么最好。我可以想到三种可能的解决方案:
- 在 Lumen 中创建一个自定义会话驱动程序,它将初始化我们的框架会话。
- 完全忽略 Lumen 会话
在正常会话旁边使用流明会话,因此它们同时处于活动状态,但我不知道这是否有效。
/* |-------------------------------------------------------------------------- | Authentication Guards |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. | Of course, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | Supported: "session" | | NOTE: "token" driver is not supported in JWT Auth | */ 'guards' => [ 'api' => [ 'driver' => 'session', 'provider' => 'users' ], ],
我正在尝试编辑这些详细信息,但我一直 运行 出错。不知道是我做错了什么,还是完全走错了路
您为什么使用 Lumen 会话?
Lumen 仅用于构建 API,因此应该是无状态的!
在 Lumen 5.2 中,他们完全取消了对会话的支持。
Lumen 5.2 represents a shift on slimming Lumen to focus solely focusing serving stateless, JSON APIs. As such, sessions and views are no longer included with the framework.