我不知道如何使用SecurityServiceProvider
在Silex
。我的配置是:Silex SecurityServiceProvider引發'標識符'security.authentication_providers「未定義。'
$app['security.firewalls'] = array(
'admin' => array(
'pattern' => '^/_admin/.+',
'form' => array('login_path' => '/_admin/', 'check_path' => '/_admin/login_check'),
'logout' => array('logout_path' => '/_admin/logout'),
'users' => array(
'admin' => array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsR...'),
),
),
);
$app->register(new Silex\Provider\SecurityServiceProvider());
這只是拋出:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Identifier "security.authentication_providers" is not defined.'
根據在某些情況下的文檔時,您要訪問的安全功能的請求的處理外,你必須調用$app->boot();
但這不是我的情況。
如果我打電話$app->boot();
$app->register(...)
之前,不會引發任何異常,但它可能是因爲當時在產生登錄表單的樹枝引發不開機可言:
Unable to generate a URL for the named route "_admin_login_check" as such route does not exist.
有an issue a few months ago有可能是相同的問題,但它關閉所以我想現在應該修復了
也許不相關的問題,但你不與兩個中的一個實現黃金法則(它們在文檔中陳述):您的login_path必須定義在限制區域之外。你的位於/ _admin /,而你的禁區位於/_admin/.+,所以你沒有在外界定義它。 – mTorres
我不這麼認爲。表達式'/ _admin /.+'不匹配'/ _admin /'路徑,所以'/ _admin /'在禁區之外。 – martin