API Authentication

  • Hi,

    i have a question about pagekit authentication system. I want to create an API that's secured by @Access Annotations.

    At the moment i use this API for my pagekit-extension.

    Now i'd like to try to use the same API Endpoints from an third-party-application. So i need some authentication. I'd like to work with an API-Token, that can be generated for each user.

    This token can be set in the header or query of the requests. How can i do something like that?

    I think that can be useful for many other developers, too.

  • Since Pagekit is based on Symfony, there is a easy method to do Symfony authentication of the token. You can use the Guard component. For this you will have to Guard and setup authenticator Class. Now, configure the authenticator by updating the Firewall. After that you will have to register the authenticator as a service in your yml file. Now you can test the response with this command

    1. curl -H "X-AUTH-TOKEN: username" http://your_app_url