douyingyu5573 2016-04-27 10:57
浏览 54

是否可以在Silex应用程序中使用Symfony Security链提供程序?

I have an application that has so far been using Basic authentication. One of the requirements of the application was to allow authentication using OAuth.

I have started to implement this using the OAuthServiceProvider (https://github.com/gigablah/silex-oauth) and I have got it to work.

However I would like to have multiple authentication providers. This is so that I can register users within the application for people that do not have such accounts or do not want to use them. This is also because I have a local system user that has 'admin' rights on the application.

I have read around this and I have seen that Symfony 2 has a chain_provider for the security provider. As Silex is based off Symfony I wondered if it possible to implement this in Silex.

I have looked at the code to do it in Symfony - http://symfony.com/doc/current/cookbook/security/multiple_user_providers.html. But I do not know how to translate the YML configuration into service registrations in Silex.

Any help is greatly appreciated.

UPDATE (10 May 2016)

I have removed some information here as it was incorrect. It is not possible to get Silex to use Form and OAuth authentication out of the box.

I will have to go with just OAuth for the moment and live with the fact I cannot have local authentication as well. I want to look into the 'Guard Authentication' as mentioned in the comments, but I cannot find how to use this in Silex at the moment, if anyone has done this and has an example of how to configure the Silex App to use it that would be great.

  • 写回答

1条回答 默认 最新

  • dsdv76767671 2016-08-02 13:24
    关注

    in silex 2.0

    $app->register(new Silex\Provider\SecurityServiceProvider(), [
        'security.firewalls' => [...
             'users' => function ($app) {
                               return new ChainUserProvider(
                                 [$userProviderOne, $userProviderTwo]);) ...
    
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题