drsxzut183207938 2018-08-10 05:57
浏览 51
已采纳

Symfony | 验证请求

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?

  • 写回答

2条回答 默认 最新

  • duankuaiwang2706 2018-09-19 11:42
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了