Projet

Général

Profil

0001-qommon-push-saml-information-in-the-session-at-saml-.patch

Benjamin Dauvergne, 03 octobre 2013 16:55

Télécharger (4,5 ko)

Voir les différences:

Subject: [PATCH] qommon: push saml information in the session at saml login,
 and export them as substitution variables

New substitution variables are:
 - session_saml True / False
 - session_saml_name_id string
 - session_saml_name_id_format string
 - session_saml_session_index string
 - session_saml_idp_entity_id string
 - session_saml_attribute_<attribute_name> list(string)
 help/fr/misc-substvars.page |   31 +++++++++++++++++++++++++++++++
 wcs/qommon/publisher.py     |    3 +++
 wcs/qommon/saml2.ptl        |   12 +++++++++++-
 wcs/qommon/sessions.py      |   14 ++++++++++++++
 4 files changed, 59 insertions(+), 1 deletion(-)
help/fr/misc-substvars.page
192 192
  </table>
193 193
  </section>
194 194

  
195
  <section>
196
    <title>Authentification SAML</title>
197

  
198
    <table shade="rows">
199
    <tr>
200
      <td><p><code>session_saml</code></p></td>
201
      <td><p>Un booléen indiquant si SAML a été utilisé pour authentifier l'utilisateur</p></td>
202
    </tr>
203
    <tr>
204
      <td><p><code>session_saml_idp_entity_id</code></p></td>
205
      <td><p>« L'entity ID » du fournisseur d'identité ayant identifié l'utilisateur en cours</p></td>
206
    </tr>
207
    <tr>
208
      <td><p><code>session_saml_name_id</code></p></td>
209
      <td><p>Le Name ID de l'utilisateur en cours</p></td>
210
    </tr>
211
    <tr>
212
      <td><p><code>session_saml_name_id_format</code></p></td>
213
      <td><p>Le format de Name ID de l'utilisateur en cours</p></td>
214
    </tr>
215
    <tr>
216
      <td><p><code>session_saml_session_index</code></p></td>
217
      <td><p>Le numéro de session SAML</p></td>
218
    </tr>
219
    <tr>
220
      <td><p><code>session_saml_attribute_xxx</code></p></td>
221
      <td><p>L'attribut SAML « xxx »</p></td>
222
    </tr>
223
  </table>
224
  </section>
225

  
195 226
</section>
196 227

  
197 228
</page>
wcs/qommon/publisher.py
532 532
        self.substitutions.reset()
533 533
        self.substitutions.feed(self)
534 534
        self.substitutions.feed(request)
535
        session = get_session()
536
        if session is not None:
537
            self.substitutions.feed(session)
535 538
        for extra_source in self.extra_sources:
536 539
            self.substitutions.feed(extra_source(self, request))
537 540
        return Publisher.try_publish(self, request)
wcs/qommon/saml2.ptl
305 305
                # is not normal
306 306
                pass
307 307
        session.lasso_identity_provider_id = login.remoteProviderId
308

  
308
        attributes = {}
309
        for attribute in assertion.attributeStatement[0].attribute:
310
            attributes[attribute.name] = [ value.any[0].content
311
                    for value attribute.attributeValue ]
312
        session.saml = {
313
                'idp_entity_id': login.remoteProviderId,
314
                'session_index': getattr(session, 'lasso_session_index', ''),
315
                'name_id_format': login.nameIdentifier.format,
316
                'name_id': login.nameIdentifier.content,
317
                'attributes': attributes,
318
        }
309 319
        response = get_response()
310 320
        if session.after_url:
311 321
            after_url = session.after_url
wcs/qommon/sessions.py
289 289
                session_indexes):
290 290
            return session
291 291
        return None
292

  
293
    def get_substitution_variables(self, prefix='session_')
294
        d = {prefix+'saml': False}
295
        # saml attributes
296
        if hasattr(self, 'saml'):
297
            d[prefix+'saml'] = True
298
            for key in self.saml:
299
                if key == 'attributes':
300
                    for attribute_name in self.saml['attributes']:
301
                        values = self.saml['attributes'][attribute_name]
302
                        d[prefix + 'saml_attribute_' + key.replace('-', '_')] = values
303
                else:
304
                    d[prefix + 'saml_' + key] = self.saml[key]
305
        return d
292
-