informatique:securite:authentic

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
informatique:securite:authentic [2021/10/07 14:36] – [Authentic] bn8informatique:securite:authentic [2021/10/07 14:41] – [Authentic] bn8
Ligne 1: Ligne 1:
 ====== Authentic ====== ====== Authentic ======
 +
 +**Doc officielle (en partie obsolète) :** https://authentic2.readthedocs.io/en/latest/
  
 ===== Configuration d'une application cliente CAS ===== ===== Configuration d'une application cliente CAS =====
Ligne 21: Ligne 23:
       * ''LDAP'' : attributs récupérés directement depuis l'annuaire LDAP qui peuvent être mono-valués ou multi-valués.       * ''LDAP'' : attributs récupérés directement depuis l'annuaire LDAP qui peuvent être mono-valués ou multi-valués.
       * pas de suffixe entre parenthèses : il s'agit le plus souvent d'attributs générés à la voler par Authentic, soit en fonction d'une méthode issue de la configuration (voir paramètre ''ATTRIBUTE_SOURCES''), soit d'attributs standard prévus par Authentic.       * pas de suffixe entre parenthèses : il s'agit le plus souvent d'attributs générés à la voler par Authentic, soit en fonction d'une méthode issue de la configuration (voir paramètre ''ATTRIBUTE_SOURCES''), soit d'attributs standard prévus par Authentic.
 +
 +===== Génération d'attributs à la volée =====
 +
 +Authentic permet d'écrire soi-même la méthode de génération d'attributs qui seront ensuite diffusables aux services utilisant le SSO. Pour cela, il faut les déclarer dans la variable de configuration ''ATTRIBUTE_SOURCES'' comme suit :
 +
 +<code python>
 +def generate_fullname(ctx):
 +    return ctx['user'].attributes.first_name + " " + ctx['user'].attributes.last_name
 +
 +ATTRIBUTE_SOURCES = [
 +    ('function', {
 +        'name': 'fullname',
 +        'dependencies': ['user'],
 +        'function': generate_fullname
 +    }),
 +]
 +</code>
 +
 +<note tip>''ctx['user'].attributes'' permet d'accéder uniquement aux attributs synchronisés dans Authentic, pas aux attributs LDAP. Pour accéder à un attribut LDAP, il faut passer par la méthode ''get_attributes()'' : <code python>attrs = ctx['user'].get_attributes(None, ctx)
 +return attrs.get('edupersonaffiliation', [])</code>
 +</note>
 +
 +**Exemple complet pour la génération de l'attribut //eduPersonScopedAffiliation// :**
 +<code python>
 +import logging
 +
 +log = logging.getLogger('config')
 +
 +def generate_eduPersonScopedAffiliation(ctx):
 +    attrs = ctx['user'].get_attributes(None, ctx)
 +    if 'edupersonaffiliation' not in attrs:
 +        log.warning('generate_eduPersonScopedAffiliation: no edupersonaffiliation attribute found')
 +        return []
 +
 +    domain = os.environ.get('EDU_SCOPED_AFFILIATION_DOMAIN')
 +    if not domain:
 +        log.warning('generate_eduPersonScopedAffiliation: EDU_SCOPED_AFFILIATION_DOMAIN not found in env')
 +        return []
 +
 +    log.debug('generate_eduPersonScopedAffiliation: edupersonaffiliation = %s / domain = %s', attrs['edupersonaffiliation'], domain)
 +    return ["%s@%s" % (aff, domain) for aff in attrs['edupersonaffiliation']]
 +
 +ATTRIBUTE_SOURCES = [
 +    ('function', {
 +        'name': 'eduPersonScopedAffiliation',
 +        'dependencies': ['user'],
 +        'function': generate_eduPersonScopedAffiliation
 +    }),
 +]
 +</code>
 +
  
  
  • informatique/securite/authentic.txt
  • Dernière modification : 2022/02/16 19:06
  • de bn8