Search code examples
phpsymfonysecurityauthenticationsymfony4

Symfony | Authenticate request


I'm trying to create a "service" like application, which can be able to receive API calls from another services. (These services will be built, for different purposes). And also able to send API calls to an another one.

Each request that they send, and accept has to have the following format.

{
    header : {
        // some header information, like locale, currency code etc.
        signature : "some-hashed-data-using-the-whole-request"
    },
    request : {
        // the usable business data
    }
}

To each request I want to append a hash, that is generated from the actual request or anyhow (salted with password or any kind of magic added). Its not that important at the moment. I gave the name signature to this field. So for each received request, I want to reproduce this signature from the request. If the signature I received is matching with the one I generated, I let the application run otherwise showing some error message.

I already read a few articles, but most of them is for user-pass combinations.

My question is not about that if it's a good solution or not. I just want to know how can implement a middleware like functionality - like in laravel - in Symfony 4?


Solution

  • As k0pernikus mentioned, the before after filters solves my issue.