Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev WIP Lots of refactoring for Authentication and Authorization plug…
…ins.
- Loading branch information
Showing
69 changed files
with
788 additions
and
781 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
class AuthManager implements IAuthManager { | ||
/** | ||
* @var IAuthManager | ||
*/ | ||
public $authorizationPlugin; | ||
public function init() { | ||
$this->authorizationPlugin = App()->pluginManager->getPlugin(App()->getConfig('authorizationPlugin', 'ls_core_plugins_PermissionDb')); | ||
} | ||
public function addItemChild($itemName, $childName) { | ||
return $this->authorizationPlugin->addItemChild($itemName, $childName); | ||
} | ||
|
||
public function assign($itemName, $userId, $bizRule = null, $data = null) { | ||
return $this->authorizationPlugin->assign($itemName, $userId, $bizRule, $data); | ||
} | ||
|
||
public function checkAccess($itemName, $userId, $params = array()) { | ||
return $this->authorizationPlugin->checkAccess($itemName, $userId, $params); | ||
} | ||
|
||
public function clearAll() { | ||
return $this->authorizationPlugin->clearAll(); | ||
} | ||
|
||
public function clearAuthAssignments() { | ||
return $this->authorizationPlugin->clearAuthAssignments(); | ||
} | ||
|
||
public function createAuthItem($name, $type, $description = '', $bizRule = null, $data = null) { | ||
return $this->authorizationPlugin->createAuthItem($name, $type, $description, $bizRule, $data); | ||
} | ||
|
||
public function executeBizRule($bizRule, $params, $data) { | ||
return $this->authorizationPlugin->executeBizRule($bizRule, $params, $data); | ||
} | ||
|
||
public function getAuthAssignment($itemName, $userId) { | ||
return $this->authorizationPlugin->getAuthAssignment($itemName, $userId); | ||
} | ||
|
||
public function getAuthAssignments($userId) { | ||
return $this->authorizationPlugin->getAuthAssignments($userId); | ||
} | ||
|
||
public function getAuthItem($name) { | ||
return $this->authorizationPlugin->getAuthItem($name); | ||
} | ||
|
||
public function getAuthItems($type = null, $userId = null) { | ||
return $this->authorizationPlugin->getAuthItems($type, $userId); | ||
} | ||
|
||
public function getItemChildren($itemName) { | ||
return $this->authorizationPlugin->getItemChildren($itemName); | ||
} | ||
|
||
public function hasItemChild($itemName, $childName) { | ||
return $this->authorizationPlugin->hasItemChild($itemName, $childName); | ||
} | ||
|
||
public function isAssigned($itemName, $userId) { | ||
return $this->authorizationPlugin->isAssigned($itemName, $userId); | ||
} | ||
|
||
public function removeAuthItem($name) { | ||
return $this->authorizationPlugin->removeAuthItem($name); | ||
} | ||
|
||
public function removeItemChild($itemName, $childName) { | ||
return $this->authorizationPlugin->removeItemChild($itemName, $childName); | ||
} | ||
|
||
public function revoke($itemName, $userId) { | ||
return $this->authorizationPlugin->revoke($itemName, $userId); | ||
} | ||
|
||
public function save() { | ||
return $this->authorizationPlugin->save(); | ||
} | ||
|
||
public function saveAuthAssignment($assignment) { | ||
return $this->authorizationPlugin->saveAuthAssignment($assignment); | ||
} | ||
|
||
public function saveAuthItem($item, $oldName = null) { | ||
return $this->authorizationPlugin->saveAuthItem($item); | ||
} | ||
|
||
} |
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 | ||
|
||
/** | ||
* @property \ls\pluginmanager\PluginBase $plugin | ||
*/ | ||
class PluginIdentity extends CBaseUserIdentity { | ||
/** | ||
* | ||
* @var \ls\pluginmanager\AuthPluginBase | ||
*/ | ||
private $plugin; | ||
protected $_id; | ||
protected $_name; | ||
public function __construct(\ls\pluginmanager\AuthPluginBase $plugin) { | ||
$this->plugin = $plugin; | ||
} | ||
public function authenticate() { | ||
$result = $this->plugin->authenticate(Yii::app()->request); | ||
$this->setState('authenticationPlugin', $this->plugin->id); | ||
if (!isset($result)) { | ||
$this->errorCode = self::ERROR_PASSWORD_INVALID; | ||
} else { | ||
$this->errorCode = self::ERROR_NONE; | ||
if (is_array($result)) { | ||
$this->_name = $result['name']; | ||
$this->_id = $result['id']; | ||
unset($result['name']); | ||
unset($result['id']); | ||
$this->attributes = $result; | ||
} | ||
} | ||
return $this->errorCode === self::ERROR_NONE; | ||
} | ||
|
||
public function getId() { | ||
return $this->_id; | ||
} | ||
|
||
public function getName() { | ||
return $this->_name; | ||
} | ||
|
||
public function setAttributes($value) { | ||
return $this->setState('attributes', $value); | ||
} | ||
public function getAttributes() { | ||
return $this->getState('attributes', []); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
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
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
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
Oops, something went wrong.