Symfony2 をフレームワークとして使用して Web アプリを開発しています。ユーザーはログインして残りのサービスを使用する必要があります。ユーザーの認証に symfony のファイアウォールを使用しています。
ファイアウォールコードは
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/login$
security: false
secured_area:
pattern: ^/
form_login: ~
logout: ~
コントローラーコードは
public function indexAction()
{
return $this->redirect($this->generateUrl('index_search'));
}
public function loginAction() {
$request = $this->getRequest();
$session = $request->getSession();
// get the login error if there is one
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render('IsBeagleBundle:Auth:login.html.php', array(
// last username entered by the user
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
}
ルートは
$collection->add('index', new Route('/', array(
'_controller' => 'IsBeagleBundle:Auth:index',
)));
$collection->add('login', new Route('/login', array(
'_controller' => 'IsBeagleBundle:Auth:login',
)));
$collection->add('login_check', new Route('/login_check', array()));
私が直面している問題は
ファイアウォール認証に合格した場合、リダイレクトは完全に機能し、検索ページに移動しますが、認証に失敗した場合は、503 Service Unavailable
ステータスと共に返され、ログイン ページに再度移動する必要があります。
しかし、空のページを更新すると、ログイン ページが表示されます。
誰かが私が間違っていたことを理解できますか?
EDIT 1 - 出力
編集2
フロントコントローラーの次の行をコメントアウトするとapp.php
、
$kernel = new AppCache($kernel);
その後、返されるステータスは に変更されますが200
、長い待ち時間がかかり、応答は空です。私が理解した他のことは、ログインコントローラー内でsymfonyセッション変数を出力しようとした場合です
$request = $this->getRequest();
$session = $request->getSession();
echo '<pre>';
print_r($session);
echo '</pre>';
時間とメモリがかかりすぎて、終わりがありません。これにより、ブラウザがフリーズします。理由はわかりませんでした。
PS : symfony の標準ディストリビューションを使用しています