• Resolved rleguede

    (@rleguede)


    Bonjour,

    Je reviens vers vous pour comprendre comment fonctionne les attributs.
    J’utilise un serveur CAS avec protocole 2.0, qui fait appel à un LDAP. J’aimerais récupérer des attributs de ce LDAP quand un utilisateur s’identifie (tel que Nom, Prénom, mail, Société).

    J’ai utilisé le champs “Cas user attributes you want to populate into session.” pour appeler les attributs que je souhaite récupérer.
    Au préalable, j’ai modifié sur mon CAS pour lui spécifier de partager les attributs concernés (fichier deployerConfigContext.xml).

    Quand je lance une authentification, j’obtiens dans la log d’erreur le message suivant :
    “PHP Warning: Invalid argument supplied for foreach() in C:\wamp64\www\comm\wp-content\plugins\wp-cassify\classes\wp_cassify_plugin.php on line 841”

    La ligne :
    “foreach ( $expiration_rules as $expiration_rule ) {
    …”

    Pouvez-vous m’expliquer à quoi correspond la variable $expiration_rules et comment l’utiliser ?

    Merci pour votre aide et explication,

    Cordialement

    https://wordpress.org/plugins/wp-cassify/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    CAS protocole version 2.0 is not able to populate attributes natively.
    So to do this, you must modify a view file located here tomcat8/webapps/cas/WEB-INF/view/jsp/protocol/2.0/casServiceValidationSuccess.jsp to include user attributes in CAS Server xml response. Modify the file like below :

    <!-- Recuperation des attributs utilisateurs -->
            <cas:attributes>
                    <c:forEach var="auth" items="${assertion.chainedAuthentications}">
                            <c:forEach var="attr" items="${auth.principal.attributes}" >
                                    <cas:${fn:escapeXml(attr.key)}>${fn:escapeXml(attr.value)}</cas:${fn:escapeXml(attr.key)}>
                            </c:forEach>
                    </c:forEach>
            </cas:attributes>
    
        </cas:authenticationSuccess>
    </cas:serviceResponse>

    You can check that attributes are sent by CAS Server with error_log debug function in wp_cassify_plugin.php in function wp_cassify_grab_service_ticket :

    error_log( print_r( $cas_server_xml_response, TRUE ) );

    Then, you can follow this screencast (POPULATE CAS USER ATTRIBUTE INTO SESSION) to access cas user attributes from you WordPress theme :https://wpcassify.wordpress.com/getting-started/

    Best regards.

    Thread Starter rleguede

    (@rleguede)

    Hi,

    Thanks you for your help. It’s working for one attribute !
    But if I ask for two or more attributes it doesn’t working (example with “displayName”).

    Error log :

    PHP Notice:  Undefined index:  displayName in C:\wamp64\www\comm\wp-content\plugins\wp-cassify\classes\wp_cassify_plugin.php on line 518
    
    PHP Stack trace:
     PHP   1. {main}() C:\wamp64\www\comm\index.php:0
     PHP   2. require() C:\wamp64\www\comm\index.php:17
     PHP   3. require_once() C:\wamp64\www\comm\wp-blog-header.php:12
     PHP   4. require_once() C:\wamp64\www\comm\wp-load.php:37
     PHP   5. require_once() C:\wamp64\www\comm\wp-config.php:89
     PHP   6. do_action() C:\wamp64\www\comm\wp-settings.php:392
     PHP   7. call_user_func_array:{C:\wamp64\www\comm\wp-includes\plugin.php:525}() C:\wamp64\www\comm\wp-includes\plugin.php:525
     PHP   8. wp_cassify\WP_Cassify_Plugin->wp_cassify_grab_service_ticket() C:\wamp64\www\comm\wp-includes\plugin.php:525
     PHP   9. wp_cassify\WP_Cassify_Plugin->wp_cassify_populate_attributes_into_session() C:\wamp64\www\comm\wp-content\plugins\wp-cassify\classes\wp_cassify_plugin.php:311

    wp_cassify_plugin.php on line 518 : it’s the foreach function on $cas_user_attributes_names

    foreach( $cas_user_attributes_names as $cas_user_attributes_name ) {
    					$cas_user_datas_filtered[ $cas_user_attributes_name ] = $cas_user_datas[ $cas_user_attributes_name ];
    				}

    Any idea what is the problem here ?

    Thank you very much

    Thread Starter rleguede

    (@rleguede)

    Oups.

    I check again my attributes on CAS server.
    It’s working for two attributes, the problem should come from some attributes on my server. Seems it’s not related to the plugin.

    Sorry about that, and again, thanks for your help.

    Ok,

    So i can close ticket ?

    Best regards

    Thread Starter rleguede

    (@rleguede)

    Hi,

    Yes you can close it, sorry for my late answer.

    Best regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘attributes into session’ is closed to new replies.