django-auth-adfs 1.11.4__tar.gz → 1.11.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-auth-adfs
3
- Version: 1.11.4
3
+ Version: 1.11.5
4
4
  Summary: A Django authentication backend for Microsoft ADFS and AzureAD
5
5
  Home-page: https://github.com/snok/django-auth-adfs
6
6
  License: BSD
@@ -4,4 +4,4 @@ This file is imported by setup.py
4
4
  Adding imports here will break setup.py
5
5
  """
6
6
 
7
- __version__ = '1.11.4'
7
+ __version__ = '1.11.5'
@@ -78,6 +78,7 @@ class Settings(object):
78
78
  self.PROXIES = None
79
79
 
80
80
  self.VERSION = 'v1.0'
81
+ self.SCOPES = []
81
82
 
82
83
  required_settings = [
83
84
  "AUDIENCE",
@@ -138,6 +139,10 @@ class Settings(object):
138
139
  elif "VERSION" in _settings:
139
140
  raise ImproperlyConfigured("The VERSION cannot be set when TENANT_ID is not set.")
140
141
 
142
+ if self.VERSION == "v2.0" and not self.SCOPES and self.RELYING_PARTY_ID:
143
+ warnings.warn('Use `SCOPES` for AzureAD instead of RELYING_PARTY_ID', DeprecationWarning)
144
+ if not isinstance(self.SCOPES, list):
145
+ raise ImproperlyConfigured("Scopes must be a list")
141
146
  # Overwrite defaults with user settings
142
147
  for setting, value in _settings.items():
143
148
  if hasattr(self, setting):
@@ -346,7 +351,10 @@ class ProviderConfig(object):
346
351
  })
347
352
  if self._mode == "openid_connect":
348
353
  if settings.VERSION == 'v2.0':
349
- query["scope"] = f"openid api://{settings.RELYING_PARTY_ID}/.default"
354
+ if settings.SCOPES:
355
+ query['scope'] = " ".join(settings.SCOPES)
356
+ else:
357
+ query["scope"] = f"openid api://{settings.RELYING_PARTY_ID}/.default"
350
358
  query.pop("resource")
351
359
  else:
352
360
  query["scope"] = "openid"
@@ -11,4 +11,5 @@ app_name = "rest_framework"
11
11
 
12
12
  urlpatterns = [
13
13
  re_path(r'^login$', views.OAuth2LoginView.as_view(), name='login'),
14
+ re_path(r'^logout$', views.OAuth2LogoutView.as_view(), name='logout'),
14
15
  ]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = 'django-auth-adfs'
3
- version = "1.11.4" # Remember to also change __init__.py version
3
+ version = "1.11.5" # Remember to also change __init__.py version
4
4
  description = 'A Django authentication backend for Microsoft ADFS and AzureAD'
5
5
  authors = ['Joris Beckers <joris.beckers@gmail.com>']
6
6
  maintainers = ['Jonas Krüger Svensson <jonas-ks@hotmail.com>', 'Sondre Lillebø Gundersen <sondrelg@live.no>']
@@ -1,38 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['django_auth_adfs']
6
-
7
- package_data = \
8
- {'': ['*'], 'django_auth_adfs': ['templates/django_auth_adfs/*']}
9
-
10
- install_requires = \
11
- ['PyJWT>=2.4.0,<3.0.0',
12
- 'cryptography>=1.7,<40.0',
13
- 'requests>=1,<3',
14
- 'urllib3>=1.26.0,<2.0.0']
15
-
16
- extras_require = \
17
- {':python_full_version <= "3.7.0"': ['django>=3,<4'],
18
- ':python_version >= "3.8"': ['django>=3,<5']}
19
-
20
- setup_kwargs = {
21
- 'name': 'django-auth-adfs',
22
- 'version': '1.11.4',
23
- 'description': 'A Django authentication backend for Microsoft ADFS and AzureAD',
24
- 'long_description': 'ADFS Authentication for Django\n==============================\n\n.. image:: https://readthedocs.org/projects/django-auth-adfs/badge/?version=latest\n :target: http://django-auth-adfs.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n.. image:: https://img.shields.io/pypi/v/django-auth-adfs.svg\n :target: https://pypi.python.org/pypi/django-auth-adfs\n.. image:: https://img.shields.io/pypi/pyversions/django-auth-adfs.svg\n :target: https://pypi.python.org/pypi/django-auth-adfs#downloads\n.. image:: https://img.shields.io/pypi/djversions/django-auth-adfs.svg\n :target: https://pypi.python.org/pypi/django-auth-adfs\n.. image:: https://codecov.io/github/snok/django-auth-adfs/coverage.svg?branch=master\n :target: https://codecov.io/github/snok/django-auth-adfs?branch=master\n\nA Django authentication backend for Microsoft ADFS and Azure AD\n\n* Free software: BSD License\n* Homepage: https://github.com/snok/django-auth-adfs\n* Documentation: http://django-auth-adfs.readthedocs.io/\n\nFeatures\n--------\n\n* Integrates Django with Active Directory on Windows 2012 R2, 2016 or Azure AD in the cloud.\n* Provides seamless single sign on (SSO) for your Django project on intranet environments.\n* Auto creates users and adds them to Django groups based on info received from ADFS.\n* Django Rest Framework (DRF) integration: Authenticate against your API with an ADFS access token.\n\nInstallation\n------------\n\nPython package::\n\n pip install django-auth-adfs\n\nIn your project\'s ``settings.py`` add these settings.\n\n.. code-block:: python\n\n AUTHENTICATION_BACKENDS = (\n ...\n \'django_auth_adfs.backend.AdfsAuthCodeBackend\',\n ...\n )\n\n INSTALLED_APPS = (\n ...\n # Needed for the ADFS redirect URI to function\n \'django_auth_adfs\',\n ...\n\n # checkout the documentation for more settings\n AUTH_ADFS = {\n "SERVER": "adfs.yourcompany.com",\n "CLIENT_ID": "your-configured-client-id",\n "RELYING_PARTY_ID": "your-adfs-RPT-name",\n # Make sure to read the documentation about the AUDIENCE setting\n # when you configured the identifier as a URL!\n "AUDIENCE": "microsoft:identityserver:your-RelyingPartyTrust-identifier",\n "CA_BUNDLE": "/path/to/ca-bundle.pem",\n "CLAIM_MAPPING": {"first_name": "given_name",\n "last_name": "family_name",\n "email": "email"},\n }\n\n # Configure django to redirect users to the right URL for login\n LOGIN_URL = "django_auth_adfs:login"\n LOGIN_REDIRECT_URL = "/"\n\n ########################\n # OPTIONAL SETTINGS\n ########################\n\n MIDDLEWARE = (\n ...\n # With this you can force a user to login without using\n # the LoginRequiredMixin on every view class\n #\n # You can specify URLs for which login is not enforced by\n # specifying them in the LOGIN_EXEMPT_URLS setting.\n \'django_auth_adfs.middleware.LoginRequiredMiddleware\',\n )\n\nIn your project\'s ``urls.py`` add these paths:\n\n.. code-block:: python\n\n urlpatterns = [\n ...\n path(\'oauth2/\', include(\'django_auth_adfs.urls\')),\n ]\n\nThis will add these paths to Django:\n\n* ``/oauth2/login`` where users are redirected to, to initiate the login with ADFS.\n* ``/oauth2/login_no_sso`` where users are redirected to, to initiate the login with ADFS but forcing a login screen.\n* ``/oauth2/callback`` where ADFS redirects back to after login. So make sure you set the redirect URI on ADFS to this.\n* ``/oauth2/logout`` which logs out the user from both Django and ADFS.\n\nYou can use them like this in your django templates:\n\n.. code-block:: html\n\n <a href="{% url \'django_auth_adfs:logout\' %}">Logout</a>\n <a href="{% url \'django_auth_adfs:login\' %}">Login</a>\n <a href="{% url \'django_auth_adfs:login-no-sso\' %}">Login (no SSO)</a>\n\nContributing\n------------\nContributions to the code are more then welcome.\nFor more details have a look at the ``CONTRIBUTING.rst`` file.\n',
25
- 'author': 'Joris Beckers',
26
- 'author_email': 'joris.beckers@gmail.com',
27
- 'maintainer': 'Jonas Krüger Svensson',
28
- 'maintainer_email': 'jonas-ks@hotmail.com',
29
- 'url': 'https://github.com/snok/django-auth-adfs',
30
- 'packages': packages,
31
- 'package_data': package_data,
32
- 'install_requires': install_requires,
33
- 'extras_require': extras_require,
34
- 'python_requires': '>=3.7,<4.0',
35
- }
36
-
37
-
38
- setup(**setup_kwargs)