Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

EZP-25482: Fix exception with CSRF protection disabled #515

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emodric
Copy link
Contributor

@emodric emodric commented Feb 17, 2016

When CSRF protection is disabled with framework.csrf_protection.enabled flag set to false, site crashes with an exception about missing security.csrf.token_manager service.

Depends on: ezsystems/ezpublish-kernel#1589

@dpobel
Copy link
Contributor

dpobel commented Feb 23, 2016

you need to add a test in https://github.com/ezsystems/PlatformUIBundle/blob/master/Tests/ApplicationConfig/Providers/SessionInfoTest.php
other than that, that seems ok to me.

@emodric emodric force-pushed the fix_csrf_token_disable_crash branch from 9a2db3d to e39697f Compare February 23, 2016 10:12
@emodric
Copy link
Contributor Author

emodric commented Feb 23, 2016

@dpobel Done.

@emodric emodric force-pushed the fix_csrf_token_disable_crash branch from e39697f to 3362f0d Compare February 23, 2016 10:30
@dpobel
Copy link
Contributor

dpobel commented Feb 23, 2016

+1

@andrerom
Copy link
Contributor

andrerom commented Feb 23, 2016

+1 ( @dpobel assuming js code is not expecting it to always be there? )

@dpobel
Copy link
Contributor

dpobel commented Feb 23, 2016

@andrerom that's a very good remark, I need to check

@emodric
Copy link
Contributor Author

emodric commented Feb 23, 2016

@andrerom @dpobel In my tests login worked fine.

@dpobel
Copy link
Contributor

dpobel commented Feb 23, 2016

the actual login should work but did you check with an existing session ?
I think that because of https://github.com/ezsystems/ez-js-rest-client/blob/master/src/authAgents/SessionAuthAgent.js#L81, that won't work, can you try @emodric ?

@emodric
Copy link
Contributor Author

emodric commented Feb 23, 2016

@dpobel I'm not sure I understand. What and how do I need to test? It's not too obvious from JS code.

@dpobel
Copy link
Contributor

dpobel commented Feb 23, 2016

:)
Just go to PlatformUI, login normally and after you are logged in, refresh the page. In that case, PlatformUI will receive the session info object describing the existing session but without the CSRF token and the SessionAuthAgent will throw an error because it is missing and expects one.

@emodric
Copy link
Contributor Author

emodric commented Feb 23, 2016

Hm... This is what I get now when trying to login:

Parameter "sessionId" for route "ezpublish_rest_deleteSession" must match "[^/]++" ("" given) to generate a corresponding URL.

Is this expected?

@@ -29,7 +29,7 @@ class SessionInfo implements Provider

public function __construct(
SessionInterface $session,
CsrfTokenManagerInterface $csrfTokenManager,
CsrfTokenManagerInterface $csrfTokenManager = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot have a default value here. If you want to add null as default value, you must move the argument at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn it! Slipped through my fingers!

But then it's a breaking change :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes, but it should be OK IMHO. And btw the service should be marked private

Copy link
Contributor Author

@emodric emodric Apr 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yes, but it should be OK IMHO.

Okay, fixed.

And btw the service should be marked private

It already is? Or you meant Symfony DIC service? Any reason why?

@bdunogier
Copy link
Member

The consensus reached after discussion with the platform team can be read on jira.

This pull-request is not sufficient at the moment, as it only fixes an error, but doesn't make the wholee thing work.

What we would like for the moment is that PlatformUI throws a clear and documented exception when the CsrfTokenManager is not set. We can then quietly consider an improvement to the JS rest client to allow it to work without a csrf token (not supported at the moment).

@andrerom
Copy link
Contributor

Ok, I guess csrf should only be allowed to be disabled for basic auth mode, but we don't support that from ui atm so not applicable. Better error reporting, in this case especially on logging page is indeed missing piece here: https://jira.ez.no/browse/EZP-25344

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants