authentic2-cut/src/authentic2_cut/__init__.py

74 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
#
# authentic2_cut - Authentic2 plugin for CUT
# Copyright (C) 2016 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.apps
class AppConfig(django.apps.AppConfig):
name = 'authentic2_cut'
def post_migrate(self, **kwargs):
# create custom operations
from django_rbac.models import Operation
from django_rbac.utils import get_operation
FC_MANAGE_OP = Operation(name=u'Gérer les fédérations France Connect',
slug='fc_manage')
get_operation(FC_MANAGE_OP)
def ready(self):
from django.db.models.signals import post_migrate
post_migrate.connect(
self.post_migrate,
sender=self)
def get_a2_manager_actions(self, model=None, **kwargs):
'''Retourne des actions utilisateurs pour la gestion France Connect'''
from django.contrib.auth import get_user_model
from .actions import FranceConnect
if issubclass(model, get_user_model()):
return [FranceConnect]
return []
def get_a2_manager_other_data(self, model=None, **kwargs):
'''Retourne des objets pour afficher la fédération France Connect'''
from django.contrib.auth import get_user_model
from .user_datas import FranceConnectUserData
if issubclass(model, get_user_model()):
return [FranceConnectUserData]
return []
default_app_config = 'authentic2_cut.AppConfig'
class Plugin(object):
def get_before_urls(self):
from . import urls
return urls.urlpatterns
def get_apps(self):
return [__name__]
def get_authentication_backends(self):
return []
def get_auth_frontends(self):
return []