From a223815def1c952d8a5d306979351659504bd258 Mon Sep 17 00:00:00 2001
From: Epidemy
Date: Sat, 3 Aug 2024 22:14:24 +0330
Subject: [PATCH 1/2] Fix using function _is_strict_origin_policy_enabled in
BMI and SEP and adding it to base banks to adhere to DRY principal
---
azbankgateways/banks/banks.py | 4 ++++
azbankgateways/banks/bmi.py | 3 ---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/azbankgateways/banks/banks.py b/azbankgateways/banks/banks.py
index e1956a5..215dd92 100644
--- a/azbankgateways/banks/banks.py
+++ b/azbankgateways/banks/banks.py
@@ -10,6 +10,7 @@
from django.utils import timezone
from .. import default_settings as settings
+from django.conf import settings as django_settings
from ..exceptions import (
AmountDoesNotSupport,
BankGatewayStateInvalid,
@@ -42,6 +43,9 @@ def __init__(self, identifier: str, **kwargs):
self.identifier = identifier
self.default_setting_kwargs = kwargs
self.set_default_settings()
+
+ def _is_strict_origin_policy_enabled(self):
+ return django_settings.SECURE_REFERRER_POLICY == 'strict-origin-when-cross-origin'
@abc.abstractmethod
def set_default_settings(self):
diff --git a/azbankgateways/banks/bmi.py b/azbankgateways/banks/bmi.py
index 18be354..aa1c524 100644
--- a/azbankgateways/banks/bmi.py
+++ b/azbankgateways/banks/bmi.py
@@ -20,9 +20,6 @@ class BMI(BaseBank):
_terminal_code = None
_secret_key = None
- def _is_strict_origin_policy_enabled(self):
- return settings.SECURE_REFERRER_POLICY == 'strict-origin-when-cross-origin'
-
def __init__(self, **kwargs):
super(BMI, self).__init__(**kwargs)
if not self._is_strict_origin_policy_enabled():
From 7dccf9b219ca9a84431e857b8ea16ba79d45ac35 Mon Sep 17 00:00:00 2001
From: Ali Zahedigol
Date: Tue, 6 Aug 2024 14:16:59 +0300
Subject: [PATCH 2/2] fix: Thanks apidemy #115
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 95e652a..b0a9d90 100644
--- a/README.md
+++ b/README.md
@@ -293,7 +293,7 @@ def go_to_gateway_view(request):
```python
-SECURE_REFERRER_POLICY = 'strict-origin-when-cross-origin'
+SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
```
انتخاب خودکار درگاه
@@ -500,7 +500,7 @@ pre-commit install
* [ahmadrezanavaie](https://github.com/ahmadrezanavaie) رفع مشکل ترجمه
* [zamoosh](https://github.com/zamoosh) اضافه کردن وضعیت های تراکنش در بانک ملت
* [birddevelper](https://github.com/birddevelper) الزامی کردن وجود referrer برای درگاه بانک ملی
-
+* [apidemy](https://github.com/apidemy) ریفکتور _is_strict_origin_policy_enabled و پیروی از DRY
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.