Skip to content

Rename djangosaml2 -> djangosaml2_v0181 for upgrade reasons #1

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

Open
wants to merge 1 commit into
base: v0181_policystat
Choose a base branch
from
Open
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
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions djangosaml2/backends.py → djangosaml2_v0181/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions djangosaml2/conf.py → djangosaml2_v0181/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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'):
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion djangosaml2/urls.py → djangosaml2_v0181/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

from django.conf.urls import url
from djangosaml2 import views
from djangosaml2_v0181 import views


urlpatterns = [
Expand Down
4 changes: 2 additions & 2 deletions djangosaml2/utils.py → djangosaml2_v0181/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', {})
Expand Down Expand Up @@ -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)


Expand Down
32 changes: 16 additions & 16 deletions djangosaml2/views.py → djangosaml2_v0181/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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.
"""
Expand Down Expand Up @@ -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', )})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down