debug_kit icon indicating copy to clipboard operation
debug_kit copied to clipboard

Authorization fail

Open Erwane opened this issue 5 years ago • 8 comments

When using Cakephp/Authorization plugin, debugkit fail. One solution is to skip authorization in AuthorizationMiddleware (https://github.com/cakephp/authorization/issues/80#issuecomment-575626974) , but it's not a good place to add exceptions.

One way is to check this in DebugKit/Controller but they don't extends a common "AppController" (in plugin) so, there is a lot of "replicated code". Below, an example in the "beforeFilter" method

// In DebugKit.Controller::beforeFilter()
$authorizationService = $this->getRequest()->getAttribute('authorization');
if ($authorizationService instanceof \Authorization\AuthorizationService) {
    $service = $authorizationService->skipAuthorization();
}

Do you think we can add this common plugin controller with no risk ?

Erwane avatar Jan 17 '20 13:01 Erwane

We could, I am not sure we should though. Having debugkit disable authentication and authorization checks is risky as people often forget to disable debugkit in production. Perhaps we could do this via an opt-in option though?

markstory avatar Jan 17 '20 14:01 markstory

@markstory You could add if (Configure::read(debug)) into it?

dereuromark avatar Jan 17 '20 14:01 dereuromark

An opt-in options is like configuring the DebugKit.safeTld or DebugKit.forceEnable i think.

But i'm not sure it's a risk. The Authorization plugins is only disable for the DebugKit request and it's a XHR request. You can't access app url with a DebugKit call.

Erwane avatar Jan 17 '20 14:01 Erwane

That could work, I always worry about the person who accidentally leaves debug on in production. As it is cake not the user that gets blamed.

markstory avatar Jan 17 '20 14:01 markstory

As i said, i'm sure it's not a problem. Disabling Authorization plugin in Debugkit controllers only disable it for Debukit requests, not app requests

Erwane avatar Jan 20 '20 07:01 Erwane

i try a PR ?

Erwane avatar Jan 28 '20 12:01 Erwane

@Erwane That would be great!

markstory avatar Jan 28 '20 17:01 markstory

I suppose the question is do we expose something that people can use to probe websites with to gain environment data/etc.

If a user has DebugKit enabled, what level of guarantee do we provide?

othercorey avatar Apr 20 '20 04:04 othercorey

We documented the need to set DebugKit.ignoreAuthorization to true in the README.md of this repo as well as in the docs for the debug_kit.

Therefore I will close this issue.

LordSimal avatar Dec 27 '23 10:12 LordSimal