Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Fixes for Drupal roles map and docs #1208

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ext/drupal/7.x/pydio/class.DrupalPydio.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct( $params )
* @return boolean True on success
* @since 1.5
*/
public function onLoginUser($name, $password)
public function onLoginUser($name, $password, $roles)
{
// Initialize variables
$success = false;
Expand All @@ -33,7 +33,7 @@ public function onLoginUser($name, $password)
$AJXP_GLUE_GLOBALS["secret"] = $this->secret;
$AJXP_GLUE_GLOBALS["autoCreate"] = $this->autoCreate;
$AJXP_GLUE_GLOBALS["plugInAction"] = "login";
$AJXP_GLUE_GLOBALS["login"] = array("name"=>$name, "password"=>"");
$AJXP_GLUE_GLOBALS["login"] = array("name"=>$name, "password"=>"", "roles"=>$roles);

include($this->glueCode);
return true;
Expand Down Expand Up @@ -77,7 +77,7 @@ public function onLogout($user)
* @param boolean true if user was succesfully stored in the database
* @param string message
*/
public function onAfterStoreUser($name, $password, $isAdmin, $isnew)
public function onAfterStoreUser($name, $password, $roles, $isnew)
{
// convert the user parameters passed to the event
// to a format the external application
Expand All @@ -87,10 +87,12 @@ public function onAfterStoreUser($name, $password, $isAdmin, $isnew)
//global $plugInAction, $result, $secret, $user;
$AJXP_GLUE_GLOBALS["secret"] = $this->secret;

$isAdmin = in_array('administrator', $roles);
$AJXP_GLUE_GLOBALS["user"] = array();
$AJXP_GLUE_GLOBALS["user"]['name'] = $name;
$AJXP_GLUE_GLOBALS["user"]['password'] = $password;
$AJXP_GLUE_GLOBALS["user"]['right'] = ($isAdmin?'admin':'');
$AJXP_GLUE_GLOBALS["user"]['roles'] = $roles;
$AJXP_GLUE_GLOBALS["plugInAction"] = ($isnew?"addUser":"updateUser");

include($this->glueCode);
Expand Down
16 changes: 10 additions & 6 deletions ext/drupal/7.x/pydio/pydio.module
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function pydio_user_delete($account){
}


function pydio_map_roles($role) {
return user_role_load($role)->name;
}

function pydio_user_func($op, &$edit, $account, $category = null){
require_once("class.DrupalPydio.php");
Expand All @@ -50,24 +53,25 @@ function pydio_user_func($op, &$edit, $account, $category = null){
"ajxp_auto_create" => (variable_get('pydio_auto_create', "0") == "0"?true:false)
);
$drupHandler = new DrupalPydio($params);

$roles = array_map("pydio_map_roles", array_keys($account->roles));

if(!$drupHandler->glueCodeFound) return ;
switch ($op) {
case "login":
$drupHandler->onLoginUser($edit["input"]["name"], $edit["input"]["pass"]);
$drupHandler->onLoginUser($edit["input"]["name"], $edit["input"]["pass"], $roles);
break;

case "logout":
$drupHandler->onLogout($account);
break;

case "insert":
$admin = in_array('3', array_values($account->roles)) || in_array('administrator', array_values($account->roles));
$result = $drupHandler->onAfterStoreUser($edit['name'], $edit['pass'], $admin, true);
$result = $drupHandler->onAfterStoreUser($account->name, $account->pass, $roles, true);
break;

case "update":
$admin = in_array('3', array_values($account->roles)) || in_array('administrator', array_values($account->roles));
$result = $drupHandler->onAfterStoreUser($account->name, $account->pass, $admin, false);
$result = $drupHandler->onAfterStoreUser($account->name, $account->pass, $roles, false);
break;

case "delete":
Expand Down Expand Up @@ -127,4 +131,4 @@ function pydio_admin() {
);

return system_settings_form($form);
}
}
17 changes: 8 additions & 9 deletions ext/drupal/Drupal.Pydio-HOWTO.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3>2/ Pydio configuration</h3>
done, with the standard pydio authentication mechanism, be sure
that at least an "admin" user is created.</p><p>If you intend to allow
guest browsing, set the "Allow Guest Browsing" option to
true in the Pydio Settings &gt; Global Options &gt; Core Options &gt; Authentication, and if you are logged, log out. This should create the
true in the Pydio Settings &gt; Application Options &gt; Application Core &gt; Authentication, and if you are logged, log out. This should create the
"guest" user. As admin, log back to the interface and
create a "Guest" Repository. Go to the users section and
grant access (read only may be better) to this repository to the
Expand All @@ -27,8 +27,8 @@ <h3>2/ Pydio configuration</h3>
users. Considering the acces rights, the trick here would be to set a "Default Right" value to "rw", so that you don't have to
manually edit the users rights each time you add them.</p>

<p><strong>2.4 Auth.remote configuration</strong></p><p><strong></strong><span style="font-weight: normal;">Logged as admin, go to </span>Settings &gt; Global Options &gt; Core Options &gt; Authentication,<span style="font-weight: normal;"> </span><span style="font-style: normal;"><span style="font-weight: normal;"></span></span><span style="font-weight: normal;">and set the
Authentication "Main Instance" driver to be the "Remote Authentication" ( = auth.remote plugin)</span><span style="font-weight: normal;"> :<span style="font-family: monospace;"><br></span></span></p><ul><li>Choose the CMS Type "Drupal"</li><li>Enter your Drupal installation full URL (e.g. http://domain.tld/drupal)</li><li>Leave the Login URL to default "/" , except if no login form can be found on your drupal home page.</li><li>Leave the Auth Form ID to default "user-login-form", except if the login form on your drupal home page has not as html ID this string. You can check that using the HTML inspector of your favorite browser.</li><li>Exit Action: either leads back to drupal page, or triggers a log out.</li><li>Local Prefix: force some users with specific prefix to be stored and authenticated locally (not against drupal).</li><li>Secret Key: this will be a string that both side (pydio &amp; drupal) will share to recognize each other</li><li>Login Redirect: if set to a given page URL, when arriving on pydio, a not-logged guest will be directly redirected to this page.</li><li>Admin Login: make sure a specific user will be recognized as administrator by Pydio.<br></li></ul>
<p><strong>2.4 Auth.remote configuration</strong></p><p><strong></strong><span style="font-weight: normal;">Logged as admin, go to </span>Settings &gt; Application Options &gt; Application Core &gt; Authentication,<span style="font-weight: normal;"> </span><span style="font-style: normal;"><span style="font-weight: normal;"></span></span><span style="font-weight: normal;">and set the
Authentication "Main Instance" driver to be the "Remote Authentication" ( = auth.remote plugin)</span><span style="font-weight: normal;"> :<span style="font-family: monospace;"><br></span></span></p><ul><li>Choose the CMS Type "Drupal"</li><li>Enter your Drupal installation full URL (e.g. http://domain.tld/drupal)</li><li>Leave the Login URL to default "/" , except if no login form can be found on your drupal home page.</li><li>Leave the Auth Form ID to default "user-login". Your drupal installation may use a different ID for the login form. (Drupal 6 used user-login-form and other login modules may use something else.) You can check that using the HTML inspector of your favorite browser.</li><li>Exit Action: either leads back to drupal page, or triggers a log out.</li><li>Local Prefix: force some users with specific prefix to be stored and authenticated locally (not against drupal).</li><li>Secret Key: this will be a string that both side (pydio &amp; drupal) will share to recognize each other</li><li>Roles Map: This string will map your drupal roles to pydio roles when users are created and updated. The format is "DrupalRole:PydioRole,DrupalRole2:PydioRole2". Members of the administrator role will automatically map to administrator users in pydio.</li><li>Login Redirect: if set to a given page URL, when arriving on pydio, a not-logged guest will be directly redirected to this page.</li><li>Admin Login: make sure a specific user will be recognized as administrator by Pydio.<br></li></ul>
<p>Other options should be left to default values, otherwise put your mouse on the options label to get more info. For the secret key, warning, if you want to use a "$" sign in
your key, you have to put a \ before.</p><p>Also make sure NOT to set a secondary instance, this plugin does not support multi-auth configuration yet.<br></p>

Expand All @@ -39,8 +39,8 @@ <h3>3/ Drupal Configuration</h3>
"Pydio Bridge" module under the "Other"
section. Enable the plugin.</p>
<p><strong>3.2 Configure the module</strong></p><p><strong></strong>Go to "Site
Configuration &gt; Pydio Settings" (click on the module
"Help" for v7). There are three parameters to configure for
Configuration &gt; Pydio Settings" or for Drupal 7 Click the "Pydio Settings" link
under the admin menu. There are three parameters to configure for
this plugin :&nbsp;</p>
<ul>
<li><p style="margin-bottom: 0cm;"><strong>Pydio Install Path</strong>
Expand All @@ -59,10 +59,9 @@ <h3>3/ Drupal Configuration</h3>
specially if you are installing this "bridge" when already
managing many users in a Drupal installation. By default ("no"),
Users will be created in Pydio only by a Drupal administrator
action of creating a Drupal users. Existing users will not be
recognized by Pydio. If you set to "Auto create",
existing users will be automatically created when a user logs in to
Drupal.
action of creating a Drupal user. Existing users will not be
recognized by Pydio. If you enable "Auto create", existing users
will be automatically created when a user logs in to Drupal.
</p>
</li></ul>
<p>Save the module configuration.</p>
Expand Down