Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Update django to django 3.1, remove redundant backport code
Browse files Browse the repository at this point in the history
- Remove six imports
- Remove deprecation warnings
  • Loading branch information
AvuGradConnection committed Mar 24, 2021
1 parent 71fa738 commit 1adab75
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 45 deletions.
3 changes: 2 additions & 1 deletion idptest/scripts/c14n.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals
from io import StringIO


from django.utils.six import StringIO
from lxml import etree


Expand Down
10 changes: 5 additions & 5 deletions idptest/tests/test_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import string
import unittest

from django.utils.six import text_type

from saml2idp import xml_render
from saml2idp import xml_signing
from saml2idp import saml2idp_metadata as smd
Expand Down Expand Up @@ -149,10 +149,10 @@ def test_loading_private_key():
filename = os.path.join(os.getcwd(), 'keys/sample/sample-private-key.pem')
config = {smd.PRIVATE_KEY_FILENAME: filename}

assert type(filename) is text_type
assert type(filename) is str
xml_signing.load_private_key(config)

filename = text_type(filename)
filename = str(filename)
config = {smd.PRIVATE_KEY_FILENAME: filename}
xml_signing.load_private_key(config)

Expand All @@ -172,10 +172,10 @@ def test_loading_certificate_from_file():
filename = os.path.join(os.getcwd(), 'keys/sample/sample-certificate.pem')
config = {smd.CERTIFICATE_FILENAME: filename}

assert type(filename) is text_type
assert type(filename) is str
xml_signing.load_certificate(config)

filename = text_type(filename)
filename = str(filename)
config = {smd.CERTIFICATE_FILENAME: filename}

certificate = xml_signing.load_certificate(config)
Expand Down
10 changes: 5 additions & 5 deletions saml2idp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from bs4 import BeautifulSoup
from django.core.exceptions import ImproperlyConfigured

from . import codex
from . import exceptions
from . import saml2idp_metadata
from . import xml_render
from .logging import get_saml_logger
from saml2idp import codex
from saml2idp import exceptions
from saml2idp import saml2idp_metadata
from saml2idp import xml_render
from saml2idp.logging import get_saml_logger

MINUTES = 60
HOURS = 60 * MINUTES
Expand Down
6 changes: 3 additions & 3 deletions saml2idp/demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from . import base
from . import exceptions
from . import xml_render
from saml2idp import base
from saml2idp import exceptions
from saml2idp import xml_render

class Processor(base.Processor):
"""
Expand Down
10 changes: 6 additions & 4 deletions saml2idp/google_apps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from . import base
from . import codex
from . import exceptions
from . import xml_render

from saml2idp import base
from saml2idp import codex
from saml2idp import exceptions
from saml2idp import xml_render


class Processor(base.Processor):
"""
Expand Down
6 changes: 5 additions & 1 deletion saml2idp/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"""
from __future__ import absolute_import, division, print_function, unicode_literals


# Django imports
from django.core.exceptions import ImproperlyConfigured


# Local imports
from .saml2idp_metadata import SAML2IDP_CONFIG, SAML2IDP_REMOTES
from saml2idp.saml2idp_metadata import SAML2IDP_CONFIG, SAML2IDP_REMOTES


def get_config_for_acs(acs_url):
"""
Expand Down
6 changes: 3 additions & 3 deletions saml2idp/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

from django.core.exceptions import ImproperlyConfigured

from . import exceptions
from . import saml2idp_metadata
from .logging import get_saml_logger
from saml2idp import exceptions
from saml2idp import saml2idp_metadata
from saml2idp.logging import get_saml_logger

logger = get_saml_logger()

Expand Down
8 changes: 5 additions & 3 deletions saml2idp/salesforce.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from . import base
from . import exceptions
from . import xml_render

from saml2idp import base
from saml2idp import exceptions
from saml2idp import xml_render


class Processor(base.Processor):
"""
Expand Down
2 changes: 2 additions & 0 deletions saml2idp/saml2idp_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"""
from __future__ import absolute_import, division, print_function, unicode_literals


from django.conf import settings
from django.core.exceptions import ImproperlyConfigured


CERTIFICATE_DATA = 'certificate_data'
CERTIFICATE_FILENAME = 'certificate_file'
PRIVATE_KEY_DATA = 'private_key_data'
Expand Down
7 changes: 4 additions & 3 deletions saml2idp/shib.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from . import base
from . import xml_render
import zlib
import base64


from saml2idp import base
from saml2idp import xml_render


class Processor(base.Processor):
"""
Shib-specific Processor
Expand Down
5 changes: 3 additions & 2 deletions saml2idp/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from django.conf.urls import url
from .views import descriptor, login_begin, login_init, login_process, logout
from .metadata import get_deeplink_resources
from saml2idp.views import descriptor, login_begin, login_init, login_process, logout
from saml2idp.metadata import get_deeplink_resources


def deeplink_url_patterns(
url_base_pattern=r'^init/%s/$',
Expand Down
16 changes: 9 additions & 7 deletions saml2idp/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

import os


from django.contrib import auth
from django.core.validators import URLValidator
from django.contrib.auth.decorators import login_required
Expand All @@ -16,12 +16,14 @@
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.views.decorators.csrf import csrf_exempt

from . import saml2idp_metadata
from . import exceptions
from . import metadata
from . import registry
from . import xml_signing
from .logging import get_saml_logger

from saml2idp import saml2idp_metadata
from saml2idp import exceptions
from saml2idp import metadata
from saml2idp import registry
from saml2idp import xml_signing
from saml2idp.logging import get_saml_logger


logger = get_saml_logger()

Expand Down
8 changes: 5 additions & 3 deletions saml2idp/xml_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
"""
from __future__ import absolute_import, division, print_function, unicode_literals


import string

from .xml_signing import get_signature_xml
from .xml_templates import (ATTRIBUTE,

from saml2idp.xml_signing import get_signature_xml
from saml2idp.xml_templates import (ATTRIBUTE,
ATTRIBUTE_STATEMENT,
ASSERTION_GOOGLE_APPS,
ASSERTION_SALESFORCE,
RESPONSE,
SUBJECT)

from .logging import get_saml_logger
from saml2idp.logging import get_saml_logger

logger = get_saml_logger()

Expand Down
10 changes: 5 additions & 5 deletions saml2idp/xml_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

import OpenSSL.crypto

from . import saml2idp_metadata as smd
from .codex import nice64
from .xml_templates import SIGNED_INFO, SIGNATURE
from .logging import get_saml_logger
from saml2idp import saml2idp_metadata as smd
from saml2idp.codex import nice64
from saml2idp.xml_templates import SIGNED_INFO, SIGNATURE
from saml2idp.logging import get_saml_logger

logger = get_saml_logger()

Expand Down Expand Up @@ -71,7 +71,7 @@ def get_signature_xml(subject, reference_uri):
logger.debug('Subject: %s' % (subject,))

# Hash the subject.
if isinstance(subject, six.text_type):
if isinstance(subject, str):
subject = subject.encode()

subject_hash = hashlib.sha1()
Expand Down
1 change: 1 addition & 0 deletions saml2idp/xml_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
from __future__ import absolute_import, division, print_function, unicode_literals


SIGNED_INFO = (
'<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">'
'<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod>'
Expand Down

0 comments on commit 1adab75

Please sign in to comment.