Search code examples
asp.net-coresecuritycallbackasp.net-core-webapi

Securing the call back reqest in ASP.NET Core Web API


I have a Payment Getaway integrated to my project and I want to secure the callback request and after some research the best way was to send a token with the callback request.

Is this the best way or is there better way to handle this?

I have tried this way for my project in staging but it is time to get to production and I really don't know is this a secure way to do that


Solution

  • Securing the call back reqest in ASP.NET Core Web API. Is this the best way or is there better way to handle this? I really don't know is this a secure way to do that.

    Well, without having look at your implementation its really hard to tell whether its secure or better or not.

    Although, token along with callback request is most popular way to handle secure transaction. However, it depends on how the token and cross request has been designed.

    Regarding the secure request and transaction, you should ensure few important configuration.

    First of all, your token shouldn't be simple tokens like random strings. Instead, you should use Hash-Based Message Authentication Code or any cryptographic library or built-in .NET classes. If possible use proper encryption mechanism.

    Another important point is that, token transmission and expirity. Token must be transmitted over https protocal and need to ensure if it doesn't tampered in between. Make sure your transaction token cannot be resuable. Once a transaction completed terminate the token so that it cannot be reused.

    In addition, if possible implement server-side validation to ensure that the received token is valid and not compromised. This may involve verifying the signature of the token (if applicable) and checking its expiration time if tokens are time-limited.

    Now, back to your question if that's the better way?

    Regarding your existing implementation, if you think you already considered above steps and configuration, I think you are good to go.

    Note: Please refer to this official document for some additional idea and best practice guideline for how you could make your data and trasaction more secure.