本文整理汇总了PHP中Magento\Framework\AuthorizationInterface类的典型用法代码示例。如果您正苦于以下问题:PHP AuthorizationInterface类的具体用法?PHP AuthorizationInterface怎么用?PHP AuthorizationInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuthorizationInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: isDisplayed
/**
* Check whether survey question can show
*
* @return bool
*/
public function isDisplayed()
{
if ($this->_authSession->getHideSurveyQuestion() || false == $this->_authorization->isAllowed(null) || $this->_survey->isSurveyViewed() || false == $this->_survey->isSurveyUrlValid()) {
return false;
}
return true;
}
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Survey.php
示例2: __call
/**
* Handler for all SOAP operations.
*
* @param string $operation
* @param array $arguments
* @return \stdClass|null
* @throws WebapiException
* @throws \LogicException
* @throws AuthorizationException
*/
public function __call($operation, $arguments)
{
$requestedServices = $this->_request->getRequestedServices();
$serviceMethodInfo = $this->_apiConfig->getServiceMethodInfo($operation, $requestedServices);
$serviceClass = $serviceMethodInfo[SoapConfig::KEY_CLASS];
$serviceMethod = $serviceMethodInfo[SoapConfig::KEY_METHOD];
// check if the operation is a secure operation & whether the request was made in HTTPS
if ($serviceMethodInfo[SoapConfig::KEY_IS_SECURE] && !$this->_request->isSecure()) {
throw new WebapiException(__("Operation allowed only in HTTPS"));
}
$isAllowed = false;
foreach ($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES] as $resource) {
if ($this->_authorization->isAllowed($resource)) {
$isAllowed = true;
break;
}
}
if (!$isAllowed) {
throw new AuthorizationException(__(AuthorizationException::NOT_AUTHORIZED, ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])]));
}
$service = $this->_objectManager->get($serviceClass);
$inputData = $this->_prepareRequestData($serviceClass, $serviceMethod, $arguments);
$outputData = call_user_func_array([$service, $serviceMethod], $inputData);
return $this->_prepareResponseData($outputData, $serviceClass, $serviceMethod);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:35,代码来源:Handler.php
示例3: aroundDispatch
/**
* Replace standard admin login form with HTTP Basic authentication
*
* @param AbstractAction $subject
* @param callable $proceed
* @param RequestInterface $request
* @return ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function aroundDispatch(AbstractAction $subject, \Closure $proceed, RequestInterface $request)
{
$resource = isset($this->aclResources[$request->getControllerName()]) ? isset($this->aclResources[$request->getControllerName()][$request->getActionName()]) ? $this->aclResources[$request->getControllerName()][$request->getActionName()] : $this->aclResources[$request->getControllerName()] : null;
$type = $request->getParam('type');
$resourceType = isset($this->aclResources[$type]) ? $this->aclResources[$type] : null;
if (!$resource || !$resourceType) {
return parent::aroundDispatch($subject, $proceed, $request);
}
$session = $this->_auth->getAuthStorage();
// Try to login using HTTP-authentication
if (!$session->isLoggedIn()) {
list($login, $password) = $this->httpAuthentication->getCredentials();
try {
$this->_auth->login($login, $password);
} catch (AuthenticationException $e) {
$this->logger->critical($e);
}
}
// Verify if logged in and authorized
if (!$session->isLoggedIn() || !$this->authorization->isAllowed($resource) || !$this->authorization->isAllowed($resourceType)) {
$this->httpAuthentication->setAuthenticationFailed('RSS Feeds');
return $this->_response;
}
return parent::aroundDispatch($subject, $proceed, $request);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:BackendAuthentication.php
示例4: getUrl
/**
* Generate row url
* @param \Magento\Framework\DataObject $item
* @return bool|string
*/
public function getUrl($item)
{
if ($this->_authorization->isAllowed('Magento_Sales::actions_view')) {
return parent::getUrl($item);
}
return false;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:UrlGenerator.php
示例5: getUrl
/**
* Create url for passed item using passed url model
* @param \Magento\Framework\Object $item
* @return string
*/
public function getUrl($item)
{
if ($this->_authorization->isAllowed('Magento_Customer::manage') && $item->getCustomerId()) {
return parent::getUrl($item);
}
return false;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:UrlGenerator.php
示例6: update
/**
* Remove massaction items in case they disallowed for user
* @param mixed $argument
* @return mixed
*/
public function update($argument)
{
if (false === $this->authorization->isAllowed('Magento_Indexer::changeMode')) {
unset($argument['change_mode_onthefly']);
unset($argument['change_mode_changelog']);
}
return $argument;
}
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:ItemsUpdater.php
示例7: execute
/**
* Block admin ability to use customer billing agreements
*
* @param EventObserver $observer
* @return void
*/
public function execute($observer)
{
$event = $observer->getEvent();
$methodInstance = $event->getMethodInstance();
if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement && false == $this->_authorization->isAllowed('Magento_Paypal::use')) {
$event->getResult()->isAvailable = false;
}
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:14,代码来源:RestrictAdminBillingAgreementUsage.php
示例8: canAddAttributes
/**
* @return boolean
*/
protected function canAddAttributes()
{
$isWrapped = $this->registry->registry('use_wrapper');
if (!isset($isWrapped)) {
$isWrapped = true;
}
return $isWrapped && $this->authorization->isAllowed('Magento_Catalog::attributes_attributes');
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:11,代码来源:Attributes.php
示例9: getButtonData
/**
* @return array
*/
public function getButtonData()
{
$customerId = $this->getCustomerId();
$data = [];
if ($customerId && $this->authorization->isAllowed('Magento_Sales::create')) {
$data = ['label' => __('Create Order'), 'on_click' => sprintf("location.href = '%s';", $this->getCreateOrderUrl()), 'class' => 'add', 'sort_order' => 40];
}
return $data;
}
开发者ID:tingyeeh,项目名称:magento2,代码行数:12,代码来源:OrderButton.php
示例10: isAllowed
/**
* Check if all ACL resources are allowed to be accessed by current API user.
*
* @param string[] $aclResources
* @return bool
*/
public function isAllowed($aclResources)
{
foreach ($aclResources as $resource) {
if (!$this->authorization->isAllowed($resource)) {
return false;
}
}
return true;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Authorization.php
示例11: execute
/**
* Block admin ability to use customer billing agreements
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
$event = $observer->getEvent();
$methodInstance = $event->getMethodInstance();
if ($methodInstance instanceof \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement && false == $this->_authorization->isAllowed('Magento_Paypal::use')) {
/** @var \Magento\Framework\DataObject $result */
$result = $observer->getEvent()->getResult();
$result->setData('is_available', false);
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:RestrictAdminBillingAgreementUsageObserver.php
示例12: getButtonData
/**
* @return array
*/
public function getButtonData()
{
$customerId = $this->getCustomerId();
$data = [];
$canModify = $customerId && $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button');
if ($canModify) {
$data = ['label' => __('Login As Customer'), 'class' => 'login login-button', 'on_click' => 'window.open( \'' . $this->getInvalidateTokenUrl() . '\')', 'sort_order' => 70];
}
return $data;
}
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:13,代码来源:Login.php
示例13: testExecute
/**
* @param object $methodInstance
* @param bool $isAllowed
* @param bool $isAvailable
* @dataProvider restrictAdminBillingAgreementUsageDataProvider
*/
public function testExecute($methodInstance, $isAllowed, $isAvailable)
{
$this->_event->setMethodInstance($methodInstance);
$this->_authorization->expects($this->any())->method('isAllowed')->with('Magento_Paypal::use')->will($this->returnValue($isAllowed));
$result = new \stdClass();
$result->isAvailable = true;
$this->_event->setResult($result);
$this->_model->execute($this->_observer);
$this->assertEquals($isAvailable, $result->isAvailable);
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:16,代码来源:RestrictAdminBillingAgreementUsageTest.php
示例14: prepareDataSource
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$hidden = !$this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button');
foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')]['edit'] = ['href' => $this->urlBuilder->getUrl('loginascustomer/login/login', ['customer_id' => $item['entity_id']]), 'label' => __('Login As Customer'), 'hidden' => $hidden, 'target' => '_blank'];
}
}
return $dataSource;
}
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:16,代码来源:Actions.php
示例15: filterAclElements
/**
* Delete elements that have "acl" attribute but value is "not allowed"
* In any case, the "acl" attribute will be unset
*
* @param ScheduledStructure $scheduledStructure
* @param Structure $structure
*/
public function filterAclElements(ScheduledStructure $scheduledStructure, Structure $structure)
{
foreach ($scheduledStructure->getElements() as $name => $data) {
list(, $data) = $data;
if (isset($data['attributes']['acl']) && $data['attributes']['acl']) {
if (!$this->authorization->isAllowed($data['attributes']['acl'])) {
$this->removeElement($scheduledStructure, $structure, $name);
}
}
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Acl.php
示例16: filterAclNodes
/**
* Delete nodes that have "acl" attribute but value is "not allowed"
* In any case, the "acl" attribute will be unset
*
* @param \Magento\Framework\Simplexml\Element $xml
* @return void
*/
public function filterAclNodes(\Magento\Framework\Simplexml\Element $xml)
{
$limitations = $xml->xpath('//*[@acl]') ?: array();
foreach ($limitations as $node) {
if (!$this->_authorization->isAllowed($node['acl'])) {
$node->unsetSelf();
} else {
unset($node['acl']);
}
}
}
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Acl.php
示例17: testFilterAclElements
public function testFilterAclElements()
{
$scheduledStructureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure')->disableOriginalConstructor()->getMock();
$structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Data\\Structure')->disableOriginalConstructor()->getMock();
$elements = ['element_0' => [0 => '', 1 => ['attributes' => ['name' => 'element_0']]], 'element_1' => [0 => '', 1 => ['attributes' => ['name' => 'element_1', 'acl' => 'acl_authorised']]], 'element_2' => [0 => '', 1 => ['attributes' => ['name' => 'element_2', 'acl' => 'acl_non_authorised']]], 'element_3' => [0 => '', 1 => ['attributes' => ['name' => 'element_3', 'acl' => 'acl_non_authorised']]]];
$scheduledStructureMock->expects($this->once())->method('getElements')->willReturn($elements);
$this->authorizationMock->expects($this->exactly(3))->method('isAllowed')->willReturnMap([['acl_authorised', null, true], ['acl_non_authorised', null, false]]);
$structureMock->expects($this->exactly(3))->method('getChildren')->willReturnMap([['element_2', ['element_2_child' => []]], ['element_2_child', []], ['element_3', []]]);
$scheduledStructureMock->expects($this->exactly(3))->method('unsetElement')->willReturnMap([['element_2', null], ['element_2_child', null], ['element_3', null]]);
$structureMock->expects($this->exactly(2))->method('unsetElement')->willReturnMap([['element_2', true, true], ['element_3', true, true]]);
$this->model->filterAclElements($scheduledStructureMock, $structureMock);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:AclTest.php
示例18: update
/**
* Remove massaction items in case they disallowed for user
* @param mixed $argument
* @return mixed
*/
public function update($argument)
{
if (false === $this->_authorization->isAllowed('Magento_Sales::cancel')) {
unset($argument['cancel_order']);
}
if (false === $this->_authorization->isAllowed('Magento_Sales::hold')) {
unset($argument['hold_order']);
}
if (false === $this->_authorization->isAllowed('Magento_Sales::unhold')) {
unset($argument['unhold_order']);
}
return $argument;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:ItemsUpdater.php
示例19: execute
/**
* Force admin to change password
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
if (!$this->observerConfig->isPasswordChangeForced()) {
return;
}
if (!$this->authSession->isLoggedIn()) {
return;
}
$actionList = ['adminhtml_system_account_index', 'adminhtml_system_account_save', 'adminhtml_auth_logout'];
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getEvent()->getControllerAction();
/** @var \Magento\Framework\App\RequestInterface $request */
$request = $observer->getEvent()->getRequest();
if ($this->authSession->getPciAdminUserIsPasswordExpired()) {
if (!in_array($request->getFullActionName(), $actionList)) {
if ($this->authorization->isAllowed('Magento_Backend::myaccount')) {
$controller->getResponse()->setRedirect($this->url->getUrl('adminhtml/system_account/'));
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_POST_DISPATCH, true);
} else {
/*
* if admin password is expired and access to 'My Account' page is denied
* than we need to do force logout with error message
*/
$this->authSession->clearStorage();
$this->session->clearStorage();
$this->messageManager->addErrorMessage(__('Your password has expired; please contact your administrator.'));
$controller->getRequest()->setDispatched(false);
}
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:ForceAdminPasswordChangeObserver.php
示例20: isAllowed
/**
* Check whether item is allowed to the user
*
* @return bool
*/
public function isAllowed()
{
try {
return $this->_acl->isAllowed((string) $this->_resource);
} catch (\Exception $e) {
return false;
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Item.php
注:本文中的Magento\Framework\AuthorizationInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论