summaryrefslogtreecommitdiffstats
path: root/rp_meyzieu/mappers/portail_famille_ecities.py
blob: def750b9c7c93e47dd73e242a5c3d878167f978a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

"""
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.auth.saml2 import END_POINTS_PATH
from rp_meyzieu.filters import portail_famille_ecitiz

form_values = {
        'login_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',
        'form_attrs': { 'name': 'eCitiz' },
        'post_fields': ['MonIdentifiant_champcalcule6', 'MonMotDePasse_champcalcule9'],
        'username_field': 'MonIdentifiant_champcalcule6',
        'password_field': 'MonMotDePasse_champcalcule9',
        }

urls = {
        'associate_url': '/ffaxsslMeyzieu/mandaye_associate',
        'connection_url': '/mandaye/sso',
        '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'/$',
            'method': 'GET',
            'redirect': index_url, 
            },  
        {
            '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'/ffaxsslMeyzieu/$', r'/ffaxsslMeyzieu/workflow_url$'),
            'method': 'GET',
            'on_response': [{
                'content-types': ['text/html'],
                'filter': portail_famille_ecitiz.rewrite_logout_form
                },
                {
                    'content-types': ['text/html'],
                    'filter': portail_famille_ecitiz.add_sso_login_box
                    },
                {
                    'content-types': ['text/html'],
                    'filter': portail_famille_ecitiz.clean_js
                    }
                ],
            },
        {
            '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',
                'on_response': [{
                    'filter': portail_famille_ecitiz.associate,
                    'values': {
                        'action': urls['associate_url'],
                        'template': 'portail_famille/associate.html',
                        },
                    },
                    {
                        'content-types': ['text/html'],
                        'filter': portail_famille_ecitiz.clean_js
                        }
                    ]
                },
        {
                'path':  r'/ffaxsslMeyzieu/mandaye_associate$',
                'method': 'POST',
                'response': {
                    'auth': 'associate_submit',
                    'condition': "response.code==302"
                    }
                },
        {
                'path': r'%s$' % END_POINTS_PATH['single_sign_on_post'],
                'method': 'POST',
                'response': {'auth': 'single_sign_on_post'}
                },
        {
                'path': r'%s$' % END_POINTS_PATH['single_logout'],
                'method': 'GET',
                'response': {'auth': 'single_logout',}
                },
        {
                'path': r'%s$' % END_POINTS_PATH['single_logout_return'],
                'method': 'GET',
                'response': {
                    'auth': 'single_logout_return',
                    'values': {
                        'next_url': index_url
                        },
                    }
                },
        ]