84 lines
2.3 KiB
Python
84 lines
2.3 KiB
Python
|
|
"""
|
|
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 mandaye_cud.filters.example import ReplayFilter
|
|
|
|
form_values = {
|
|
'login_url': '/studio/accueil',
|
|
'form_attrs': { 'id': 'login-form' },
|
|
'post_fields': ['username', 'password'],
|
|
'username_field': 'username',
|
|
'password_field': 'password',
|
|
}
|
|
|
|
urls = {
|
|
'associate_url': '/mandaye/associate',
|
|
'connection_url': '/mandaye/sso',
|
|
'disassociate_url': '/mandaye/disassociate',
|
|
'login_url': '/mandaye/login'
|
|
}
|
|
|
|
mapping = [
|
|
{
|
|
'path': r'/mandaye/login$',
|
|
'method': 'GET',
|
|
'response': {
|
|
'auth': 'login',
|
|
'values': {'condition': "'success' in response.msg"},
|
|
},
|
|
},
|
|
{
|
|
'path': r'/mandaye/sso$',
|
|
'method': 'GET',
|
|
'response': {'auth': 'sso',}
|
|
},
|
|
{
|
|
'path': r'/mandaye/slo$',
|
|
'method': 'GET',
|
|
'response': {'auth': 'slo',}
|
|
},
|
|
{
|
|
'path': r'/mandaye/associate$',
|
|
'method': 'GET',
|
|
'on_response': [{
|
|
'filter': ReplayFilter.associate,
|
|
'values': {
|
|
'action': urls['associate_url'],
|
|
'template': 'associate.html',
|
|
'sp_name': 'Arcopole',
|
|
'login_name': form_values['username_field'],
|
|
'password_name': form_values['password_field'],
|
|
},
|
|
},]
|
|
},
|
|
{
|
|
'path': r'/mandaye/associate$',
|
|
'method': 'POST',
|
|
'response': {
|
|
'auth': 'associate_submit',
|
|
'values': {'condition': "'success' in response.msg"}
|
|
},
|
|
},
|
|
]
|
|
|