From 1a1256c17702823d17997540505a8a20aaf77f37 Mon Sep 17 00:00:00 2001 From: Denis Timofeev Date: Mon, 23 May 2022 23:54:49 +0400 Subject: [PATCH] Rename djangosaml2 -> djangosaml2_v0181 for upgrade reasons --- .../__init__.py | 0 .../acs_failures.py | 2 +- .../backends.py | 6 ++-- {djangosaml2 => djangosaml2_v0181}/cache.py | 0 {djangosaml2 => djangosaml2_v0181}/conf.py | 4 +-- .../exceptions.py | 0 {djangosaml2 => djangosaml2_v0181}/models.py | 0 .../overrides.py | 2 +- {djangosaml2 => djangosaml2_v0181}/signals.py | 0 .../templates/djangosaml2/auth_error.html | 0 .../djangosaml2/echo_attributes.html | 0 .../example_post_binding_form.html | 0 .../templates/djangosaml2/login_error.html | 0 .../templates/djangosaml2/logout_error.html | 0 .../templates/djangosaml2/wayf.html | 0 .../templatetags/__init__.py | 0 .../templatetags/idplist.py | 4 +-- .../tests/__init__.py | 20 ++++++------ .../tests/attribute-maps/saml_uri.py | 0 .../tests/auth_response.py | 2 +- .../tests/conf.py | 0 .../tests/idpcert.csr | 0 .../tests/idpcert.key | 0 .../tests/idpcert.pem | 0 .../tests/mycert.csr | 0 .../tests/mycert.key | 0 .../tests/mycert.pem | 0 .../tests/remote_metadata.xml | 0 .../tests/remote_metadata_one_idp.xml | 0 .../tests/remote_metadata_three_idps.xml | 0 .../tests/sp_metadata.xml | 0 .../tests/spcert.csr | 0 .../tests/spcert.key | 0 .../tests/spcert.pem | 0 .../tests/urls.py | 2 +- {djangosaml2 => djangosaml2_v0181}/urls.py | 2 +- {djangosaml2 => djangosaml2_v0181}/utils.py | 4 +-- {djangosaml2 => djangosaml2_v0181}/views.py | 32 +++++++++---------- 38 files changed, 40 insertions(+), 40 deletions(-) rename {djangosaml2 => djangosaml2_v0181}/__init__.py (100%) rename {djangosaml2 => djangosaml2_v0181}/acs_failures.py (90%) rename {djangosaml2 => djangosaml2_v0181}/backends.py (98%) rename {djangosaml2 => djangosaml2_v0181}/cache.py (100%) rename {djangosaml2 => djangosaml2_v0181}/conf.py (94%) rename {djangosaml2 => djangosaml2_v0181}/exceptions.py (100%) rename {djangosaml2 => djangosaml2_v0181}/models.py (100%) rename {djangosaml2 => djangosaml2_v0181}/overrides.py (95%) rename {djangosaml2 => djangosaml2_v0181}/signals.py (100%) rename {djangosaml2 => djangosaml2_v0181}/templates/djangosaml2/auth_error.html (100%) rename {djangosaml2 => djangosaml2_v0181}/templates/djangosaml2/echo_attributes.html (100%) rename {djangosaml2 => djangosaml2_v0181}/templates/djangosaml2/example_post_binding_form.html (100%) rename {djangosaml2 => djangosaml2_v0181}/templates/djangosaml2/login_error.html (100%) rename {djangosaml2 => djangosaml2_v0181}/templates/djangosaml2/logout_error.html (100%) rename {djangosaml2 => djangosaml2_v0181}/templates/djangosaml2/wayf.html (100%) rename {djangosaml2 => djangosaml2_v0181}/templatetags/__init__.py (100%) rename {djangosaml2 => djangosaml2_v0181}/templatetags/idplist.py (92%) rename {djangosaml2 => djangosaml2_v0181}/tests/__init__.py (98%) rename {djangosaml2 => djangosaml2_v0181}/tests/attribute-maps/saml_uri.py (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/auth_response.py (98%) rename {djangosaml2 => djangosaml2_v0181}/tests/conf.py (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/idpcert.csr (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/idpcert.key (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/idpcert.pem (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/mycert.csr (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/mycert.key (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/mycert.pem (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/remote_metadata.xml (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/remote_metadata_one_idp.xml (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/remote_metadata_three_idps.xml (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/sp_metadata.xml (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/spcert.csr (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/spcert.key (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/spcert.pem (100%) rename {djangosaml2 => djangosaml2_v0181}/tests/urls.py (97%) rename {djangosaml2 => djangosaml2_v0181}/urls.py (96%) rename {djangosaml2 => djangosaml2_v0181}/utils.py (97%) rename {djangosaml2 => djangosaml2_v0181}/views.py (95%) diff --git a/djangosaml2/__init__.py b/djangosaml2_v0181/__init__.py similarity index 100% rename from djangosaml2/__init__.py rename to djangosaml2_v0181/__init__.py diff --git a/djangosaml2/acs_failures.py b/djangosaml2_v0181/acs_failures.py similarity index 90% rename from djangosaml2/acs_failures.py rename to djangosaml2_v0181/acs_failures.py index 76dfe9c8..e92ab2a3 100644 --- a/djangosaml2/acs_failures.py +++ b/djangosaml2_v0181/acs_failures.py @@ -11,7 +11,7 @@ def template_failure(request, status=403, **kwargs): """ Renders a SAML-specific template with general authentication error description. """ - return render(request, 'djangosaml2/login_error.html', status=status) + return render(request, 'djangosaml2_v0181/login_error.html', status=status) def exception_failure(request, exc_class=PermissionDenied, **kwargs): diff --git a/djangosaml2/backends.py b/djangosaml2_v0181/backends.py similarity index 98% rename from djangosaml2/backends.py rename to djangosaml2_v0181/backends.py index 22edc6ce..e356ad52 100644 --- a/djangosaml2/backends.py +++ b/djangosaml2_v0181/backends.py @@ -22,10 +22,10 @@ MultipleObjectsReturned, ImproperlyConfigured, ) -from djangosaml2.signals import pre_user_save +from djangosaml2_v0181.signals import pre_user_save -logger = logging.getLogger('djangosaml2') +logger = logging.getLogger('djangosaml2_v0181') def get_model(model_path): @@ -49,7 +49,7 @@ def get_model(model_path): def get_saml_user_model(): try: - # djangosaml2 custom user model + # djangosaml2_v0181 custom user model return get_model(settings.SAML_USER_MODEL) except AttributeError: try: diff --git a/djangosaml2/cache.py b/djangosaml2_v0181/cache.py similarity index 100% rename from djangosaml2/cache.py rename to djangosaml2_v0181/cache.py diff --git a/djangosaml2/conf.py b/djangosaml2_v0181/conf.py similarity index 94% rename from djangosaml2/conf.py rename to djangosaml2_v0181/conf.py index 9291b6f1..61309220 100644 --- a/djangosaml2/conf.py +++ b/djangosaml2_v0181/conf.py @@ -21,7 +21,7 @@ from saml2.config import SPConfig -from djangosaml2.utils import get_custom_setting +from djangosaml2_v0181.utils import get_custom_setting def get_config_loader(path, request=None): @@ -64,7 +64,7 @@ def config_settings_loader(request=None): def get_config(config_loader_path=None, request=None): config_loader_path = config_loader_path or get_custom_setting( - 'SAML_CONFIG_LOADER', 'djangosaml2.conf.config_settings_loader') + 'SAML_CONFIG_LOADER', 'djangosaml2_v0181.conf.config_settings_loader') config_loader = get_config_loader(config_loader_path) return config_loader(request) diff --git a/djangosaml2/exceptions.py b/djangosaml2_v0181/exceptions.py similarity index 100% rename from djangosaml2/exceptions.py rename to djangosaml2_v0181/exceptions.py diff --git a/djangosaml2/models.py b/djangosaml2_v0181/models.py similarity index 100% rename from djangosaml2/models.py rename to djangosaml2_v0181/models.py diff --git a/djangosaml2/overrides.py b/djangosaml2_v0181/overrides.py similarity index 95% rename from djangosaml2/overrides.py rename to djangosaml2_v0181/overrides.py index 96849bec..9618d689 100644 --- a/djangosaml2/overrides.py +++ b/djangosaml2_v0181/overrides.py @@ -3,7 +3,7 @@ import saml2.client from django.conf import settings -logger = logging.getLogger('djangosaml2') +logger = logging.getLogger('djangosaml2_v0181') class Saml2Client(saml2.client.Saml2Client): diff --git a/djangosaml2/signals.py b/djangosaml2_v0181/signals.py similarity index 100% rename from djangosaml2/signals.py rename to djangosaml2_v0181/signals.py diff --git a/djangosaml2/templates/djangosaml2/auth_error.html b/djangosaml2_v0181/templates/djangosaml2/auth_error.html similarity index 100% rename from djangosaml2/templates/djangosaml2/auth_error.html rename to djangosaml2_v0181/templates/djangosaml2/auth_error.html diff --git a/djangosaml2/templates/djangosaml2/echo_attributes.html b/djangosaml2_v0181/templates/djangosaml2/echo_attributes.html similarity index 100% rename from djangosaml2/templates/djangosaml2/echo_attributes.html rename to djangosaml2_v0181/templates/djangosaml2/echo_attributes.html diff --git a/djangosaml2/templates/djangosaml2/example_post_binding_form.html b/djangosaml2_v0181/templates/djangosaml2/example_post_binding_form.html similarity index 100% rename from djangosaml2/templates/djangosaml2/example_post_binding_form.html rename to djangosaml2_v0181/templates/djangosaml2/example_post_binding_form.html diff --git a/djangosaml2/templates/djangosaml2/login_error.html b/djangosaml2_v0181/templates/djangosaml2/login_error.html similarity index 100% rename from djangosaml2/templates/djangosaml2/login_error.html rename to djangosaml2_v0181/templates/djangosaml2/login_error.html diff --git a/djangosaml2/templates/djangosaml2/logout_error.html b/djangosaml2_v0181/templates/djangosaml2/logout_error.html similarity index 100% rename from djangosaml2/templates/djangosaml2/logout_error.html rename to djangosaml2_v0181/templates/djangosaml2/logout_error.html diff --git a/djangosaml2/templates/djangosaml2/wayf.html b/djangosaml2_v0181/templates/djangosaml2/wayf.html similarity index 100% rename from djangosaml2/templates/djangosaml2/wayf.html rename to djangosaml2_v0181/templates/djangosaml2/wayf.html diff --git a/djangosaml2/templatetags/__init__.py b/djangosaml2_v0181/templatetags/__init__.py similarity index 100% rename from djangosaml2/templatetags/__init__.py rename to djangosaml2_v0181/templatetags/__init__.py diff --git a/djangosaml2/templatetags/idplist.py b/djangosaml2_v0181/templatetags/idplist.py similarity index 92% rename from djangosaml2/templatetags/idplist.py rename to djangosaml2_v0181/templatetags/idplist.py index cf4eccad..9b894b51 100644 --- a/djangosaml2/templatetags/idplist.py +++ b/djangosaml2_v0181/templatetags/idplist.py @@ -14,8 +14,8 @@ from django import template -from djangosaml2.conf import config_settings_loader -from djangosaml2.utils import available_idps +from djangosaml2_v0181.conf import config_settings_loader +from djangosaml2_v0181.utils import available_idps register = template.Library() diff --git a/djangosaml2/tests/__init__.py b/djangosaml2_v0181/tests/__init__.py similarity index 98% rename from djangosaml2/tests/__init__.py rename to djangosaml2_v0181/tests/__init__.py index 50789320..37d48d65 100644 --- a/djangosaml2/tests/__init__.py +++ b/djangosaml2_v0181/tests/__init__.py @@ -43,13 +43,13 @@ from saml2.config import SPConfig from saml2.s_utils import decode_base64_and_inflate, deflate_and_base64_encode -from djangosaml2 import views -from djangosaml2.cache import OutstandingQueriesCache -from djangosaml2.conf import get_config -from djangosaml2.tests import conf -from djangosaml2.tests.auth_response import auth_response -from djangosaml2.signals import post_authenticated -from djangosaml2.views import finish_logout +from djangosaml2_v0181 import views +from djangosaml2_v0181.cache import OutstandingQueriesCache +from djangosaml2_v0181.conf import get_config +from djangosaml2_v0181.tests import conf +from djangosaml2_v0181.tests.auth_response import auth_response +from djangosaml2_v0181.signals import post_authenticated +from djangosaml2_v0181.views import finish_logout User = get_user_model() @@ -58,7 +58,7 @@ class SAML2Tests(TestCase): - urls = 'djangosaml2.tests.urls' + urls = 'djangosaml2_v0181.tests.urls' def setUp(self): if hasattr(settings, 'SAML_ATTRIBUTE_MAPPING'): @@ -545,14 +545,14 @@ def test_config_loader_with_real_conf(request): class ConfTests(TestCase): def test_custom_conf_loader(self): - config_loader_path = 'djangosaml2.tests.test_config_loader' + config_loader_path = 'djangosaml2_v0181.tests.test_config_loader' request = RequestFactory().get('/bar/foo') conf = get_config(config_loader_path, request) self.assertEqual(conf.entityid, 'testentity') def test_custom_conf_loader_from_view(self): - config_loader_path = 'djangosaml2.tests.test_config_loader_with_real_conf' + config_loader_path = 'djangosaml2_v0181.tests.test_config_loader_with_real_conf' request = RequestFactory().get('/login/') request.user = AnonymousUser() middleware = SessionMiddleware() diff --git a/djangosaml2/tests/attribute-maps/saml_uri.py b/djangosaml2_v0181/tests/attribute-maps/saml_uri.py similarity index 100% rename from djangosaml2/tests/attribute-maps/saml_uri.py rename to djangosaml2_v0181/tests/attribute-maps/saml_uri.py diff --git a/djangosaml2/tests/auth_response.py b/djangosaml2_v0181/tests/auth_response.py similarity index 98% rename from djangosaml2/tests/auth_response.py rename to djangosaml2_v0181/tests/auth_response.py index 52b4bd4b..d9f9def6 100644 --- a/djangosaml2/tests/auth_response.py +++ b/djangosaml2_v0181/tests/auth_response.py @@ -26,7 +26,7 @@ def auth_response(session_id, Params: session_id: The session ID to generate the reponse for. Login set an - outstanding session ID, i.e. djangosaml2 waits for a response for + outstanding session ID, i.e. djangosaml2_v0181 waits for a response for that session. uid: Unique identifier for a User (will be present as an attribute in the answer). Ignored when attribute_statements is not ``None``. diff --git a/djangosaml2/tests/conf.py b/djangosaml2_v0181/tests/conf.py similarity index 100% rename from djangosaml2/tests/conf.py rename to djangosaml2_v0181/tests/conf.py diff --git a/djangosaml2/tests/idpcert.csr b/djangosaml2_v0181/tests/idpcert.csr similarity index 100% rename from djangosaml2/tests/idpcert.csr rename to djangosaml2_v0181/tests/idpcert.csr diff --git a/djangosaml2/tests/idpcert.key b/djangosaml2_v0181/tests/idpcert.key similarity index 100% rename from djangosaml2/tests/idpcert.key rename to djangosaml2_v0181/tests/idpcert.key diff --git a/djangosaml2/tests/idpcert.pem b/djangosaml2_v0181/tests/idpcert.pem similarity index 100% rename from djangosaml2/tests/idpcert.pem rename to djangosaml2_v0181/tests/idpcert.pem diff --git a/djangosaml2/tests/mycert.csr b/djangosaml2_v0181/tests/mycert.csr similarity index 100% rename from djangosaml2/tests/mycert.csr rename to djangosaml2_v0181/tests/mycert.csr diff --git a/djangosaml2/tests/mycert.key b/djangosaml2_v0181/tests/mycert.key similarity index 100% rename from djangosaml2/tests/mycert.key rename to djangosaml2_v0181/tests/mycert.key diff --git a/djangosaml2/tests/mycert.pem b/djangosaml2_v0181/tests/mycert.pem similarity index 100% rename from djangosaml2/tests/mycert.pem rename to djangosaml2_v0181/tests/mycert.pem diff --git a/djangosaml2/tests/remote_metadata.xml b/djangosaml2_v0181/tests/remote_metadata.xml similarity index 100% rename from djangosaml2/tests/remote_metadata.xml rename to djangosaml2_v0181/tests/remote_metadata.xml diff --git a/djangosaml2/tests/remote_metadata_one_idp.xml b/djangosaml2_v0181/tests/remote_metadata_one_idp.xml similarity index 100% rename from djangosaml2/tests/remote_metadata_one_idp.xml rename to djangosaml2_v0181/tests/remote_metadata_one_idp.xml diff --git a/djangosaml2/tests/remote_metadata_three_idps.xml b/djangosaml2_v0181/tests/remote_metadata_three_idps.xml similarity index 100% rename from djangosaml2/tests/remote_metadata_three_idps.xml rename to djangosaml2_v0181/tests/remote_metadata_three_idps.xml diff --git a/djangosaml2/tests/sp_metadata.xml b/djangosaml2_v0181/tests/sp_metadata.xml similarity index 100% rename from djangosaml2/tests/sp_metadata.xml rename to djangosaml2_v0181/tests/sp_metadata.xml diff --git a/djangosaml2/tests/spcert.csr b/djangosaml2_v0181/tests/spcert.csr similarity index 100% rename from djangosaml2/tests/spcert.csr rename to djangosaml2_v0181/tests/spcert.csr diff --git a/djangosaml2/tests/spcert.key b/djangosaml2_v0181/tests/spcert.key similarity index 100% rename from djangosaml2/tests/spcert.key rename to djangosaml2_v0181/tests/spcert.key diff --git a/djangosaml2/tests/spcert.pem b/djangosaml2_v0181/tests/spcert.pem similarity index 100% rename from djangosaml2/tests/spcert.pem rename to djangosaml2_v0181/tests/spcert.pem diff --git a/djangosaml2/tests/urls.py b/djangosaml2_v0181/tests/urls.py similarity index 97% rename from djangosaml2/tests/urls.py rename to djangosaml2_v0181/tests/urls.py index 3098ce8c..4a13b569 100644 --- a/djangosaml2/tests/urls.py +++ b/djangosaml2_v0181/tests/urls.py @@ -15,7 +15,7 @@ from django.conf.urls import include, url from django.contrib import admin -from djangosaml2 import views +from djangosaml2_v0181 import views urlpatterns = [ diff --git a/djangosaml2/urls.py b/djangosaml2_v0181/urls.py similarity index 96% rename from djangosaml2/urls.py rename to djangosaml2_v0181/urls.py index bd87d774..57c73666 100644 --- a/djangosaml2/urls.py +++ b/djangosaml2_v0181/urls.py @@ -14,7 +14,7 @@ # limitations under the License. from django.conf.urls import url -from djangosaml2 import views +from djangosaml2_v0181 import views urlpatterns = [ diff --git a/djangosaml2/utils.py b/djangosaml2_v0181/utils.py similarity index 97% rename from djangosaml2/utils.py rename to djangosaml2_v0181/utils.py index 75f40ee7..f6d6e172 100644 --- a/djangosaml2/utils.py +++ b/djangosaml2_v0181/utils.py @@ -43,7 +43,7 @@ def get_idp_sso_supported_bindings(idp_entity_id=None, config=None): This is not clear in the pysaml2 code, so wrapping it in a util""" if config is None: # avoid circular import - from djangosaml2.conf import get_config + from djangosaml2_v0181.conf import get_config config = get_config() # load metadata store from config meta = getattr(config, 'metadata', {}) @@ -78,7 +78,7 @@ def fail_acs_response(request, *args, **kwargs): but this can be simply changed so that PermissionDenied exception is raised instead. """ failure_function = import_string(get_custom_setting('SAML_ACS_FAILURE_RESPONSE_FUNCTION', - 'djangosaml2.acs_failures.template_failure')) + 'djangosaml2_v0181.acs_failures.template_failure')) return failure_function(request, *args, **kwargs) diff --git a/djangosaml2/views.py b/djangosaml2_v0181/views.py similarity index 95% rename from djangosaml2/views.py rename to djangosaml2_v0181/views.py index e1c9e078..d62ebf02 100644 --- a/djangosaml2/views.py +++ b/djangosaml2_v0181/views.py @@ -55,19 +55,19 @@ from saml2.validate import ResponseLifetimeExceed, ToEarly from saml2.xmldsig import SIG_RSA_SHA1, SIG_RSA_SHA256 # support for SHA1 is required by spec -from djangosaml2.cache import IdentityCache, OutstandingQueriesCache -from djangosaml2.cache import StateCache -from djangosaml2.exceptions import IdPConfigurationMissing -from djangosaml2.conf import get_config -from djangosaml2.overrides import Saml2Client -from djangosaml2.signals import post_authenticated -from djangosaml2.utils import ( +from djangosaml2_v0181.cache import IdentityCache, OutstandingQueriesCache +from djangosaml2_v0181.cache import StateCache +from djangosaml2_v0181.exceptions import IdPConfigurationMissing +from djangosaml2_v0181.conf import get_config +from djangosaml2_v0181.overrides import Saml2Client +from djangosaml2_v0181.signals import post_authenticated +from djangosaml2_v0181.utils import ( available_idps, fail_acs_response, get_custom_setting, get_idp_sso_supported_bindings, get_location, is_safe_url_compat, ) -logger = logging.getLogger('djangosaml2') +logger = logging.getLogger('djangosaml2_v0181') def _set_subject_id(session, subject_id): @@ -93,9 +93,9 @@ def callable_bool(value): def login(request, config_loader_path=None, - wayf_template='djangosaml2/wayf.html', - authorization_error_template='djangosaml2/auth_error.html', - post_binding_form_template='djangosaml2/post_binding_form.html'): + wayf_template='djangosaml2_v0181/wayf.html', + authorization_error_template='djangosaml2_v0181/auth_error.html', + post_binding_form_template='djangosaml2_v0181/post_binding_form.html'): """SAML Authorization Request initiator This view initiates the SAML2 Authorization handshake @@ -107,7 +107,7 @@ def login(request, binding is being used. You can customize this template to include custom branding and/or text explaining the automatic redirection process. Please see the example template in - templates/djangosaml2/example_post_binding_form.html + templates/djangosaml2_v0181/example_post_binding_form.html If set to None or nonexistent template, default form from the saml2 library will be rendered. """ @@ -273,7 +273,7 @@ def assertion_consumer_service(request, The IdP will send its response to this view, which will process it with pysaml2 help and log the user in using the custom Authorization backend - djangosaml2.backends.Saml2Backend that should be + djangosaml2_v0181.backends.Saml2Backend that should be enabled in the settings.py """ attribute_mapping = attribute_mapping or get_custom_setting('SAML_ATTRIBUTE_MAPPING', {'uid': ('username', )}) @@ -365,7 +365,7 @@ def assertion_consumer_service(request, @login_required def echo_attributes(request, config_loader_path=None, - template='djangosaml2/echo_attributes.html'): + template='djangosaml2_v0181/echo_attributes.html'): """Example view that echo the SAML attributes of an user""" state = StateCache(request.session) conf = get_config(config_loader_path, request) @@ -442,7 +442,7 @@ def logout_service_post(request, *args, **kwargs): def do_logout_service(request, data, binding, config_loader_path=None, next_page=None, - logout_error_template='djangosaml2/logout_error.html'): + logout_error_template='djangosaml2_v0181/logout_error.html'): """SAML Logout Response endpoint The IdP will send the logout response to this view, @@ -507,7 +507,7 @@ def finish_logout(request, response, next_page=None): return django_logout(request, next_page=next_page) else: logger.error('Unknown error during the logout') - return render(request, "djangosaml2/logout_error.html", {}) + return render(request, "djangosaml2_v0181/logout_error.html", {}) def metadata(request, config_loader_path=None, valid_for=None):