manage sso and slo
This commit is contained in:
parent
8e99b9a8e2
commit
93f8b55a86
|
@ -0,0 +1,3 @@
|
||||||
|
*.db
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
|
@ -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"
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@
|
||||||
"target": "http://villes2.portail-familles.com:8080",
|
"target": "http://villes2.portail-familles.com:8080",
|
||||||
"mapper": "portail_famille_ecities",
|
"mapper": "portail_famille_ecities",
|
||||||
"auth_type": "saml2",
|
"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_public_key": "certs/saml.crt",
|
||||||
"saml2_signature_private_key": "certs/saml.key"
|
"saml2_signature_private_key": "certs/saml.key"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
|
import urllib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from urlparse import parse_qs
|
||||||
from mandaye.log import logger
|
from mandaye.log import logger
|
||||||
|
|
||||||
def associate(env, values, request, response):
|
def associate(env, values, request, response):
|
||||||
if response.msg and "<form" in response.msg:
|
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)
|
||||||
response.msg = sub[0]
|
response.msg = sub[0]
|
||||||
if sub[1] != 1:
|
if sub[1] != 1:
|
||||||
|
@ -19,3 +22,18 @@ def associate(env, values, request, response):
|
||||||
logger.warning('Filter portail_famille_ecitiz.associate: submit replacement failed !')
|
logger.warning('Filter portail_famille_ecitiz.associate: submit replacement failed !')
|
||||||
|
|
||||||
return response
|
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
|
||||||
|
|
||||||
|
|
|
@ -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"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ urls = {
|
||||||
'login_url': '/mandaye/login'
|
'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 = [
|
mapping = [
|
||||||
{
|
{
|
||||||
'path': r'/mandaye/login$',
|
'path': r'/mandaye/login$',
|
||||||
|
@ -61,6 +63,22 @@ mapping = [
|
||||||
'auth': 'slo',
|
'auth': 'slo',
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'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$',
|
'path': r'/ffaxsslMeyzieu/mandaye_associate$',
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
|
@ -71,7 +89,9 @@ mapping = [
|
||||||
'action': urls['associate_url'],
|
'action': urls['associate_url'],
|
||||||
'template': 'portail_famille/associate.html',
|
'template': 'portail_famille/associate.html',
|
||||||
},
|
},
|
||||||
},]
|
},
|
||||||
|
{'filter': portail_famille_ecitiz.clean_js}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'path': r'/ffaxsslMeyzieu/mandaye_associate$',
|
'path': r'/ffaxsslMeyzieu/mandaye_associate$',
|
||||||
|
@ -100,6 +120,9 @@ mapping = [
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
'response': [{
|
'response': [{
|
||||||
'auth': 'single_logout_return',
|
'auth': 'single_logout_return',
|
||||||
|
'values': {
|
||||||
|
'next_url': index_url
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
Reference in New Issue