This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement RestAPI token-based authentication. Last todo is to check t…
…he nonce is never reused. Add ORDER parameter in auth frontends plugins to make sure they are called in the correct order. Introduce a specific /pydio/ path to query API for non-workspaces actions. To be documented and checked when generating workspace slugs.
- Loading branch information
Showing
11 changed files
with
314 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ajxpcore id="authfront.http_basic" enabled="false" label="CONF_MESSAGE[Basic Http FrontEnd]" description="CONF_MESSAGE[Send a basic http request to the user]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd"> | ||
<class_definition filename="plugins/authfront.http_basic/class.BasicHttpAuthFrontend.php" classname="BasicHttpAuthFrontend"/> | ||
<server_settings> | ||
<global_param name="ORDER" type="integer" label="Order" description="Order this plugin with other auth frontends" default="2"/> | ||
</server_settings> | ||
</ajxpcore> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ajxpcore id="authfront.keystore" label="CONF_MESSAGE[Basic Http by Server]" enabled="true" description="CONF_MESSAGE[Basic Http Auth performed by server (e.g. apache htaccess)]" | ||
<ajxpcore id="authfront.keystore" label="CONF_MESSAGE[API Keystore]" enabled="true" description="CONF_MESSAGE[Store API keys/token to simplify REST connection]" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd"> | ||
<class_definition filename="plugins/authfront.keystore/class.KeystoreAuthFrontend.php" classname="KeystoreAuthFrontend"/> | ||
<client_settings> | ||
<resources> | ||
<js className="ApikeysPane" file="plugins/authfront.keystore/class.ApikeysPane.js" autoload="true"/> | ||
</resources> | ||
</client_settings> | ||
<server_settings> | ||
<global_param name="ORDER" type="integer" label="Order" | ||
description="Order this plugin with other auth frontends" default="3"/> | ||
</server_settings> | ||
<registry_contributions> | ||
<client_configs> | ||
<component_config className="AjxpTabulator::userdashboard_parameters_tab"> | ||
<additional_tab id="apikeys_pane" | ||
tabInfo='{"id":"my-api-data","iconClass":"icon-cog","element":"apikeys_pane","closeable":false,"label":"403","title":"403","dontFocus":true,"position":2}' | ||
paneInfo='{"type":"widget"}'><![CDATA[ | ||
<div id="apikeys_pane" ajxpClass="ApikeysPane" class="tabbed_editor"> | ||
<div id="generate_token_button">Generate new tokens!</div> | ||
<div id="token_results"></div> | ||
<div id="revoke_tokens_button">Revoke existing token!</div> | ||
</div> | ||
]]></additional_tab> | ||
</component_config> | ||
</client_configs> | ||
<actions> | ||
<action name="keystore_generate_auth_token"> | ||
<rightsContext adminOnly="false" noUser="false" read="false" userLogged="true" write="false"/> | ||
<processing> | ||
<serverCallback methodName="authTokenActions" restParams="/device" sdkMethodName="generateAuthToken"/> | ||
</processing> | ||
</action> | ||
<action name="keystore_revoke_tokens"> | ||
<rightsContext adminOnly="false" noUser="false" read="false" userLogged="true" write="false"/> | ||
<processing> | ||
<serverCallback methodName="authTokenActions" restParams="/" sdkMethodName="generateAuthToken"/> | ||
</processing> | ||
</action> | ||
</actions> | ||
</registry_contributions> | ||
</ajxpcore> |
34 changes: 34 additions & 0 deletions
34
core/src/plugins/core.authfront/class.AbstractAuthFrontend.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/* | ||
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io> | ||
* This file is part of Pydio. | ||
* | ||
* Pydio is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Pydio is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Pydio. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* The latest code can be found at <http://pyd.io/>. | ||
*/ | ||
defined('AJXP_EXEC') or die( 'Access not allowed'); | ||
|
||
abstract class AbstractAuthFrontend extends AJXP_Plugin { | ||
|
||
/** | ||
* Try to authenticate the user based on various external parameters | ||
* Return true if user is now logged. | ||
* | ||
* @param bool $isLast Whether this is is the last plugin called. | ||
* @return bool | ||
*/ | ||
abstract function tryToLogUser($isLast = false); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/* | ||
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io> | ||
* This file is part of Pydio. | ||
* | ||
* Pydio is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Pydio is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Pydio. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* The latest code can be found at <http://pyd.io/>. | ||
*/ | ||
defined('AJXP_EXEC') or die( 'Access not allowed'); | ||
|
||
class FrontendsLoader extends AJXP_Plugin { | ||
|
||
public function init($options){ | ||
|
||
parent::init($options); | ||
|
||
// Load all enabled frontend plugins | ||
$fronts = AJXP_PluginsService::getInstance()->getPluginsByType("authfront"); | ||
usort($fronts, array($this, "frontendsSort")); | ||
foreach($fronts as $front){ | ||
if($front->isEnabled()){ | ||
AJXP_PluginsService::setPluginActive($front->getType(), $front->getName(), true); | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @param AJXP_Plugin $a | ||
* @param AJXP_Plugin $b | ||
* @return int | ||
*/ | ||
public function frontendsSort($a, $b){ | ||
$aConf = $a->getConfigs(); | ||
$bConf = $b->getConfigs(); | ||
$orderA = intval($aConf["ORDER"]); | ||
$orderB = intval($bConf["ORDER"]); | ||
if($orderA == $orderB) return 0; | ||
return $orderA > $orderB ? 1 : -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ajxpcore id="core.authfront" label="CONF_MESSAGE[Authentification FrontEnd]" | ||
description="CONF_MESSAGE[Actual way to authenticate users (via credentials, certificates, http, etc]" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd"> | ||
<class_definition classname="FrontendsLoader" filename="plugins/core.authfront/class.FrontendsLoader.php"/> | ||
</ajxpcore> |
Oops, something went wrong.