python3: encoding variations in saml base code

This commit is contained in:
Paul Marillonnet 2020-02-06 18:25:30 +01:00
parent 915d9e33ea
commit c69824f54f
3 changed files with 9 additions and 4 deletions

View File

@ -26,6 +26,7 @@ from django.conf import settings
from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.shortcuts import render
from django.utils import six
from django.utils.encoding import force_text
from django.utils.six.moves.urllib import parse as urlparse
from django.core.exceptions import ValidationError
@ -387,8 +388,9 @@ def load_provider(request, entity_id, server=None, sp_or_idp='sp',
if not service_provider.enabled:
return False
if server:
server.addProviderFromBuffer(lasso.PROVIDER_ROLE_SP,
liberty_provider.metadata.encode('utf8'))
server.addProviderFromBuffer(
lasso.PROVIDER_ROLE_SP,
force_text(liberty_provider.metadata.encode('utf8')))
policy = get_sp_options_policy(liberty_provider)
if policy:
encryption_mode = 0

View File

@ -26,6 +26,7 @@ from django.db.models import Q
from django.conf import settings
from django.core.exceptions import ValidationError
from django.utils import six
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
@ -385,7 +386,7 @@ class LibertyProvider(Service):
def clean(self):
super(LibertyProvider, self).clean()
p = lasso.Provider.newFromBuffer(lasso.PROVIDER_ROLE_ANY, self.metadata.encode('utf8'))
p = lasso.Provider.newFromBuffer(lasso.PROVIDER_ROLE_ANY, force_text(self.metadata.encode('utf8')))
if p is None:
raise ValidationError(_('Invalid metadata file'))
self.entity_id = p.providerId

View File

@ -27,6 +27,7 @@ import datetime
import time
from django.utils import six
from django.utils.encoding import force_text
def filter_attribute_private_key(message):
@ -277,7 +278,8 @@ class Saml2Metadata(object):
self.tb.end(self.EXTENSIONS)
def __str__(self):
return '<?xml version="1.0"?>\n' + etree.tostring(self.root_element())
return '<?xml version="1.0"?>\n' + force_text(
etree.tostring(self.root_element()))
def iso8601_to_datetime(date_string):