diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..27c6770 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +MANIFEST +*.pyc +*.pyo +*.db +.*.swp +cache/ +dist/ +./static/ +doc/_build +authentic.egg-info +local_settings.py +log.log +authentic2/locale/fr/LC_MESSAGES/django.mo +local_settings.* +*.egg-info +*.mo \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 12a1bbb..2687c98 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ include COPYING recursive-include src/authentic2_auth_msp/templates *.html -recursive-include src/authentic2_auth_msp/static *.js *.css *.png +recursive-include src/authentic2_auth_msp/static *.js *.css *.png *.gif *.jpg recursive-include src/authentic2_auth_msp/locale *.po *.mo diff --git a/setup.py b/setup.py index d49e948..2f02f2b 100755 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ setup(name='authentic2-auth-msp', 'authentic2', 'requests', 'requests-oauthlib', + 'django-sekizai', ], entry_points={ 'authentic2.plugin': [ diff --git a/src/authentic2_auth_msp/__init__.py b/src/authentic2_auth_msp/__init__.py index e69de29..54b9456 100644 --- a/src/authentic2_auth_msp/__init__.py +++ b/src/authentic2_auth_msp/__init__.py @@ -0,0 +1,15 @@ +__version__ = '1.0.0a' + +class Plugin(object): + def get_before_urls(self): + from . import urls + return urls.urlpatterns + + def get_apps(self): + return [__name__, 'sekizai'] + + def get_authentication_backends(self): + return ['authentic2_auth_msp.backends.MspBackend'] + + def get_auth_frontends(self): + return ['authentic2_auth_msp.auth_frontends.MspFrontend'] diff --git a/src/authentic2_auth_msp/app_settings.py b/src/authentic2_auth_msp/app_settings.py index c909f0d..bbd47c6 100644 --- a/src/authentic2_auth_msp/app_settings.py +++ b/src/authentic2_auth_msp/app_settings.py @@ -1,6 +1,5 @@ import sys -from django.conf import settings from django.core.exceptions import ImproperlyConfigured @@ -18,6 +17,10 @@ class AppSettings(object): raise ImproperlyConfigured('Missing setting %r' % (self.prefix + name)) return v + @property + def enabled(self): + return self._setting('ENABLED', False) + @property def authorize_url(self): return self._setting('AUTHORIZE_URL') @@ -55,6 +58,6 @@ class AppSettings(object): return self._setting('MORE_URL', 'https://mon.service-public.fr/') -app_settings = AppSettings('MSP_') +app_settings = AppSettings('A2_MSP_') app_settings.__name__ = __name__ sys.modules[__name__] = app_settings diff --git a/src/authentic2_auth_msp/auth_frontends.py b/src/authentic2_auth_msp/auth_frontends.py new file mode 100644 index 0000000..a3f3818 --- /dev/null +++ b/src/authentic2_auth_msp/auth_frontends.py @@ -0,0 +1,25 @@ +from django.utils.translation import gettext_noop +from django.template.loader import render_to_string +from django import forms + +from . import app_settings + +class MspFrontend(object): + def enabled(self): + return app_settings.enabled + + def name(self): + return gettext_noop('mon.service-public.fr') + + def id(self): + return 'msp' + + def form(self): + return forms.Form + + def template(self): + return 'authentic2_auth_msp/connecting.html' + + def profile(self, request): + return render_to_string('authentic2_auth_msp/linking.html') + diff --git a/src/authentic2_auth_msp/migrations/0001_initial.py b/src/authentic2_auth_msp/migrations/0001_initial.py deleted file mode 100644 index 95963a9..0000000 --- a/src/authentic2_auth_msp/migrations/0001_initial.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'MspAccount' - db.create_table(u'msp_mspaccount', ( - (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('user', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['portail_citoyen.Citoyen'], unique=True)), - ('agc', self.gf('django.db.models.fields.CharField')(max_length=64)), - )) - db.send_create_signal(u'msp', ['MspAccount']) - - - def backwards(self, orm): - # Deleting model 'MspAccount' - db.delete_table(u'msp_mspaccount') - - - models = { - u'auth.group': { - 'Meta': {'object_name': 'Group'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - u'auth.permission': { - 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - u'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - u'msp.mspaccount': { - 'Meta': {'object_name': 'MspAccount'}, - 'agc': ('django.db.models.fields.CharField', [], {'max_length': '64'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['portail_citoyen.Citoyen']", 'unique': 'True'}) - }, - u'portail_citoyen.citoyen': { - 'Meta': {'object_name': 'Citoyen'}, - 'address': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), - 'backend': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), - 'backend_id': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}), - 'city': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'mobile': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'phone': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '5', 'blank': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '256'}) - } - } - - complete_apps = ['msp'] \ No newline at end of file diff --git a/src/authentic2_auth_msp/migrations/0002_auto__add_field_mspaccount_token.py b/src/authentic2_auth_msp/migrations/0002_auto__add_field_mspaccount_token.py deleted file mode 100644 index 65c1328..0000000 --- a/src/authentic2_auth_msp/migrations/0002_auto__add_field_mspaccount_token.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'MspAccount.token' - db.add_column(u'msp_mspaccount', 'token', - self.gf('django.db.models.fields.TextField')(default=''), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'MspAccount.token' - db.delete_column(u'msp_mspaccount', 'token') - - - models = { - u'auth.group': { - 'Meta': {'object_name': 'Group'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - u'auth.permission': { - 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - u'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - u'msp.mspaccount': { - 'Meta': {'object_name': 'MspAccount'}, - 'agc': ('django.db.models.fields.CharField', [], {'max_length': '64'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'token': ('django.db.models.fields.TextField', [], {}), - 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['portail_citoyen.Citoyen']", 'unique': 'True'}) - }, - u'portail_citoyen.citoyen': { - 'Meta': {'object_name': 'Citoyen'}, - 'address': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), - 'backend': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), - 'backend_id': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}), - 'city': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'mobile': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'phone': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '5', 'blank': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '256'}) - } - } - - complete_apps = ['msp'] \ No newline at end of file diff --git a/src/authentic2_auth_msp/migrations/0003_auto__chg_field_mspaccount_user.py b/src/authentic2_auth_msp/migrations/0003_auto__chg_field_mspaccount_user.py deleted file mode 100644 index a3be5fd..0000000 --- a/src/authentic2_auth_msp/migrations/0003_auto__chg_field_mspaccount_user.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - - # Changing field 'MspAccount.user' - db.alter_column(u'msp_mspaccount', 'user_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['portail_citoyen.Citoyen'], unique=True, null=True, on_delete=models.SET_NULL)) - - def backwards(self, orm): - - # User chose to not deal with backwards NULL issues for 'MspAccount.user' - raise RuntimeError("Cannot reverse this migration. 'MspAccount.user' and its values cannot be restored.") - - # The following code is provided here to aid in writing a correct migration - # Changing field 'MspAccount.user' - db.alter_column(u'msp_mspaccount', 'user_id', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['portail_citoyen.Citoyen'], unique=True)) - - models = { - u'auth.group': { - 'Meta': {'object_name': 'Group'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - u'auth.permission': { - 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - u'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - u'msp.mspaccount': { - 'Meta': {'object_name': 'MspAccount'}, - 'agc': ('django.db.models.fields.CharField', [], {'max_length': '64'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'token': ('django.db.models.fields.TextField', [], {}), - 'user': ('django.db.models.fields.related.OneToOneField', [], {'default': 'None', 'to': u"orm['portail_citoyen.Citoyen']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL'}) - }, - u'portail_citoyen.citoyen': { - 'Meta': {'object_name': 'Citoyen'}, - 'address': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), - 'backend': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), - 'backend_id': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}), - 'city': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '128', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'mobile': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'phone': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '5', 'blank': 'True'}), - 'title': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '256'}) - } - } - - complete_apps = ['msp'] \ No newline at end of file diff --git a/src/authentic2_auth_msp/migrations/__init__.py b/src/authentic2_auth_msp/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/authentic2_auth_msp/static/authentic2_auth_msp/img/Thumbs.db b/src/authentic2_auth_msp/static/authentic2_auth_msp/img/Thumbs.db deleted file mode 100644 index 4f4ad84..0000000 Binary files a/src/authentic2_auth_msp/static/authentic2_auth_msp/img/Thumbs.db and /dev/null differ diff --git a/src/authentic2_auth_msp/static/authentic2_auth_msp/img/bg/Thumbs.db b/src/authentic2_auth_msp/static/authentic2_auth_msp/img/bg/Thumbs.db deleted file mode 100644 index e61f4b3..0000000 Binary files a/src/authentic2_auth_msp/static/authentic2_auth_msp/img/bg/Thumbs.db and /dev/null differ diff --git a/src/authentic2_auth_msp/templates/authentic2_auth_msp/confirm_unlink.html b/src/authentic2_auth_msp/templates/authentic2_auth_msp/confirm_unlink.html index e14b000..6e04b4d 100644 --- a/src/authentic2_auth_msp/templates/authentic2_auth_msp/confirm_unlink.html +++ b/src/authentic2_auth_msp/templates/authentic2_auth_msp/confirm_unlink.html @@ -5,10 +5,10 @@ {% block content %} - {% addtoblock "css" %}{% endaddtoblock %} - {% addtoblock "js" %}{% endaddtoblock %} - {% addtoblock "js" %}{% endaddtoblock %} - {% addtoblock "js" %}{% endaddtoblock %} + {% addtoblock "css" %}{% endaddtoblock %} + {% addtoblock "js" %}{% endaddtoblock %} + {% addtoblock "js" %}{% endaddtoblock %} + {% addtoblock "js" %}{% endaddtoblock %}