0

I am trying to implement the FOSOAuthServerBundle. I need it in order to create a centralized authentication function that will be shared by some other projects.

I followed the tutorial from here: Getting Started With FOSOAuthServerBundle

But I have a problem now: When trying to access the route auth.local/app_dev.php/oauth/v2/auth, I am getting the following error:

InvalidConfigurationException: The child node "providers" at path "security" must be configured.

Here is my security.yml:

security:
firewalls:
    api:
        pattern: /api
        fos_oauth: true
        stateless: true
    oauth_authorize:
        pattern: /oauth/v2/auth 
        form_login:
            provider: fos_userbundle
            check_path: /oauth/v2/auth_login_check
            login_path: /oauth/v2/auth_login
        anonymous: true
    oauth_token:
        pattern: /oauth/v2/token
        security: false      

access_control:
    - { path: ^/oauth/v2/auth_login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265

1 Answers1

2

This error doesn't have much to do with FOSOAuthServerBundle, but rather your security.yml configuration. You haven't specified a provider, so symfony doesn't know where to load the users from. You should read the security page in the Symfony docs to see how to configure it properly. If you want users that are in a database, look at loading users from a database. Either way, you should have a security.yml that has a structure like this:

security:
    encoders: #your encoder here
    providers: #your provider here
    firewalls: #your firewalls here
    access_control: #your access_control here

You can fill in each section by looking through the docs and using what suits your needs best, there are lots of options. But you must have a providers section.

Sehael
  • 3,678
  • 21
  • 35
  • Thank you @Sehal. I see, but in fact in the FOSOAuthServerBundle tutorial, it is not mentioned to add providers in the security.yml Am I doing something wrong there? – Milos Cuculovic Dec 03 '14 at 13:43
  • the documentation for the bundle on github is just showing an example of how to configure the parts of your security.yml that are relevant to the bundle. It assumes that you know how to configure security.yml properly before hand. – Sehael Dec 03 '14 at 16:39
  • I see. Thanks. Is there a full example of a working project using this FOSOAuthServerBundle ? – Milos Cuculovic Dec 04 '14 at 10:12
  • take a look at this answer [here](http://stackoverflow.com/questions/21259190/how-to-implement-fosoauthserverbundle-to-secure-an-rest-api/21264949#21264949). there are some links to a blog and a decent overview of how to set it up. – Sehael Dec 04 '14 at 16:13