2017-06-30 4 views
1

$app['security.authentication_manager']からデフォルトの認証プロバイダUserAuthenticationProviderを削除する方法はありますか?Silex 2:デフォルト認証プロバイダを削除するUserAuthenticationProvider

独自の認証プロバイダを作成しましたが、認証プロセスがそのように機能しないため、DaoAuthenticationProviderを呼び出す既定のものを使用してユーザーパスワードを確認する必要はありません。

この時点で、認証マネージャは2つの認証プロバイダを呼び出します。私のカスタムとデフォルトの認証プロバイダです。成功した認証を許可するために、私はテストをスキップするためにDAOを上書きしますが、それはきれいではありません。

カスタム認証プロバイダ

$app['security.authentication_listener.factory.sds'] = $app->protect(function ($name, $options) use ($app) { 
    // define the authentication provider object 
    $app['security.authentication_provider.'.$name.'.sds'] = function() use ($app) { 
     return new CustomAuthenticationProvider($app['user.provider'], $app['security.encoder_factory']); 
    }; 

    // define the authentication listener object 
    $app['security.authentication_listener.'.$name.'.sds'] = function() use ($app) { 
     return new CustomAuthenticationListener($app['security.token_storage'], $app['security.authentication_manager']); 
    }; 

    return array(
     // the authentication provider id 
     'security.authentication_provider.'.$name.'.sds', 
     // the authentication listener id 
     'security.authentication_listener.'.$name.'.sds', 
     // the entry point id 
     null, 
     // the position of the listener in the stack 
     'pre_auth' 
    ); 
}); 

は、カスタムcalssを使用してテストをスキップするDAOを上書きします。私はその点を避けるために、認証マネージャーからDAO呼び出しを取り除いています。

$app['security.authentication_provider.dao._proto'] = $app->protect(function ($name) use($app) { 
     return new \Trilogis\Classes\CustomUserAuthenticationProvider(
      $app['security.user_provider.' . $name], 
      $app['security.user_checker'], 
      $name, 
      $app['security.encoder_factory'] 
     ); 
    }); 
+0

'sds'ファイアウォールのセキュリティ設定を追加してください –

答えて

0

だけで簡単に推測していますが、唯一のあなたを有効にするために$app['security.authentication_providers']配列を上書きしてみてください。

<?php 
//... 
// overriding available providers to only allow mine 
$app['security.authentication_providers'] = [ 
    $app['security.authentication_listener.factory.sds'] 
]; 

オーバーライドすると、configuring the Authentication Manager with only one providerとなります。

IMHO、これはDaoAuthenticationProviderを上書きするよりもきれいです

関連する問題