From 6df561d8a12f73c8727c80500a4511a8b6afb680 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 21 Dec 2017 12:16:16 +0100 Subject: [PATCH 244/246] Prepare merge into authentic2 --- COPYING | 2 - MANIFEST.in | 7 -- README | 120 -------------------------- debian/changelog | 5 -- debian/compat | 1 - debian/control | 17 ---- debian/rules | 9 -- debian/source/format | 1 - getlasso.sh | 20 ----- setup.py | 130 ----------------------------- tests/settings.py | 11 --- tests/{test_api.py => test_api_auth_fc.py} | 0 tox.ini | 46 ---------- 13 files changed, 369 deletions(-) delete mode 100644 COPYING delete mode 100644 MANIFEST.in delete mode 100644 README delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100755 debian/rules delete mode 100644 debian/source/format delete mode 100755 getlasso.sh delete mode 100755 setup.py delete mode 100644 tests/settings.py rename tests/{test_api.py => test_api_auth_fc.py} (100%) delete mode 100644 tox.ini diff --git a/COPYING b/COPYING deleted file mode 100644 index fb1febb4..00000000 --- a/COPYING +++ /dev/null @@ -1,2 +0,0 @@ -authentic2-auth-fc is entirely under the copyright of Entr'ouvert and -distributed under the license AGPLv3 or later. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c07a348a..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -include COPYING -recursive-include src/authentic2_auth_fc/templates *.html -recursive-include src/authentic2_auth_fc/static *.css *.png *.svg -recursive-include src/authentic2_auth_fc/locale *.po *.mo -recursive-include src/authentic2_auth_fc *.json -include VERSION -include MANIFEST.in diff --git a/README b/README deleted file mode 100644 index 6e82d776..00000000 --- a/README +++ /dev/null @@ -1,120 +0,0 @@ -================== -authentic2-auth-fc -================== - -Authentic2 plugin to authenticate against *France Connect* the french -citizen and entreprise SSO. - -Installation -============ - -Install with `pip install authentic2-auth-fc` - -Settings -======== - -Add `A2_FC_ENABLE = True` to your `local_settings.py` file -Define the needed parameters:: - - A2_FC_CLIENT_ID = 'id assigned by DISIC' - A2_FC_CLIENT_SECRET = 'secret assigned by DISIC' - A2_FC_VERIFY_CERTIFICATE = False # True for production - -A2_FC_CREATE = True set the plugin in provisionning mode. If a sub is unknown, -a user is created instead of asking authentication. - -When the create mode is enabled, the link for unlinking is hidden on the -profile frontend. This is due to the not yet implemented need of asking -the user credentiels when unlinking a user created without any other credential -that the authentication delegation. Unlinking meaning, loosing access to this -account at the end of the current session. To enable unlinking when create is -unabled use A2_FC_ENABLE_UNLINK_WHEN_CREATE = True. - -A2_FC_LOGOUT_WHEN_UNLINK = True is using to trigger a logout toward the OP -after unlinking. - -Platforms -========= - -When testing against another platform than FranceConnect you must change -the default endpoints URL in your `local_settings.py` file:: - - A2_FC_AUTHORIZE_URL = 'https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize' - A2_FC_TOKEN_URL = 'https://fcp.integ01.dev-franceconnect.fr/api/v1/token' - A2_FC_USERINFO_URL = 'https://fcp.integ01.dev-franceconnect.fr/api/v1/userinfo' - A2_FC_LOGOUT_URL = 'https://fcp.integ01.dev-franceconnect.fr/api/v1/logout' - -Data Providers -============== - -You can define data provider endpoints with the following dictionnary : - -A2_FC_FD_LIST = { - 'revenu_fiscal_de_reference': [ - { - 'name': 'OpenDataSoft', - 'url': 'https://datafranceconnect.opendatasoft.com/api/records/1.0/search', - 'query_dic': {'dataset': 'guichet-des-bretons', }, - }, - ], -} - -Data is requested using the login or link endpoint view giving space delimited -scopes in the `fd_scopes` get parameter : - - fc/callback/?next=%2F&fd_scopes=revenu_fiscal_de_reference scolarite - -The data received is recorded in the session with a dictionnary named `fc-data` -with scopes as keys and lists of data as values. A data is a tuple -FD name and data content. - -fc_data_dic = { - scope_name = [ - [FD_name, data], - ], -} - -Attribute mapping -================= - -You can map France Connect attributes to Authentic2 attributes through the -setting A2_FC_USER_INFO_MAPPINGS. A2_FC_USER_INFO_MAPPINGS is a dictionnary -whose keys are authentic2's attribute names and value can be France Connect -attribute names or dictionnary with the following keys: - -- `value` : a static value which will be assigned to the authentic2 attribute, - can be any Python value, -- `ref` : the name of a France Connect attribute, -- `translation` : a transformation name among: - - @insee-communes@ : translate the value using mapping from INSEE code of - communes to their name, - - @insee-countries@ : translate the value using mapping from INSEE code of - countries to their name, - - @simple@ : lookup the value using the dictionnary in @translation_simple@. -- `compute`: compute a value using a known function, only known function for now - is @today@ which returns @datetime.date.today()@. -- `verified`: set the verified flag on the value. - -Exemple: - -A2_FC_USER_INFO_MAPPINGS = { - 'first_name': 'given_name', - 'last_name': 'family_name', - 'birthdate': { 'ref': 'birthdate', 'translation': 'isodate' }, - 'birthplace': { 'ref': 'birthplace', 'translation': 'insee-communes' }, - 'birthcountry': { 'ref': 'birthcountry', 'translation': 'insee-countries' }, - 'birthplace_insee': 'birthplace', - 'birthcountry_insee': 'birthcountry', - 'title': { - 'ref': 'gender', - 'translation': 'simple', - 'translation_simple': { - 'male': 'Monsieur', - 'female': 'Madame', - } - }, - 'gender': 'gender', - 'validated': { 'value': True }, - 'validation_date': { 'compute': 'today' }, - 'validation_context': { 'value': 'France Connect' }, -} diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index a97fd81d..00000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -python-authentic2-auth-fc (1.0.1-0) wheezy; urgency=low - - * First upstream release - - -- Benjamin Dauvergne Thu, 2 Dec 2014 12:00:29 +0100 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7f8f011e..00000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/debian/control b/debian/control deleted file mode 100644 index 3f219d36..00000000 --- a/debian/control +++ /dev/null @@ -1,17 +0,0 @@ -Source: python-authentic2-auth-fc -Maintainer: Benjamin Dauvergne -Section: python -Priority: optional -Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6), debhelper (>= 7.4.3), - python-django (>= 1.5) -Standards-Version: 3.9.1 -X-Python-Version: >= 2.6 - -Package: python-authentic2-auth-fc -Architecture: all -Depends: ${misc:Depends}, - python-authentic2 (>= 2.1.2.1009), - python-requests, - python-requests-oauthlib -Description: FranceConnect authentication frontend for Authentic2 - diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 447dee0c..00000000 --- a/debian/rules +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/make -f - -# This file was automatically generated by stdeb 0.6.0+git at -# Fri, 14 Jun 2013 17:33:52 +0200 - -%: - dh $@ --with python2 --buildsystem=python_distutils - - diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 163aaf8d..00000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/getlasso.sh b/getlasso.sh deleted file mode 100755 index 680da393..00000000 --- a/getlasso.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# Get venv site-packages path -DSTDIR=`python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` - -# Get not venv site-packages path -# Remove first path (assuming that is the venv path) -NONPATH=`echo $PATH | sed 's/^[^:]*://'` -SRCDIR=`PATH=$NONPATH python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` - -# Clean up -rm -f $DSTDIR/lasso.* -rm -f $DSTDIR/_lasso.* - -# Link -ln -sv $SRCDIR/lasso.py $DSTDIR -ln -sv $SRCDIR/_lasso.* $DSTDIR - -exit 0 - diff --git a/setup.py b/setup.py deleted file mode 100755 index e6eeb287..00000000 --- a/setup.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/python -import sys -import os -import subprocess -import glob - -from setuptools import setup, find_packages -from setuptools.command.install_lib import install_lib as _install_lib -from distutils.command.build import build as _build -from distutils.command.sdist import sdist -from distutils.cmd import Command - - -class compile_translations(Command): - description = 'compile message catalogs to MO files via django compilemessages' - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - curdir = os.getcwd() - try: - os.environ.pop('DJANGO_SETTINGS_MODULE', None) - from django.core.management import call_command - for dir in glob.glob('src/*'): - for path, dirs, files in os.walk(dir): - if 'locale' not in dirs: - continue - os.chdir(os.path.realpath(path)) - call_command('compilemessages') - os.chdir(curdir) - except ImportError: - print - sys.stderr.write('!!! Please install Django >= 1.4 to build translations') - print - print - os.chdir(curdir) - - -class build(_build): - sub_commands = [('compile_translations', None)] + _build.sub_commands - - -class eo_sdist(sdist): - - def run(self): - print "creating VERSION file" - if os.path.exists('VERSION'): - os.remove('VERSION') - version = get_version() - version_file = open('VERSION', 'w') - version_file.write(version) - version_file.close() - sdist.run(self) - print "removing VERSION file" - if os.path.exists('VERSION'): - os.remove('VERSION') - -class install_lib(_install_lib): - def run(self): - self.run_command('compile_translations') - _install_lib.run(self) - -def get_version(): - '''Use the VERSION, if absent generates a version with git describe, if not - tag exists, take 0.0.0- and add the length of the commit log. - ''' - if os.path.exists('VERSION'): - with open('VERSION', 'r') as v: - return v.read() - if os.path.exists('.git'): - p = subprocess.Popen(['git','describe','--dirty','--match=v*'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - result = p.communicate()[0] - if p.returncode == 0: - return result.split()[0][1:].replace('-', '.') - else: - return '0.0.0-%s' % len( - subprocess.check_output( - ['git', 'rev-list', 'HEAD']).splitlines()) - return '0.0.0' - -README = file(os.path.join( - os.path.dirname(__file__), - 'README')).read() - -setup(name='authentic2-auth-fc', - version=get_version(), - license='AGPLv3', - description='Authentic2 FranceConnect plugin', - long_description=README, - author="Entr'ouvert", - url='https://repos.entrouvert.org/authentic2-auth-fc.git', - author_email="info@entrouvert.com", - packages=find_packages('src'), - package_dir={ - '': 'src', - }, - package_data={ - 'authentic2_auth_fc': [ - 'templates/authentic2_auth_fc/*.html', - 'static/authentic2_auth_fc/css/*.css', - 'static/authentic2_auth_fc/img/*.png', - 'static/authentic2_auth_fc/img/*.svg', - 'locale/fr/LC_MESSAGES/django.po', - 'locale/fr/LC_MESSAGES/django.mo', - '*.json', - ], - }, - install_requires=[ - 'authentic2', - 'requests', - 'requests-oauthlib', - ], - entry_points={ - 'authentic2.plugin': [ - 'authentic2-auth-fc = authentic2_auth_fc:Plugin', - ], - }, - cmdclass={ - 'build': build, - 'install_lib': install_lib, - 'compile_translations': compile_translations, - 'sdist': eo_sdist}, - zip_safe=False, -) diff --git a/tests/settings.py b/tests/settings.py deleted file mode 100644 index 2e48c94d..00000000 --- a/tests/settings.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - -LANGUAGE_CODE = 'en' -DATABASES = { - 'default': { - 'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'), - 'TEST': { - 'NAME': 'a2-test', - }, - } -} diff --git a/tests/test_api.py b/tests/test_api_auth_fc.py similarity index 100% rename from tests/test_api.py rename to tests/test_api_auth_fc.py diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 4412f9b5..00000000 --- a/tox.ini +++ /dev/null @@ -1,46 +0,0 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - -[tox] -toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic2-auth-fc/ -envlist = {coverage,nocoverage}-{dj18}-{pg,sqlite} - -[testenv] -# django.contrib.auth is not tested it does not work with our templates -whitelist_externals = - /bin/mv -setenv = - AUTHENTIC2_SETTINGS_FILE=tests/settings.py - DJANGO_SETTINGS_MODULE=authentic2.settings - sqlite: DB_ENGINE=django.db.backends.sqlite3 - pg: DB_ENGINE=django.db.backends.postgresql_psycopg2 - coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov=src/ --cov-config .coveragerc - fast: FAST=--nomigrations -usedevelop = - coverage: True - nocoverage: False -deps = - dj18: django>1.8,<1.9 - dj19: django>1.8,<1.9 - pg: psycopg2<2.7 - coverage - pytest-cov - pytest-django - mock - pytest - lxml - cssselect - pylint - pylint-django - django-webtest - WebTest - pyquery - httmock - pytest-catchlog - pytz - ../authentic2 -commands = - ./getlasso.sh - py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/} -- 2.11.0