1
我試過使用http_basic身份驗證來測試Symfony的安全軟件包。但是,當我嘗試使用管理員/管理員憑據登錄並提交時,它會一直詢問它們。Symfony http_basic身份驗證不斷要求輸入憑據
這是security.yml文件
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
providers:
in_memory:
memory:
users:
admin:
password: admin
roles: 'ROLE_ADMIN'
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
http_basic: ~
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }]
這是主控制器
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class MainController extends Controller {
/**
* @Route("/", name="homepage")
*/
public function indexAction() {
return new Response('<html><body>Home page1!</body></html>');
}
/**
* @Route("/admin", name="admin_homepage")
*/
public function adminIndexAction() {
return new Response('<html><body>Admin page1!</body></html>');
}
}
?>
服務器是住在這裏:http://sym.soferonline.ro/admin
還有什麼問題呢? 謝謝!
我已經試過這個,但它仍然不起作用 –