Closed (duplicate)
Project:
Drupal core
Version:
8.7.x-dev
Component:
routing system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Mar 2017 at 08:46 UTC
Updated:
7 Feb 2019 at 17:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
andrewbelcher commentedAdding to the above, it means that access checks can't use
AccessResult::forbiddenIf, as that returns a neutral if the condition is false...Comment #3
dawehnerHere is a test to just see whether its really the case that we return access.
Comment #4
andrewbelcher commentedSorry - my explanation probably wasn't clear enough. If there are access checks, we assume access and then every check has to either allow or forbid. I think if we expect all access checks to allow/forbid (with neutral being the same as forbid), then defaulting to allow is definitely the correct approach (and the only one).
It's more that I wonder if if would be better to start at neutral and use
orIfto allow access checks to allow/forbid/neutral (with neutral being nothing to say on the matter), in which case starting at allowed would be a problem.I've added a note to the summary to make that clearer.
Comment #5
spheresh commentedComment #7
andrewbelcher commented@spheresh, I don't think that is the right approach (and if is working correctly on the logic that is being implemented), it's
\Drupal\Core\Access\AccessManager::checkthat is potentially an issue.Comment #8
spheresh commentedPatch #5 breaks down a logic of Drupal\user\Access\LoginStatusCheck class at least :(
We can see that AccessManager::check will approve by default:
$result = AccessResult::allowed();to make sure that the method does not work properly enough, a simple test
or
In my test I explicitly indicate that I want to allow
If I would like to disallow I should add a correct condition like:
P.S. Sure we have some uncertainty in the case given below:
but I think that this uncertainty magic issue we should discuss in another topic
In our case, I'm sure that "allowed" and "neutral" should be equal to the "allowed"
Comment #9
andrewbelcher commented@spheresh, Drupal's AccessResult is based on Kleene's weak three-valued logic, so the behaviour below is already correct (see the truth table in the documentation):
The problem in this issue is that
\Drupal\Core\Access\AccessManager::checktreats neutral as forbidden due to usingandIf, where as what I'm proposing is that it starts with neutral and usesorIf.Attached is a patch that does what I am proposing.
Comment #10
spheresh commentedIt works fine!
I've made some very fast tests.
It seems now it works as intended.
Thanks.
Comment #11
andrewbelcher commentedNeed to add some test coverage to demonstrate neutral responses are treated correctly by AccessManager.
Comment #13
andrewbelcher commentedLooks like there is something somewhere which returns a 404 (not found) rather than a 403 (denied) (e.g. this fail) if the access result is neutral, but I can't see what is causing that...
Comment #17
kriboogh commentedAny progress on this issue? Been running against this problem with a custom module we are building... neutral should indeed have no influence on other decisions (hence the name... neutral).
Comment #18
tim.plunkettSee #2991698: Why does Route access checking differ from Entity access checking? especially #3, #7, #9
Comment #19
andrewbelcher commentedClosing as a duplicate of #2991698: Why does Route access checking differ from Entity access checking? as though this issue is older, that has some more detailed documentation of what is happening and what possible solutions could be made.