summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérôme Schneider <jschneider@entrouvert.com>2014-06-02 21:35:58 (GMT)
committerJérôme Schneider <jschneider@entrouvert.com>2014-06-02 21:35:58 (GMT)
commit93f8b55a8648ab2c9a629048746047fa07a09fcd (patch)
tree538b1c2efd2a506e5a3a9b0d0af1947afa0208cf
parent8e99b9a8e21c190e2ecd63868caded15a87618bb (diff)
downloadmandaye-meyzieu-93f8b55a8648ab2c9a629048746047fa07a09fcd.zip
mandaye-meyzieu-93f8b55a8648ab2c9a629048746047fa07a09fcd.tar.gz
mandaye-meyzieu-93f8b55a8648ab2c9a629048746047fa07a09fcd.tar.bz2
manage sso and slo
-rw-r--r--.gitignore3
-rw-r--r--conf.d/linuxfr_saml_example11
-rw-r--r--conf.d/portatil_famille2
-rw-r--r--rp_meyzieu/filters/portail_famille_ecitiz.py20
-rw-r--r--rp_meyzieu/mappers/linuxfr_example.py85
-rw-r--r--rp_meyzieu/mappers/portail_famille_ecities.py25
6 files changed, 47 insertions, 99 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5eeda39
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.db
+*.pyc
+*.pyo
diff --git a/conf.d/linuxfr_saml_example b/conf.d/linuxfr_saml_example
deleted file mode 100644
index 7918032..0000000
--- a/conf.d/linuxfr_saml_example
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "site_name": "linuxfr",
- "server_name": ["linuxfrsaml.local:8000"],
- "location": "/",
- "target": "https://linuxfr.org",
- "mapper": "linuxfr",
- "auth_type": "saml2",
- "saml2_idp_metadata": "http://www.identity-hub.com/idp/saml2/metadata",
- "saml2_signature_public_key": "certs/saml.crt",
- "saml2_signature_private_key": "certs/saml.key"
-}
diff --git a/conf.d/portatil_famille b/conf.d/portatil_famille
index 8025acb..c49a014 100644
--- a/conf.d/portatil_famille
+++ b/conf.d/portatil_famille
@@ -5,7 +5,7 @@
"target": "http://villes2.portail-familles.com:8080",
"mapper": "portail_famille_ecities",
"auth_type": "saml2",
- "saml2_idp_metadata": "http://www.identity-hub.com/idp/saml2/metadata",
+ "saml2_idp_metadata": "https://sso-vincennes.dev.entrouvert.org/idp/saml2/metadata",
"saml2_signature_public_key": "certs/saml.crt",
"saml2_signature_private_key": "certs/saml.key"
}
diff --git a/rp_meyzieu/filters/portail_famille_ecitiz.py b/rp_meyzieu/filters/portail_famille_ecitiz.py
index c414e2f..f00b803 100644
--- a/rp_meyzieu/filters/portail_famille_ecitiz.py
+++ b/rp_meyzieu/filters/portail_famille_ecitiz.py
@@ -1,11 +1,14 @@
+import urllib
import re
+from urlparse import parse_qs
from mandaye.log import logger
def associate(env, values, request, response):
if response.msg and "<form" in response.msg:
- sub = re.subn(r'<form action="/ffaxsslMeyzieu/workflow_url".*?>', '<form action="/ffaxsslMeyzieu/mandaye_associate" method="post" accept-charset="UTF-8">',
+ sub = re.subn(r'<form action="/ffaxsslMeyzieu/workflow_url".*?>',
+ '<form action="/ffaxsslMeyzieu/mandaye_associate" method="post" accept-charset="UTF-8">',
response.msg)
response.msg = sub[0]
if sub[1] != 1:
@@ -19,3 +22,18 @@ def associate(env, values, request, response):
logger.warning('Filter portail_famille_ecitiz.associate: submit replacement failed !')
return response
+
+def clean_js(env, values, request, response):
+ if response.msg and 'alert("Veuillez, s' in response.msg:
+ response.msg = re.sub(r'<script type="text/javascript"> alert\("Veuillez, s\'il vous pl.*?>',
+ '', response.msg)
+ return response
+
+def rewrite_logout_form(env, values, request, response):
+ if response.msg and 'egoSubmitMeDeconnecter_action220_6T9N' in response.msg:
+ response.msg = re.sub(
+ re.compile('</form>\n<form enctype="multipart/form-data".*?<input type="submit" name="egoSubmitMeDeconnecter_action220_6T9N".*?</form>', re.MULTILINE|re.DOTALL),
+ '<a href="/mandaye/slo"><input type="button" name="egoSubmitMeDeconnecter_action220_6T9N" class="egoLabelButtonGuidgetStyle egoLabelButtonGuidgetStyleLeftToRight" title="" value="Me deconnecter"></a>',
+ response.msg)
+ return response
+
diff --git a/rp_meyzieu/mappers/linuxfr_example.py b/rp_meyzieu/mappers/linuxfr_example.py
deleted file mode 100644
index 80c5abf..0000000
--- a/rp_meyzieu/mappers/linuxfr_example.py
+++ /dev/null
@@ -1,85 +0,0 @@
-
-"""
-You need to defined 3 variables :
-
-* form_values (defined the login form values):
-form_values = {
- 'login_url': '/login',
- 'post_url': '/login',
- 'form_attrs': { 'name': 'form40', },
- 'username_field': 'user',
- 'password_field': 'pass',
- 'post_fields': ['birthdate', 'card_number']
-}
-login_url, form_attrs, post_fields and username_field are obligatory
-* urls (a dictionnary with urls) :
- urls = {
- 'associate_url': '/mandaye/associate',
- 'connection_url': '/mandaye/sso',
- 'login_url': '/mandaye/login'
- }
-* mapping
-"""
-
-from rp_meyzieu.filters.example import ReplayFilter
-
-form_values = {
- 'login_url': '/compte/connexion',
- 'form_attrs': { 'id': 'new_account' },
- 'post_fields': ['account[login]', 'account[password]'],
- 'username_field': 'account[login]',
- 'password_field': 'account[password]',
-}
-
-urls = {
- 'associate_url': '/mandaye_associate',
- 'connection_url': '/mandaye/sso',
- 'login_url': '/mandaye/login'
-}
-
-mapping = [
- {
- 'path': r'/mandaye/login$',
- 'method': 'GET',
- 'response': [{
- 'auth': 'login',
- 'condition': 'response.code==302',
- },]
- },
- {
- 'path': r'/mandaye/sso$',
- 'method': 'GET',
- 'response': [{
- 'auth': 'sso',
- }]
- },
- {
- 'path': r'/mandaye/slo$',
- 'method': 'GET',
- 'response': [{
- 'auth': 'slo',
- }]
- },
- {
- 'path': r'/mandaye_associate$',
- 'method': 'GET',
- 'target': '/ffaxsslMeyzieu/workflow_url?ECITIZ_ACTIVITY_PATH=Citoyen&ECITIZ_HOME_URL=citoyen.jsp&ECITIZ_PROCESS_ID=guichet&ECITIZ_DECONNECTION_URL=services_list.jsp&ECITIZ_ORG=MEY00',
- 'on_response': [{
- 'filter': ecitiz.associate,
- 'values': {
- 'action': urls['associate_url'],
- },
- },]
- },
- {
- 'path': r'/mandaye_associate$',
- 'method': 'POST',
- 'response': [
- {
- 'auth': 'associate_submit',
- 'condition': "response.code==302"
- },
- ]
- },
- ]
-
diff --git a/rp_meyzieu/mappers/portail_famille_ecities.py b/rp_meyzieu/mappers/portail_famille_ecities.py
index 8797d83..dd9d849 100644
--- a/rp_meyzieu/mappers/portail_famille_ecities.py
+++ b/rp_meyzieu/mappers/portail_famille_ecities.py
@@ -38,6 +38,8 @@ urls = {
'login_url': '/mandaye/login'
}
+index_url = '/ffaxsslMeyzieu/workflow_url?ECITIZ_ACTIVITY_PATH=Citoyen&ECITIZ_HOME_URL=citoyen.jsp&ECITIZ_PROCESS_ID=guichet&ECITIZ_DECONNECTION_URL=services_list.jsp&ECITIZ_ORG=MEY00'
+
mapping = [
{
'path': r'/mandaye/login$',
@@ -62,6 +64,22 @@ mapping = [
}]
},
{
+ 'path': (r'/ffaxsslMeyzieu/$', r'/ffaxsslMeyzieu/workflow_url'),
+ 'method': 'GET',
+ 'on_response': [{
+ 'content-types': ['text/html'],
+ 'filter': portail_famille_ecitiz.rewrite_logout_form
+ }],
+ },
+ {
+ 'path': r'/ffaxsslMeyzieu/workflow_url$',
+ 'method': 'POST',
+ 'on_response': [{
+ 'content-types': ['text/html'],
+ 'filter': portail_famille_ecitiz.rewrite_logout_form
+ }]
+ },
+ {
'path': r'/ffaxsslMeyzieu/mandaye_associate$',
'method': 'GET',
'target': '/ffaxsslMeyzieu/workflow_url?ECITIZ_ACTIVITY_PATH=Citoyen&ECITIZ_HOME_URL=citoyen.jsp&ECITIZ_PROCESS_ID=guichet&ECITIZ_DECONNECTION_URL=services_list.jsp&ECITIZ_ORG=MEY00',
@@ -71,7 +89,9 @@ mapping = [
'action': urls['associate_url'],
'template': 'portail_famille/associate.html',
},
- },]
+ },
+ {'filter': portail_famille_ecitiz.clean_js}
+ ]
},
{
'path': r'/ffaxsslMeyzieu/mandaye_associate$',
@@ -100,6 +120,9 @@ mapping = [
'method': 'GET',
'response': [{
'auth': 'single_logout_return',
+ 'values': {
+ 'next_url': index_url
+ },
}]
},
]