This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
authentic2-auth-fc/src/authentic2_auth_fc/app_settings.py

118 lines
3.3 KiB
Python
Raw Normal View History

add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
class AppSettings(object):
'''Thanks django-allauth'''
__SENTINEL = object()
def __init__(self, prefix):
self.prefix = prefix
def _setting(self, name, dflt=__SENTINEL):
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
v = getattr(settings, self.prefix + name, dflt)
if v is self.__SENTINEL:
raise ImproperlyConfigured('Missing setting %r' % (self.prefix + name))
return v
@property
2015-05-28 00:54:18 +02:00
def enable(self):
return self._setting('ENABLE', False)
2015-05-27 18:47:43 +02:00
@property
def create(self):
return self._setting('CREATE', False)
2015-05-27 18:47:43 +02:00
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
@property
def authorize_url(self):
2015-05-27 16:07:44 +02:00
return self._setting('AUTHORIZE_URL', 'https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize')
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
@property
def token_url(self):
2015-05-27 16:07:44 +02:00
return self._setting('TOKEN_URL', 'https://fcp.integ01.dev-franceconnect.fr/api/v1/token')
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
@property
2015-05-27 16:07:44 +02:00
def userinfo_url(self):
return self._setting('USERINFO_URL', 'https://fcp.integ01.dev-franceconnect.fr/api/v1/userinfo')
@property
def logout_url(self):
return self._setting('LOGOUT_URL', 'https://fcp.integ01.dev-franceconnect.fr/api/v1/logout')
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
@property
def about_url(self):
2016-06-20 16:18:09 +02:00
return self._setting('ABOUT_URL', 'https://app.franceconnect.gouv.fr/en-savoir-plus')
@property
def logout_when_unlink(self):
return self._setting('LOGOUT_WHEN_UNLINK', True)
@property
def logout_at_unlink_return_url(self):
return self._setting('LOGOUT_AT_UNLINK_RETURN_URL', '/accounts/')
@property
def enable_registration_form_prefill(self):
return self._setting('ENABLE_REGISTRATION_FORM_PREFILL', True)
@property
def attributes_mapping(self):
return self._setting('ATTRIBUTES_MAPPING',
{
'family_name': 'last_name',
'given_name': 'first_name',
'email': 'email'
})
@property
def user_info_mappings(self):
return self._setting('USER_INFO_MAPPINGS', {
'last_name': 'family_name',
'first_name': 'given_name',
'email': 'email',
'password': {'compute': 'random', 'if-empty': True},
})
@property
def next_field_name(self):
return self._setting('NEXT_FIELD_NAME', 'fc_next')
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
@property
def client_id(self):
return self._setting('CLIENT_ID')
@property
def client_secret(self):
return self._setting('CLIENT_SECRET')
@property
def verify_certificate(self):
return self._setting('VERIFY_CERTIFICATE', False)
@property
def client_credentials(self):
return self._setting('CLIENT_CREDENTIALS', ())
@property
def show_button_quick_account_creation(self):
return self._setting('SHOW_BUTTON_QUICK_ACCOUNT_CREATION', True)
@property
def auto_register(self):
return self._setting('AUTO_REGISTER', True)
2015-05-29 11:24:26 +02:00
@property
def fd_list(self):
return self._setting('FD_LIST', {})
2017-07-26 19:06:40 +02:00
@property
def scopes(self):
return self._setting('SCOPES', [])
import sys
2015-05-27 16:07:44 +02:00
app_settings = AppSettings('A2_FC_')
add msp integration application Requirements ============ Your base template must use django-sekizai and must contain a sekizai block named "css" and another named "js" respectively for stylesheet and javascript files. Installation ============ Add the application to your installed apps:: INSTALLED_APPS += ( 'msp', ) Install the authentication backend:: AUTHENTICATION_BACKENDS += ( 'msp.backends.MspBackend', ) Define needed settings, we show here the default values:: MSP_AUTHORIZE_URL = 'https://mon.service-public.fr/apis/app/oauth/authorize' MSP_TOKEN_URL = 'https://mon.service-public.fr/apis/app/oauth/token' MSP_API_URL = 'https://mon.service-public.fr/apis/' MSP_CLIENT_ID = 'id assigned by DIMAP' MSP_CLIENT_SECRET = 'secret assigned by DIMAP' MSP_CLIENT_CERTIFICATE = ('/my-path/my-certificate.crt', '/my-path/my-certificate.key') MSP_VERIFY_CERTIFICATE = False You must plug the application views in your urls.py file by adding this content:: url(r'^msp/', include('msp.urls')), To link your account to MSP or unlink your account from MSP, add the following content to your template:: {% include 'msp/linking.html' %} It will show a linking link when unauthenticated and when no msp account is linked to the current account or an unlinking link when authenticated and a to MSP exists. To show a connection box include this content in your template:: {% include 'msp/connecting.html' %} To make the include file use a popup to talk to MSP add the popup parameter like in the following content:: {% include 'msp/connecting.html' with popup=1 %}
2013-10-11 17:33:20 +02:00
app_settings.__name__ = __name__
sys.modules[__name__] = app_settings