Skip to content
This repository was archived by the owner on Apr 27, 2022. It is now read-only.

Commit 5c1ae94

Browse files
committedSep 18, 2017
no need check access if graphql action in CompositeAuth except
1 parent 4edcb7e commit 5c1ae94

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed
 

‎src/GraphQLAction.php

+17-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GraphQLAction extends Action
3939
/**
4040
* @var array child graphql actions
4141
*/
42-
private $actions = [];
42+
private $authActions = [];
4343
/**
4444
* @var callable a PHP callable that will be called when running an action to determine
4545
* if the current user has the permission to execute the action. If not set, the access
@@ -95,10 +95,21 @@ public function getGraphQLActions()
9595
if ($this->schemaArray === true) {
9696
return [self::INTROSPECTIONQUERY => 'true'];
9797
}
98-
if (!$this->actions) {
99-
$this->actions = array_merge($this->schemaArray[0], $this->schemaArray[1]);
98+
$ret = array_merge($this->schemaArray[0], $this->schemaArray[1]);
99+
if (!$this->authActions) {
100+
//init
101+
$this->authActions = array_merge($this->schemaArray[0], $this->schemaArray[1]);
100102
}
101-
return $this->actions;
103+
return $ret;
104+
}
105+
106+
/**
107+
* remove action that no need check access
108+
* @param $key
109+
*/
110+
public function removeGraphQlAction($key)
111+
{
112+
unset($this->authActions[$key]);
102113
}
103114

104115
/**
@@ -111,8 +122,8 @@ public function run()
111122
//调度状态下将执行构建查询
112123
$this->controller->module->enableValidation();
113124
}
114-
if ($this->actions && $this->checkAccess) {
115-
foreach ($this->actions as $childAction) {
125+
if ($this->authActions && $this->checkAccess) {
126+
foreach ($this->authActions as $childAction) {
116127
call_user_func($this->checkAccess, $childAction);
117128
}
118129
}

‎src/filters/auth/CompositeAuth.php

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ protected function isActive($action)
9696
foreach ($maps as $key => $value) {
9797
foreach ($this->except as $pattern) {
9898
if (fnmatch($pattern, $key)) {
99+
$action->removeGraphQlAction($key);
99100
continue 2;
100101
}
101102
}

0 commit comments

Comments
 (0)
This repository has been archived.