Skip to content

Commit

Permalink
Merge pull request #115 from apidemy/fix-missing-strict-origin-policy…
Browse files Browse the repository at this point in the history
…-func

Fix using function _is_strict_origin_policy_enabled in BMI and SEP
  • Loading branch information
ali-zahedi authored Aug 6, 2024
2 parents a4f648c + 7dccf9b commit 461b427
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def go_to_gateway_view(request):
</p>

```python
SECURE_REFERRER_POLICY = 'strict-origin-when-cross-origin'
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
```

<h3 dir="rtl"> انتخاب خودکار درگاه </h3>
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions azbankgateways/banks/banks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions azbankgateways/banks/bmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 461b427

Please sign in to comment.