阅读(3152) (5)

Laravel 8 仪表板授权

2021-07-09 14:25:43 更新

访问 /telescope 即可显示仪表盘。 默认情况下,您只能在 local 环境中访问此仪表板。在你的 app/Providers/TelescopeServiceProvider.php 文件中,有一个 gate 方法。此授权能控制在 非本地 环境中对 Telescope 的访问。您可以根据需要随意修改此权限以限制对 Telescope 安装和访问:

/**
 * 注册 Telescope gate
 *
 * 该 gate 确定谁可以在非本地环境中访问 Telescope
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewTelescope', function ($user) {
        return in_array($user->email, [
            '[email protected]',
        ]);
    });
} 

注意:你应该确保在生产环境中将 APP_ENV 环境变量更改为 Production。 否则,你的 Telescope 调试工具将公开可用。