omise / omise-magento

Omise Magento Plugin
https://docs.opn.ooo/magento-plugin
MIT License
34 stars 19 forks source link

[ENGA3-511]: Improve the implementation to prevent the customer entering redirect URL directly in the address bar of the browser #388

Closed aashishgurung closed 2 years ago

aashishgurung commented 2 years ago

1. Objective

Improve the implementation to prevent the customer entering redirect URL directly in the address bar of the browser

Jira Ticket: #511

2. Description of change

Previously, we relied on Referer header for Safari browser and HTTP_SEC_FETCH_SITE header for other browsers to prevent user from triggering redirect URL manually. We knew Referer is not reliable as some browsers limit access to not allow HTTP_REFERER to be passed but we choose it for Safari because i does not support HTTP_SEC_FETCH_SITE.

This implementation was not 100% reliable as some payment gateway sets the value of HTTP_SEC_FETCH_SITE to none instead of cross-site. This will result in customer being redirected to abandoned cart page even though the transaction was legit.

With this PR, we removed the HEADERs checks. We create a random token, save it to the payment of the order and pass it as the query parameters with the return URI to the gateway. Once, it is redirected back, we check whether the token in the query parameter is same as the token saved in the payment of the concerned order. If yes then we proceed with the transaction else we redirect user to empty card page with message Invalid token. Please contact our support if you have any questions.

Screen Shot 2565-10-11 at 14 06 05

3. Quality assurance

Link to screencast: https://drive.google.com/file/d/1lmHnUb62TwWvZ33zpa8GRUDsxQmd9vGp/view?usp=sharing

🔧 Environments:

som-m commented 2 years ago

👍🏻

image
sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

18.0% 18.0% Coverage
0.0% 0.0% Duplication