code style (#10196)
This commit is contained in:
parent
968aa07faf
commit
83a09d874e
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
|
@ -76,7 +91,7 @@ class DefaultAdapter(object):
|
||||||
self.logger.error(u'METADATA of %d-th idp has no EntityDescriptor root tag', i)
|
self.logger.error(u'METADATA of %d-th idp has no EntityDescriptor root tag', i)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not 'entityID' in doc.attrib:
|
if 'entityID' not in doc.attrib:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
u'METADATA of %d-th idp has no entityID attribute on its root tag', i)
|
u'METADATA of %d-th idp has no entityID attribute on its root tag', i)
|
||||||
continue
|
continue
|
||||||
|
@ -105,7 +120,7 @@ class DefaultAdapter(object):
|
||||||
except (AttributeError, KeyError, IndexError) as e:
|
except (AttributeError, KeyError, IndexError) as e:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
u'invalid reference in username template %r: %s', username_template, e)
|
u'invalid reference in username template %r: %s', username_template, e)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
self.logger.exception(u'unknown error when formatting username')
|
self.logger.exception(u'unknown error when formatting username')
|
||||||
else:
|
else:
|
||||||
return username
|
return username
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.contrib.sessions.backends.db import SessionStore
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from django.contrib.sessions.backends.db import SessionStore
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
|
|
||||||
from mellon import utils
|
from mellon import utils
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
import importlib
|
import importlib
|
||||||
|
@ -29,16 +44,16 @@ def create_metadata(request):
|
||||||
public_keys.append(public_key)
|
public_keys.append(public_key)
|
||||||
name_id_formats = app_settings.NAME_ID_FORMATS
|
name_id_formats = app_settings.NAME_ID_FORMATS
|
||||||
return render_to_string('mellon/metadata.xml', {
|
return render_to_string('mellon/metadata.xml', {
|
||||||
'entity_id': request.build_absolute_uri(entity_id),
|
'entity_id': request.build_absolute_uri(entity_id),
|
||||||
'login_url': request.build_absolute_uri(login_url),
|
'login_url': request.build_absolute_uri(login_url),
|
||||||
'logout_url': request.build_absolute_uri(logout_url),
|
'logout_url': request.build_absolute_uri(logout_url),
|
||||||
'public_keys': public_keys,
|
'public_keys': public_keys,
|
||||||
'name_id_formats': name_id_formats,
|
'name_id_formats': name_id_formats,
|
||||||
'default_assertion_consumer_binding': app_settings.DEFAULT_ASSERTION_CONSUMER_BINDING,
|
'default_assertion_consumer_binding': app_settings.DEFAULT_ASSERTION_CONSUMER_BINDING,
|
||||||
'organization': app_settings.ORGANIZATION,
|
'organization': app_settings.ORGANIZATION,
|
||||||
'contact_persons': app_settings.CONTACT_PERSONS,
|
'contact_persons': app_settings.CONTACT_PERSONS,
|
||||||
'discovery_endpoint_url': request.build_absolute_uri(reverse('mellon_login')),
|
'discovery_endpoint_url': request.build_absolute_uri(reverse('mellon_login')),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def create_server(request):
|
def create_server(request):
|
||||||
|
@ -130,7 +145,7 @@ def iso8601_to_datetime(date_string, default=None):
|
||||||
This function ignores the sub-second resolution'''
|
This function ignores the sub-second resolution'''
|
||||||
try:
|
try:
|
||||||
dt = isodate.parse_datetime(date_string)
|
dt = isodate.parse_datetime(date_string)
|
||||||
except:
|
except Exception:
|
||||||
return default
|
return default
|
||||||
if is_aware(dt):
|
if is_aware(dt):
|
||||||
if not settings.USE_TZ:
|
if not settings.USE_TZ:
|
||||||
|
@ -209,7 +224,7 @@ def create_logout(request):
|
||||||
|
|
||||||
|
|
||||||
def is_nonnull(s):
|
def is_nonnull(s):
|
||||||
return not '\x00' in s
|
return '\x00' not in s
|
||||||
|
|
||||||
|
|
||||||
def same_origin(url1, url2):
|
def same_origin(url1, url2):
|
||||||
|
@ -244,6 +259,7 @@ def get_status_codes_and_message(profile):
|
||||||
message = lasso_decode(status.statusMessage)
|
message = lasso_decode(status.statusMessage)
|
||||||
return status_codes, message
|
return status_codes, message
|
||||||
|
|
||||||
|
|
||||||
def login(request, user):
|
def login(request, user):
|
||||||
for adapter in get_adapters():
|
for adapter in get_adapters():
|
||||||
if hasattr(adapter, 'auth_login'):
|
if hasattr(adapter, 'auth_login'):
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import lasso
|
import lasso
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import pytest
|
import pytest
|
||||||
import django_webtest
|
import django_webtest
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import re
|
import re
|
||||||
import lasso
|
import lasso
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import base64
|
import base64
|
||||||
import zlib
|
import zlib
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import mock
|
import mock
|
||||||
import lasso
|
import lasso
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from httmock import all_requests, response
|
from httmock import all_requests, response
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# django-mellon - SAML2 authentication for Django
|
||||||
|
# Copyright (C) 2014-2019 Entr'ouvert
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue