小编M-K*_*war的帖子

在 Iframe 中嵌入 Laravel 应用程序,登录时出现 302 错误

Laravel app我正在尝试在 中的其他一些域中使用iframe

我写了一个FrameMiddleware,其中我在标头中允许该域

 public function handle(Request $request, Closure $next)
    {
        $response = $next($request);
        $response->header('Content-Security-Policy', 'frame-ancestors http://localhost');
        return $response;
    }

Run Code Online (Sandbox Code Playgroud)

并通过使用上面的中间件 cors origin 错误被删除。

因为我Laravel app需要来自 iframe 的身份验证。它使用表单提交,而不是 API。然后它开始给出一个
419 error. VerifyCsrfToken我通过在中间件数组中添加登录路由$except来排除csrf错误来解决。

然后我检查登录请求给出 302network错误post

iframe 中的 laravel 对于 post 请求给出 302 错误

我测试了身份验证方法,经过身份验证的用户对象通过页面重定向返回Dashboard,然后302 error code显示。

而且,我已经开始same_site => null工作了config/session.php,但仍然没有工作。

php authentication iframe laravel csrf-token

4
推荐指数
1
解决办法
3603
查看次数

标签 统计

authentication ×1

csrf-token ×1

iframe ×1

laravel ×1

php ×1