Pages enfant
  • CASification de Dokuwiki

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Fichier conf/dokuwiki.php

Bloc de code

$conf['authtype']    = 'cas';

/* Ldap Options */
$conf['auth']['ldap']['server']      = 'ldap://ldap.univ.fr';
$conf['auth']['ldap']['usertree']    = 'ou=people,dc=univ,dc=fr';
$conf['auth']['ldap']['userfilter']  = '(uid=%{user})';

Fichier doku.php :

Bloc de code

  if ($ACT == 'login') {
    phpCAS::setFixedServiceURL(
      'http://www.univ.fr/wiki/doku.php?'.$_SERVER["QUERY_STRING"]);
    phpCAS::forceAuthentication();
  }

  if($ACT == 'logout') {
    phpCAS::logout();
  }

Fichier inc/auth/cas.class.php

Bloc de code

<?
require_once(DOKU_INC.'inc/auth/ldap.class.php');
include_once('CAS/CAS.php');

phpCAS::client(CAS_VERSION_2_0, 'cas.univ.fr', 443, 'cas');

class auth_cas extends auth_ldap {
    function auth_cas() {
        global $conf;
        $this->cando['external'] = true;
        $this->auth_ldap();
    }

    function trustExternal($user,$pass,$sticky=false){
        global $USERINFO;
        global $conf;
        $sticky ? $sticky = true : $sticky = false; //sanity check

        $session = $_SESSION[$conf['title']]['auth'];

        if(phpCAS::isAuthenticated()) {
            $user = phpCAS::getUser();

            if(isset($session)) {
                $_SERVER['REMOTE_USER'] = $user;
                $USERINFO = $session['info'];
                $_SESSION[$conf['title']]['auth']['user'] = $user;
                $_SESSION[$conf['title']]['auth']['pass'] = $session['pass'];
                $_SESSION[$conf['title']]['auth']['info'] = $USERINFO;
                $_SESSION[$conf['title']]['auth']['buid'] = $session['buid'];
            }
            else {
                $USERINFO = $this->getUserData($user);
                $_SERVER['REMOTE_USER'] = $user;
                $_SESSION[$conf['title']]['auth']['user'] = $user;
                $_SESSION[$conf['title']]['auth']['pass'] = $pass;
                $_SESSION[$conf['title']]['auth']['info'] = $USERINFO;
                $_SESSION[$conf['title']]['auth']['buid'] = auth_browseruid();
            }

            return true;
        }

        return false;
    }
}
?>

Pour forcer le login à l'appel de l'url de base du wiki : Fichier index.php :

Bloc de code

header("Location: doku.php?do=login");

...

ACL Dokuwiki basé sur attribut ldap

En plus d'une authentification CAS, il est possible d'utiliser le backend ldap (http://www.dokuwiki.org/auth:ldapImage Modified) afin de recuperer le groupe (ldap) de l'utilisateur connecté. Ainsi nous pouvons definir un acces granulaire (ACL) a differents namespaces/pages dokuwiki en fonction du groupe de l'utilisateur.

dans conf/local.php

Pas de format

$conf['auth']['ldap']['server'] = 'ldap://ldap.domain.tld:389';$conf['auth']['ldap']['port'] = '389';$conf['auth']['ldap']['usertree'] = 'ou=People, dc=domain,dc=tld';$conf['auth']['ldap']['grouptree'] = 'ou=Group, ou=system,dc=domain,dc=tld';$conf['auth']['ldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixAccount))';$conf['auth']['ldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUid=%{user})))';$conf['auth']['ldap']['binddn'] = 'cn=binder, ou=system,dc=domain,dc=tld';$conf['auth']['ldap']['bindpw'] = 'secret';$conf['auth']['ldap']['version'] = '3';