Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix using function _is_strict_origin_policy_enabled in BMI and SEP #115

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading