Symfony2.3 - 如何在 iframe 中进行身份验证

Symfony2.3 - how to authenticate in iframe

我有一个带有 iframe 的外部页面,其中应该加载特定的 Symfony 页面。不幸的是,该页面需要登录,所以我尝试使用 _password 和 _username 创建一个不可见的表单作为目标提交到 iframe:

<form target="theiframe" id="theiframe" name="frameform" method="post" action="http://someurl.com/login_check">
<input type="hidden" id="username" name="_username" placeholder="User" value="theusername" required="" autofocus="">
<input type="hidden" id="password" name="_password" placeholder="Passwort" value="thepassword" required="">
</form>
<iframe width="100%" height="500" frameborder="0" name="theiframe" id="theiframe" src=""></iframe>

但出于某种原因,当我尝试此操作时,Symfony 将我重定向到登录表单并出现错误:

Your session has timed out, or you have disabled cookies.

我一重新加载页面,它就突然起作用了。这只是第一次失败的尝试。

有办法解决这个问题吗?如何?

转到 external_page symfony2 中的 secure.yml。并添加:

secured_area:
    ...
    form_login:
        ...
        require_previous_session: false