1

I followed the documentation, and this is how my code is organized:

src/Company/AuthBundle/Security/ApiKeyAuthenticator.php src/Company/AuthBundle/Security/ApiKeyUserProvider.php

(they are the same as sample classes in doc)

# File: services.yml

apikey_authenticator:
   class:  Company\AuthBundle\Security\ApiKeyAuthenticator
   public: false    

# File: security.yml

  firewalls: 
    api:
      pattern: ^/api
      stateless: false
      simple_preauth:
      authenticator: apikey_authenticator
      provider: fos_userbundle
      security: false
      anonymous: true

And now, If I try to access e.g. http://symfony-project.dev/api?apikey=somekey, I got the following error:

No route found for "GET /api"

Any idea what's wrong?

1 Answer 1

1

The error message is fairly clear really - you haven't defined a route for a GET request for '/api'.

The security component you've configured takes care of authentication and granting access, but it does not control any logic specific to your application. You must create a controller and a route for requests like this.

You can see your currently defined routes with $ php app/console debug:router - if you've tried to define a route, that will help you debug it. If not, you must create one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.