Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Drop impersonate

IKarbowiak2c1a5fdb00b5
diff --git a/poetry.lock b/poetry.lock
index 5ef633fc0e..24e1c655c5 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -280,6 +280,7 @@ couchbase = ["couchbase", "couchbase-cffi"]
couchdb = ["pycouchdb"]
django = ["Django (>=1.8)"]
dynamodb = ["boto3 (>=1.4.6)"]
+elasticsearch = ["elasticsearch"]
eventlet = ["eventlet (>=0.24.1)"]
gevent = ["gevent"]
librabbitmq = ["librabbitmq (>=1.5.0)"]
@@ -533,6 +534,19 @@ version = "2.2.0"
[package.dependencies]
Django = ">=1.11"
+[[package]]
+category = "dev"
+description = "Django Debug Toolbar for GraphiQL IDE"
+name = "django-graphiql-debug-toolbar"
+optional = false
+python-versions = "*"
+version = "0.1.4"
+
+[package.dependencies]
+Django = ">=2.0"
+django-debug-toolbar = ">=2.0"
+graphene-django = ">=2.0.0"
+
[[package]]
category = "main"
description = "JSON Web Token for Django GraphQL"
@@ -546,14 +560,6 @@ Django = ">=1.11"
PyJWT = ">=1.5.0"
graphene-django = ">=2.0.0"
-[[package]]
-category = "main"
-description = "Django app to allow superusers to impersonate other users."
-name = "django-impersonate"
-optional = false
-python-versions = "*"
-version = "1.4.1"
-
[[package]]
category = "main"
description = "script tag with additional attributes for django.forms.Media"
@@ -2270,7 +2276,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
testing = ["pathlib2", "contextlib2", "unittest2"]
[metadata]
-content-hash = "1ee91cd4db26b127e36efae7b61a0611d2e0c8e1d14df02a9cf727276afa1e51"
+content-hash = "055ed0b43d81ca92b6b73e232754ef093c25d59cb946937efeb1d7db80db18ad"
python-versions = "~3.8"
[metadata.files]
@@ -2508,12 +2514,12 @@ django-filter = [
{file = "django-filter-2.2.0.tar.gz", hash = "sha256:c3deb57f0dd7ff94d7dce52a047516822013e2b441bed472b722a317658cfd14"},
{file = "django_filter-2.2.0-py3-none-any.whl", hash = "sha256:558c727bce3ffa89c4a7a0b13bc8976745d63e5fd576b3a9a851650ef11c401b"},
]
+django-graphiql-debug-toolbar = [
+ {file = "django-graphiql-debug-toolbar-0.1.4.tar.gz", hash = "sha256:946fba21418b3fd57e7e357d4cd110fb7881e08d3b7a0a8a00400fa2e75965f5"},
+]
django-graphql-jwt = [
{file = "django-graphql-jwt-0.2.1.tar.gz", hash = "sha256:6dcf9dd4990098e289d76ab4220edbf436a2e26dc6af1d4a526ac699ad93bf14"},
]
-django-impersonate = [
- {file = "django-impersonate-1.4.1.tar.gz", hash = "sha256:63b62d06f93b0318698c68f7314c78473914c262d4164eb66ad860bb83e04771"},
-]
django-js-asset = [
{file = "django-js-asset-1.2.2.tar.gz", hash = "sha256:c163ae80d2e0b22d8fb598047cd0dcef31f81830e127cfecae278ad574167260"},
{file = "django_js_asset-1.2.2-py2.py3-none-any.whl", hash = "sha256:8ec12017f26eec524cab436c64ae73033368a372970af4cf42d9354fcb166bdd"},
diff --git a/pyproject.toml b/pyproject.toml
index f8a7113be3..a605448ee1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -27,7 +27,6 @@ django-cache-url = "^3.0"
django-countries = "^5.3"
django-filter = "^2.2"
django-graphql-jwt = "<=0.2.1" # https://github.com/mirumee/saleor/issues/4652
-django-impersonate = "^1.4.1"
django-measurement = "^3.0"
django-mptt = "^0"
django-phonenumber-field = "^2.4"
diff --git a/requirements.txt b/requirements.txt
index 5035e197de..2c51bd8ea8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -113,8 +113,6 @@ django-filter==2.2.0 \
--hash=sha256:558c727bce3ffa89c4a7a0b13bc8976745d63e5fd576b3a9a851650ef11c401b
django-graphql-jwt==0.2.1 \
--hash=sha256:6dcf9dd4990098e289d76ab4220edbf436a2e26dc6af1d4a526ac699ad93bf14
-django-impersonate==1.4.1 \
- --hash=sha256:63b62d06f93b0318698c68f7314c78473914c262d4164eb66ad860bb83e04771
django-js-asset==1.2.2 \
--hash=sha256:c163ae80d2e0b22d8fb598047cd0dcef31f81830e127cfecae278ad574167260 \
--hash=sha256:8ec12017f26eec524cab436c64ae73033368a372970af4cf42d9354fcb166bdd
diff --git a/requirements_dev.txt b/requirements_dev.txt
index de837b3b51..c163ec1e80 100644
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@ -192,8 +192,6 @@ django-graphiql-debug-toolbar==0.1.4 \
--hash=sha256:946fba21418b3fd57e7e357d4cd110fb7881e08d3b7a0a8a00400fa2e75965f5
django-graphql-jwt==0.2.1 \
--hash=sha256:6dcf9dd4990098e289d76ab4220edbf436a2e26dc6af1d4a526ac699ad93bf14
-django-impersonate==1.4.1 \
- --hash=sha256:63b62d06f93b0318698c68f7314c78473914c262d4164eb66ad860bb83e04771
django-js-asset==1.2.2 \
--hash=sha256:c163ae80d2e0b22d8fb598047cd0dcef31f81830e127cfecae278ad574167260 \
--hash=sha256:8ec12017f26eec524cab436c64ae73033368a372970af4cf42d9354fcb166bdd
diff --git a/saleor/account/impersonate.py b/saleor/account/impersonate.py
deleted file mode 100644
index e9143a2c5a..0000000000
--- a/saleor/account/impersonate.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Module used to config django-impersonate app
-from .models import User
-
-
-def get_impersonatable_users(request):
- """Return all users that can be impersonated."""
- return User.objects.filter(is_staff=False, is_superuser=False)
-
-
-def can_impersonate(request):
- """Check if the current user can impersonate customers.
-
- `django-impersonate` module requires a function as input argument,
- not just permission name.
- """
- return request.user.has_perm("account.impersonate_users")
diff --git a/saleor/account/migrations/0036_auto_20191209_0407.py b/saleor/account/migrations/0036_auto_20191209_0407.py
new file mode 100644
index 0000000000..5d319b7811
--- /dev/null
+++ b/saleor/account/migrations/0036_auto_20191209_0407.py
@@ -0,0 +1,20 @@
+# Generated by Django 2.2.7 on 2019-12-09 10:07
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [("account", "0035_staffnotificationrecipient")]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name="user",
+ options={
+ "permissions": (
+ ("manage_users", "Manage customers."),
+ ("manage_staff", "Manage staff."),
+ )
+ },
+ )
+ ]
diff --git a/saleor/account/models.py b/saleor/account/models.py
index 79fe6643fb..7d2911e8b0 100644
--- a/saleor/account/models.py
+++ b/saleor/account/models.py
@@ -162,10 +162,6 @@ class User(PermissionsMixin, ModelWithMetadata, AbstractBaseUser):
pgettext_lazy("Permission description", "Manage customers."),
),
("manage_staff", pgettext_lazy("Permission description", "Manage staff.")),
- (
- "impersonate_users",
- pgettext_lazy("Permission description", "Impersonate customers."),
- ),
)
def get_full_name(self):
diff --git a/saleor/core/permissions.py b/saleor/core/permissions.py
index de70c32442..e3186b8e9c 100644
--- a/saleor/core/permissions.py
+++ b/saleor/core/permissions.py
@@ -4,7 +4,6 @@ MODELS_PERMISSIONS = [
"account.manage_users",
"account.manage_staff",
"account.manage_service_accounts",
- "account.impersonate_users",
"discount.manage_discounts",
"giftcard.manage_gift_card",
"extensions.manage_plugins",
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 9a8a8b3835..97aac9c0a1 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -2813,7 +2813,6 @@ enum PermissionEnum {
MANAGE_USERS
MANAGE_STAFF
MANAGE_SERVICE_ACCOUNTS
- IMPERSONATE_USERS
MANAGE_DISCOUNTS
MANAGE_GIFT_CARD
MANAGE_PLUGINS
diff --git a/saleor/settings.py b/saleor/settings.py
index f9a08a0be9..b50bf6a255 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -210,7 +210,6 @@ MIDDLEWARE = [
"saleor.core.middleware.site",
"saleor.core.middleware.extensions",
"social_django.middleware.SocialAuthExceptionMiddleware",
- "impersonate.middleware.ImpersonateMiddleware",
"saleor.graphql.middleware.jwt_middleware",
"saleor.graphql.middleware.service_account_middleware",
]
@@ -259,7 +258,6 @@ INSTALLED_APPS = [
"social_django",
"django_countries",
"django_filters",
- "impersonate",
"phonenumber_field",
"captcha",
]
@@ -549,15 +547,6 @@ CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_SERIALIZER = "json"
CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", None)
-# Impersonate module settings
-IMPERSONATE = {
- "URI_EXCLUSIONS": [r"^dashboard/"],
- "CUSTOM_USER_QUERYSET": "saleor.account.impersonate.get_impersonatable_users", # noqa
- "USE_HTTP_REFERER": True,
- "CUSTOM_ALLOW": "saleor.account.impersonate.can_impersonate",
-}
-
-
# Rich-text editor
ALLOWED_TAGS = [
"a",
diff --git a/tests/conftest.py b/tests/conftest.py
index 0c71c862d1..b72ab9d60f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -25,8 +25,8 @@ from saleor.account.backends import BaseBackend
from saleor.account.models import (
Address,
ServiceAccount,
- User,
StaffNotificationRecipient,
+ User,
)
from saleor.checkout import utils
from saleor.checkout.models import Checkout
@@ -1240,11 +1240,6 @@ def permission_manage_settings():
return Permission.objects.get(codename="manage_settings")
-def permission_impersonate_users():
- return Permission.objects.get(codename="impersonate_users")
-
-
@pytest.fixture
def permission_manage_menus():
return Permission.objects.get(codename="manage_menus")