From e04459825c1f317cd71afd82ba2640cbcc7576dc Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 7 May 2019 14:05:39 +0200 Subject: [PATCH] add copyright headers (#32866) --- setup.py | 16 +++++++++++++ src/authentic2_auth_fc/__init__.py | 16 +++++++++++++ src/authentic2_auth_fc/api_views.py | 16 +++++++++++++ src/authentic2_auth_fc/app_settings.py | 23 +++++++++++++++---- src/authentic2_auth_fc/authenticators.py | 16 +++++++++++++ src/authentic2_auth_fc/backends.py | 16 +++++++++++++ .../locale/fr/LC_MESSAGES/django.po | 19 +++++++++++---- src/authentic2_auth_fc/models.py | 21 ++++++++++++++--- src/authentic2_auth_fc/urls.py | 22 +++++++++++++++--- src/authentic2_auth_fc/utils.py | 16 +++++++++++++ src/authentic2_auth_fc/views.py | 20 +++++++++++++--- tests/conftest.py | 16 +++++++++++++ 12 files changed, 200 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 530224d..9ff7f3b 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,20 @@ #!/usr/bin/python +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + import sys import os import subprocess diff --git a/src/authentic2_auth_fc/__init__.py b/src/authentic2_auth_fc/__init__.py index 9d88e4c..cd93fc3 100644 --- a/src/authentic2_auth_fc/__init__.py +++ b/src/authentic2_auth_fc/__init__.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + from . import utils from . import app_settings diff --git a/src/authentic2_auth_fc/api_views.py b/src/authentic2_auth_fc/api_views.py index f7e0e04..b0ab9b4 100644 --- a/src/authentic2_auth_fc/api_views.py +++ b/src/authentic2_auth_fc/api_views.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + from django.shortcuts import get_object_or_404 from django.contrib.auth import get_user_model diff --git a/src/authentic2_auth_fc/app_settings.py b/src/authentic2_auth_fc/app_settings.py index b8864a3..54c55f8 100644 --- a/src/authentic2_auth_fc/app_settings.py +++ b/src/authentic2_auth_fc/app_settings.py @@ -1,3 +1,21 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + +import sys + class AppSettings(object): '''Thanks django-allauth''' @@ -10,7 +28,7 @@ class AppSettings(object): from django.conf import settings from django.core.exceptions import ImproperlyConfigured - v = getattr(settings, self.prefix + name, dflt) + v = getattr(settings, self.prefix + name, dflt) if v is self.__SENTINEL: raise ImproperlyConfigured('Missing setting %r' % (self.prefix + name)) return v @@ -118,9 +136,6 @@ class AppSettings(object): def popup(self): return self._setting('POPUP', False) - -import sys - app_settings = AppSettings('A2_FC_') app_settings.__name__ = __name__ sys.modules[__name__] = app_settings diff --git a/src/authentic2_auth_fc/authenticators.py b/src/authentic2_auth_fc/authenticators.py index 0869870..01097d3 100644 --- a/src/authentic2_auth_fc/authenticators.py +++ b/src/authentic2_auth_fc/authenticators.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + from django.utils.translation import gettext_noop from django.template.loader import render_to_string from django.shortcuts import render diff --git a/src/authentic2_auth_fc/backends.py b/src/authentic2_auth_fc/backends.py index 0420c2b..bf142be 100644 --- a/src/authentic2_auth_fc/backends.py +++ b/src/authentic2_auth_fc/backends.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + import json import logging diff --git a/src/authentic2_auth_fc/locale/fr/LC_MESSAGES/django.po b/src/authentic2_auth_fc/locale/fr/LC_MESSAGES/django.po index b43ca55..fbaf8a5 100644 --- a/src/authentic2_auth_fc/locale/fr/LC_MESSAGES/django.po +++ b/src/authentic2_auth_fc/locale/fr/LC_MESSAGES/django.po @@ -1,7 +1,18 @@ -# Authentic2 Mon.service-public.fr plugin french translations -# Copyright (C) 2014 Entr'ouvert -# This file is distributed under the same license as the authentic2-auth-fc package. -# Benjamin Dauvergne . # msgid "" msgstr "" diff --git a/src/authentic2_auth_fc/models.py b/src/authentic2_auth_fc/models.py index d015968..533e9f7 100644 --- a/src/authentic2_auth_fc/models.py +++ b/src/authentic2_auth_fc/models.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + import base64 import json import hmac @@ -24,7 +40,7 @@ def base64url_decode(input): def parse_id_token(id_token, client_id=None, client_secret=None): try: splitted = str(id_token).split('.') - except: + except Exception: return None, 'invalid id_token' if len(splitted) != 3: return None, 'invalid id_token' @@ -54,7 +70,7 @@ def parse_id_token(id_token, client_id=None, client_secret=None): return False try: parsed_issuer = urlparse.urlparse(payload['iss']) - except: + except Exception: return False return parsed_issuer.scheme == parsed.scheme and parsed_issuer.netloc == parsed.netloc @@ -86,7 +102,6 @@ class FcAccount(models.Model): def __unicode__(self): user_info = self.get_user_info() - id_token = self.id_token display_name = [] if 'given_name' in user_info: display_name.append(user_info['given_name']) diff --git a/src/authentic2_auth_fc/urls.py b/src/authentic2_auth_fc/urls.py index 3e28c14..4b421f2 100644 --- a/src/authentic2_auth_fc/urls.py +++ b/src/authentic2_auth_fc/urls.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + from django.conf.urls import url, include from . import views @@ -8,7 +24,7 @@ fcpatterns = [ ] urlpatterns = [ - url(r'^fc/', include(fcpatterns)), - url(r'^accounts/fc/register/$', views.registration, name='fc-registration'), - url(r'^accounts/fc/unlink/$', views.unlink, name='fc-unlink'), + url(r'^fc/', include(fcpatterns)), + url(r'^accounts/fc/register/$', views.registration, name='fc-registration'), + url(r'^accounts/fc/unlink/$', views.unlink, name='fc-unlink'), ] diff --git a/src/authentic2_auth_fc/utils.py b/src/authentic2_auth_fc/utils.py index 996e935..f547f4d 100644 --- a/src/authentic2_auth_fc/utils.py +++ b/src/authentic2_auth_fc/utils.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + import urllib import logging import os diff --git a/src/authentic2_auth_fc/views.py b/src/authentic2_auth_fc/views.py index e6598fc..3ad3cf3 100644 --- a/src/authentic2_auth_fc/views.py +++ b/src/authentic2_auth_fc/views.py @@ -1,8 +1,23 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + import uuid import logging import json import urlparse -import urllib import requests from requests_oauthlib import OAuth2Session @@ -10,7 +25,6 @@ from requests_oauthlib import OAuth2Session import django from django.views.generic import View, FormView -from django.views.generic.detail import SingleObjectMixin from django.http import HttpResponseRedirect, Http404 from django.contrib.auth import authenticate, REDIRECT_FIELD_NAME, get_user_model from django.contrib import messages @@ -473,7 +487,7 @@ class RegistrationView(PopupViewMixin, LoggerMixin, View): if self.get_in_popup(): params['popup'] = '' redirect_to = a2_utils.make_url('fc-login-or-link', params=params) - if not 'email' in data: + if 'email' not in data: data[REDIRECT_FIELD_NAME] = redirect_to messages.warning(request, _("FranceConnect didn't provide your email address, please do.")) diff --git a/tests/conftest.py b/tests/conftest.py index feccfef..f277abb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,19 @@ +# authentic2-auth-fc - authentic2 authentication for FranceConnect +# Copyright (C) 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 . + import json import pytest import django_webtest