archimed: update filters and mappers to support the toolbar
Closes #6302
This commit is contained in:
parent
a964a2f11f
commit
29540f3cf8
|
@ -23,14 +23,18 @@ def default_req(env, values, request):
|
|||
request.cookies['S_HTTP_REFERER'] = re.sub(r'\?SAMLRequest=.*$',
|
||||
'',
|
||||
str(request.cookies['S_HTTP_REFERER']))
|
||||
return request
|
||||
|
||||
def default_resp(env, values, request, response):
|
||||
try:
|
||||
response.msg = response.msg.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
response.msg = response.msg.decode('iso8859-15')
|
||||
response.msg = re.sub(r'http://[s]*' + env['target'].netloc,
|
||||
if response.headers.has_key('location'):
|
||||
print response.headers['location'][0]
|
||||
response.headers['location'][0] = re.sub(r'http[s]*://' + env['target'].netloc,
|
||||
env['mandaye.scheme'] + '://' + env["HTTP_HOST"],
|
||||
response.headers['location'][0])
|
||||
response.msg = re.sub(r'http[s]*://' + env['target'].netloc,
|
||||
env['mandaye.scheme'] + '://' + env["HTTP_HOST"],
|
||||
response.msg)
|
||||
response.msg = response.msg.encode('utf-8')
|
||||
|
@ -106,64 +110,6 @@ def json_response(env, values, request, response):
|
|||
request.msg = content
|
||||
return get_response(env, request, target)
|
||||
|
||||
def rewrite_login_box(env, values, request, response):
|
||||
if response.msg:
|
||||
response.msg = response.msg.replace(
|
||||
'http://player.vimeo.com',
|
||||
'https://player.vimeo.com'
|
||||
)
|
||||
if response.msg and \
|
||||
'id="perso_authentification"' in response.msg and \
|
||||
'action="logon.aspx"' in response.msg:
|
||||
r = re.compile(
|
||||
r'<a id="REGISTRATION" class="fancybox.iframe".*?</a>',
|
||||
re.MULTILINE|re.DOTALL)
|
||||
|
||||
response.msg = re.sub(r,
|
||||
r"""
|
||||
<br />
|
||||
<a class="" href="/mandaye/sso" title="Se connecter avec son compte citoyen Montpellier Agglo">
|
||||
<span style="font-weight: bold;">Se connecter avec son compte citoyen Montpellier Agglo</span>
|
||||
</a>
|
||||
<br />
|
||||
<a class="" href="http://oai.mediatheques.montpellier-agglo.com/camo/GuestRegister.csp?Profile=Default&OpacLanguage=fre" title="Inscrivez-vous" target="_blank">
|
||||
<span>Préinscription en ligne</span>
|
||||
</a>
|
||||
""",
|
||||
response.msg)
|
||||
return response
|
||||
|
||||
def rewrite_logged_box(env, values, request, response):
|
||||
session = env.get('beaker.session')
|
||||
if response.msg and \
|
||||
'id="compte"' in response.msg and \
|
||||
'class="account_logoff"' in response.msg and \
|
||||
session and \
|
||||
session.has_key('unique_id'):
|
||||
r = re.compile(
|
||||
r'<img border="0" src="/ui/skins/default/ermes-front/images/General/Buttons/IconBar-Buttons/cancel.gif".*?</a>',
|
||||
re.MULTILINE|re.DOTALL)
|
||||
|
||||
resp = re.sub(r,
|
||||
r"""<script type="text/javascript">
|
||||
function disassociate_logout()
|
||||
{
|
||||
var r=confirm("Etes-vous sûr de vouloir désassocier votre comptre lecteur du compte Montpellier Agglo ?");
|
||||
if (r==true)
|
||||
{
|
||||
window.location = "/mandaye/disassociate?sp_name=archimed&logout=1";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<img border="0" src="/ui/skins/default/ermes-front/images/General/Buttons/IconBar-Buttons/cancel.gif" alt="">
|
||||
<a href="/mandaye/slo?next_url=/"><span>Me déconnecter</span></a>
|
||||
<br />
|
||||
<a href="javascript:disassociate_logout()"><span>Me délier du compte Montpellier Agglo</span></a>""",
|
||||
response.msg)
|
||||
response.msg = resp
|
||||
return response
|
||||
|
||||
def registration_req(env, values, request):
|
||||
session = env['beaker.session']
|
||||
if request.msg:
|
||||
|
|
|
@ -18,7 +18,9 @@ urls = {
|
|||
'login_url': '/mandaye/login',
|
||||
'connection_url': '/mandaye/sso',
|
||||
'associate_url': '/mandaye/associate',
|
||||
'logout_url': '/mandaye/slo',
|
||||
'disassociate_url': '/mandaye/disassociate',
|
||||
'disassociate_next_url': '/mandaye/logout',
|
||||
'logout_url': '/mandaye/logout',
|
||||
}
|
||||
|
||||
mapping = [
|
||||
|
@ -36,18 +38,6 @@ mapping = [
|
|||
'content-types': ['text/html', 'application/javascript', 'application/x-javascript', 'application/json'],
|
||||
}]
|
||||
},
|
||||
{
|
||||
'path': r'/%s/|/%s/' % (base, base.lower()),
|
||||
'method': 'GET',
|
||||
'content-types': ['text/html'],
|
||||
'on_response': [{
|
||||
'filter': archimed.rewrite_login_box,
|
||||
},
|
||||
{
|
||||
'filter': archimed.rewrite_logged_box
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'path': r'/mandaye/login$',
|
||||
'method': 'GET',
|
||||
|
@ -64,11 +54,6 @@ mapping = [
|
|||
'method': 'GET',
|
||||
'response': {'auth': 'sso',}
|
||||
},
|
||||
{
|
||||
'path': r'/mandaye/slo$',
|
||||
'method': 'GET',
|
||||
'response': {'auth': 'slo',}
|
||||
},
|
||||
{
|
||||
'path': r'%s$' % END_POINTS_PATH['single_sign_on_post'],
|
||||
'method': 'POST',
|
||||
|
@ -117,11 +102,6 @@ mapping = [
|
|||
},
|
||||
}]
|
||||
},
|
||||
{
|
||||
'path': r'/mandaye/disassociate$',
|
||||
'method': 'GET',
|
||||
'response': {'auth': 'disassociate',},
|
||||
},
|
||||
{
|
||||
'path': r'/mandaye/associate_confirm$',
|
||||
'method': 'GET',
|
||||
|
|
|
@ -15,6 +15,7 @@ urls = {
|
|||
'connection_url': '/mandaye/sso',
|
||||
'associate_url': '/montpellier/extranet/login/mandaye_associate',
|
||||
'disassociate_url': '/mandaye/disassociate',
|
||||
'disassociate_next_url': '/mandaye/logout?next_url=/montpellier/extranet/login/usa_index_famille.php',
|
||||
}
|
||||
|
||||
replay_condition = lambda env, response: "OK" in response.msg
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</li>
|
||||
% if account:
|
||||
<li>
|
||||
<a href="javascript:mandaye_disassociate_logout('${urls['disassociate_url']}', '${account['sp_login']}', ${account['id']}, '/mandaye/logout?next_url=/montpellier/extranet/login/usa_index_famille.php')" title="Cliquer ici pour supprimer l'association entre ce compte et votre compte citoyen.">Me désassocier</a>
|
||||
<a href="javascript:mandaye_disassociate_logout('${urls['disassociate_url']}', '${account['sp_login']}', ${account['id']}, '${urls['disassociate_next_url']}')" title="Cliquer ici pour supprimer l'association entre ce compte et votre compte citoyen.">Délier mon compte</a>
|
||||
</li>
|
||||
% endif
|
||||
% elif is_user_locally_logged_in:
|
||||
|
|
Reference in New Issue