From f2eed93b77cd63fa838bd21bda6707dd155442a1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 16 Apr 2021 17:30:31 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Create=20PAM=20Authentication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 30 +++++++++++++++++++++++++++++- pyproject.toml | 1 + sophon/settings.py | 5 +++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 430a317..c07411e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -53,6 +53,18 @@ python-versions = ">=3.5" [package.dependencies] Django = ">=2.2" +[[package]] +name = "django-pam" +version = "2.0.0" +description = "Django PAM can be used in an SSO (Single Sign On) environment or just with a single box where you want to log into a Django app with your UNIX login." +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +python-pam = "*" +six = "*" + [[package]] name = "djangorestframework" version = "3.12.4" @@ -172,6 +184,14 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" [package.dependencies] six = ">=1.5" +[[package]] +name = "python-pam" +version = "1.8.4" +description = "Python PAM module using ctypes, py3/py2" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "pytz" version = "2021.1" @@ -230,7 +250,7 @@ brotli = ["brotlipy (>=0.6.0)"] [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "b79811649c3f98842553f41cea22d6dca824ea558e7f59e3060484fa7ee67313" +content-hash = "d569ed4cdb36fab2d02b160c3e8aeb5ecaba83a04841c7c42a5b0d2910761c31" [metadata.files] asgiref = [ @@ -253,6 +273,10 @@ django-filter = [ {file = "django-filter-2.4.0.tar.gz", hash = "sha256:84e9d5bb93f237e451db814ed422a3a625751cbc9968b484ecc74964a8696b06"}, {file = "django_filter-2.4.0-py3-none-any.whl", hash = "sha256:e00d32cebdb3d54273c48f4f878f898dced8d5dfaad009438fe61ebdf535ace1"}, ] +django-pam = [ + {file = "django-pam-2.0.0.tar.gz", hash = "sha256:eab4b1b5390405daa091df2d645119f8670c5bbd624b62eba7f858b627a038f2"}, + {file = "django_pam-2.0.0-py2.py3-none-any.whl", hash = "sha256:18935739ffeedd4564e249dfb6ef5d0fe6b3016cbd444ff85a72fbda77cc3e8a"}, +] djangorestframework = [ {file = "djangorestframework-3.12.4-py3-none-any.whl", hash = "sha256:6d1d59f623a5ad0509fe0d6bfe93cbdfe17b8116ebc8eda86d45f6e16e819aaf"}, {file = "djangorestframework-3.12.4.tar.gz", hash = "sha256:f747949a8ddac876e879190df194b925c177cdeb725a099db1460872f7c0a7f2"}, @@ -396,6 +420,10 @@ python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, {file = "python_dateutil-2.8.1-py2.py3-none-any.whl", hash = "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"}, ] +python-pam = [ + {file = "python-pam-1.8.4.tar.gz", hash = "sha256:c856d9c89fedb33951dd8a95727ae57c6887b02d065bbdffd2fd9dbc0183909b"}, + {file = "python_pam-1.8.4-py2.py3-none-any.whl", hash = "sha256:8439b470b564ac558585b5a3ffce0fce48d1eeebdff19add48279c33de7da0e0"}, +] pytz = [ {file = "pytz-2021.1-py2.py3-none-any.whl", hash = "sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798"}, {file = "pytz-2021.1.tar.gz", hash = "sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da"}, diff --git a/pyproject.toml b/pyproject.toml index 0bd5a7c..f06529d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ Markdown = "^3.3.4" django-filter = "^2.4.0" pandaSDMX = "^1.4.2" pydantic = "~1.7.3" +django-pam = "^2.0.0" [tool.poetry.dev-dependencies] diff --git a/sophon/settings.py b/sophon/settings.py index 610b2d2..2d47890 100644 --- a/sophon/settings.py +++ b/sophon/settings.py @@ -110,6 +110,11 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] +AUTHENTICATION_BACKENDS = [ + 'django_pam.auth.backends.PAMBackend', + 'django.contrib.auth.backends.ModelBackend', +] + # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/