Commit Graph

62 Commits

Author SHA1 Message Date
Fabien Potencier
922c2015f6 Merge branch '2.0' into 2.1
* 2.0:
  [DependencyInjection] fixed composer.json
  [Form] Updated checks for the ICU version from 4.5+ to 4.7+ due to test failures with ICU 4.6
  fixed CS
  small fix of #5984 when the container param is not set
  fixed CS
  Use better default ports in urlRedirectAction
  Add tests for urlRedirectAction
  Update src/Symfony/Component/DomCrawler/Tests/FormTest.php
  Update src/Symfony/Component/DomCrawler/Form.php
  [Security] remove escape charters from username provided by Digest DigestAuthenticationListener
  [Security] added test extra for digest authentication
  fixed CS
  [Security] Fixed digest authentication
  [Security] Fixed digest authentication
  [SecurityBundle] Convert Http method to uppercase in the config
  Use Norm Data instead of Data

Conflicts:
	src/Symfony/Bridge/Doctrine/Form/EventListener/MergeCollectionListener.php
	src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php
	src/Symfony/Component/DependencyInjection/composer.json
2012-11-29 11:32:18 +01:00
Sebastiaan Stok
f2cbea3b30 [Security] remove escape charters from username provided by Digest DigestAuthenticationListener 2012-11-15 16:54:04 +01:00
Sebastiaan Stok
80f6992a41 [Security] added test extra for digest authentication 2012-11-15 16:42:03 +01:00
Sebastiaan Stok
d66b03c830 fixed CS 2012-11-15 16:42:02 +01:00
Vincent Simonin
694697dd91 [Security] Fixed digest authentication
Digest authentication fail if digest parameters contains `=` character or `, ` string.

* Support escaped characters
2012-11-15 16:42:02 +01:00
Vincent Simonin
c067586368 [Security] Fixed digest authentication
Digest authentication fail if digest parameters contains `=` character or `, ` string.
2012-11-15 16:42:01 +01:00
Fabien Potencier
5cc43f9486 fixed merge 2012-08-27 21:31:24 +02:00
Fabien Potencier
c29edb5e2e merged 2.0 2012-08-26 11:32:04 +02:00
Kris Wallsmith
c51fc105f4 avoid fatal error on invalid session 2012-08-07 14:21:04 -04:00
Fabien Potencier
fea6b79acd moved component and bridge unit tests to the src/ directory
This is the first step to make each Symfony Component and Bridge self-contained.
2012-03-29 08:37:22 +02:00
Fabien Potencier
294b57e1b1 merged branch jmikola/logout-csrf (PR #3007)
Commits
-------

49a8654 [Security] Use LogoutException for invalid CSRF token in LogoutListener
a96105e [SecurityBundle] Use assertCount() in tests
4837407 [SecurityBundle] Fix execution of functional tests with different names
66722b3 [SecurityBundle] Templating helpers to generate logout URL's with CSRF tokens
aaaa040 [Security] Allow LogoutListener to validate CSRF tokens
b1f545b [Security] Refactor LogoutListener constructor to take options
c48c775 [SecurityBundle] Add functional test for form login with CSRF token

Discussion
----------

[Security] Implement support for CSRF tokens in logout URL's

```
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
```

[![Build Status](https://secure.travis-ci.org/jmikola/symfony.png?branch=logout-csrf)](http://travis-ci.org/jmikola/symfony)

This derived from #3006 but properly targeting on the master branch.

This exposes new configuration options to the logout listener to enable CSRF protection, as already exists for the form login listener. The individual commits and their extended messages should suffice for explaining the logical changes of the PR.

In addition to changing LogoutListener, I also created a templating helper to generate logout URL's, which includes a CSRF token if necessary. This may or may not using routing, depending on how the listener is configured since both route names or hard-coded paths are valid options.

Additionally, I added unit tests for LogoutListener and functional tests for both CSRF-enabled form logins and the new logout listener work.

Kudo's to @henrikbjorn for taking the time to document CSRF validation for form login listeners (see [here](http://henrik.bjrnskov.dk/symfony2-cross-site-request-forgery/)). The [Logout CSRF Protection](http://www.yiiframework.com/wiki/190/logout-csrf-protection/) article on the Yii Framework wiki was also helpful in drafting this.

---------------------------------------------------------------------------

by jmikola at 2011-12-31T07:50:31Z

Odd that Travis CI reported a build failure for PHP 5.3.2, but both 5.3 and 5.4 passed: http://travis-ci.org/#!/jmikola/symfony/builds/463356

My local machine passes as well.

---------------------------------------------------------------------------

by jmikola at 2012-02-06T20:05:30Z

@schmittjoh: Please let me know your thoughts on the last commit. I think it would be overkill to add support for another handler service and/or error page just for logout exceptions.

Perhaps as an alternative, we might just want to consider an invalid CSRF token on logout imply a false return value for `LogoutListener::requiresLogout()`. That would sacrifice the ability to handle the error separately (which a 403 response allows us), although we could still add logging (currently done in ExceptionListener).

---------------------------------------------------------------------------

by jmikola at 2012-02-13T17:41:33Z

@schmittjoh: ping

---------------------------------------------------------------------------

by fabpot at 2012-02-14T23:36:22Z

@jmikola: Instead of merging symfony/master, can you rebase?

---------------------------------------------------------------------------

by jmikola at 2012-02-15T00:00:49Z

Will do.

---------------------------------------------------------------------------

by jmikola at 2012-02-15T00:05:48Z

```
[avocado: symfony] logout-csrf (+9/-216) $ git rebase master
First, rewinding head to replay your work on top of it...
Applying: [SecurityBundle] Add functional test for form login with CSRF token
Applying: [Security] Refactor LogoutListener constructor to take options
Applying: [Security] Allow LogoutListener to validate CSRF tokens
Applying: [SecurityBundle] Templating helpers to generate logout URL's with CSRF tokens
Applying: [SecurityBundle] Fix execution of functional tests with different names
Applying: [SecurityBundle] Use assertCount() in tests
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Applying: [Security] Use LogoutException for invalid CSRF token in LogoutListener

[avocado: symfony] logout-csrf (+7) $ git st
# On branch logout-csrf
# Your branch and 'origin/logout-csrf' have diverged,
# and have 223 and 9 different commit(s) each, respectively.
#
nothing to commit (working directory clean)

[avocado: symfony] logout-csrf (+7) $
```

After rebasing, my merge commits disappeared. Is this normal?

---------------------------------------------------------------------------

by stof at 2012-02-15T00:15:07Z

Are you sure they disappeared ? Diverging from the remote branch is logical (you rewrote the history and so changed the commit id) but are you sure it does not have the commits on top of master ? Try ``git log master..logout-scrf``

If your commut are there, you simply need to force the push for the logout-csrf branch (take care to push only this branch during the force push to avoid messing all others as git won't warn you when asking to force)

---------------------------------------------------------------------------

by stof at 2012-02-15T00:17:09Z

ah sorry, you talked only about the merge commit. Yeah it is normal. When reapplying your commits on top of master, the merge commit are not kept as you are reapplying the changes linearly on top of the other branch (and deleting the merge commit was the reason why @fabpot asked you to rebase instead of merging btw)

---------------------------------------------------------------------------

by jmikola at 2012-02-15T00:18:00Z

The merge commits are not present in `git log master..logout-csrf`. Perhaps it used those merge commits when rebasing, as there were definitely conflicts resolved when I originally merged in symfony/master (@fabpot had made his own changes to LogoutListener).

I'll force-push the changes to my PR brange. IIRC, GitHub is smart enough to preserve inline diff comments, provided they were made through the PR and not on the original commits.

---------------------------------------------------------------------------

by jmikola at 2012-02-15T00:19:38Z

That worked well. In the future, I think I'll stick to merging upstream in and then rebasing afterwards. Resolving conflicts is much easier during a merge than interactive rebase.

---------------------------------------------------------------------------

by jmikola at 2012-02-23T18:46:13Z

@fabpot @schmittjoh: Is there anything else I can do for this PR? I believe the exception was the only outstanding question (see: [this comment](https://github.com/symfony/symfony/pull/3007#issuecomment-3835716)).
2012-03-05 16:12:24 +01:00
Kris Wallsmith
1e8236cfb3 [Security] added AccessMapInterface 2012-02-15 14:14:40 -08:00
Jeremy Mikola
49a8654cb8 [Security] Use LogoutException for invalid CSRF token in LogoutListener
On the advice of @schmittjoh, this commit adds a LogoutException class for use by LogoutListener if the CSRF token is invalid.

The handling in the Security component's ExceptionListener is modeled after AccessDeniedException, which gets wrapped in an AccessDeniedHttpException in the absence of handler service or error page (I didn't think it was appropriate to re-use those for LogoutException).
2012-02-14 19:03:52 -05:00
Jeremy Mikola
aaaa04003d [Security] Allow LogoutListener to validate CSRF tokens
This adds several new options to the logout listener, modeled after the form_login listener:

 * csrf_parameter
 * intention
 * csrf_provider

The "csrf_parameter" and "intention" have default values if omitted. By default, "csrf_provider" is empty and CSRF validation is disabled in LogoutListener (preserving BC). If a service ID is given for "csrf_provider", CSRF validation will be enabled. Invalid tokens will result in an InvalidCsrfTokenException being thrown before any logout handlers are invoked.
2012-02-14 19:03:51 -05:00
Jeremy Mikola
b1f545b677 [Security] Refactor LogoutListener constructor to take options
This will facilitate adding additional options for CSRF protection. Additionally, a unit test for existing behavior was added.
2012-02-14 19:03:51 -05:00
Fabien Potencier
74ccf7062a reverted 5b7ef11650 (Simplify session
storage class names now we have a separate namespace for sessions)
2012-02-11 12:04:50 +01:00
Drak
5b7ef11650 [HttpFoundation] Simplify session storage class names now we have a separate namespace for sessions. 2012-02-11 11:24:35 +05:45
Drak
27530cbb1e [HttpFoundation] Moved session related classes to own sub-namespace. 2012-02-11 11:24:31 +05:45
Drak
f98f9ae8ff [HttpFoundation] Refactor for DRY code.
Rename ArraySessionStorage to make it clear the session is a mock for testing purposes only.
Has BC class for ArraySessionStorage
Added sanity check when starting the session.
Fixed typos and incorrect php extension test method
session_module_name() also sets session.save_handler, so must use extension_loaded() to check if module exist
or not.
Respect autostart settings.
2012-02-11 11:24:11 +05:45
Dariusz Górecki
3cfaade8f7 [CS] Fix usage of assertCount
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
2012-01-18 14:42:47 +01:00
Fabien Potencier
2b5d4b90d8 merged 2.0 2011-11-24 07:16:52 +01:00
Fabien Potencier
5878490b16 removed unused use statements 2011-11-24 07:16:14 +01:00
Fabien Potencier
1340ea67a6 Merge branch '2.0'
* 2.0:
  [HttpKernel] fixed Content-Length header when using ESI tags (closes #2623)
  [HttpFoundation] added an exception to MimeTypeGuesser::guess() when no guesser are available (closes #2636)
  [Security] fixed HttpUtils::checkRequestPath() to not catch all exceptions (closes #2637)
  [DoctrineBundle] added missing default parameters, needed to setup and use DBAL without ORM
  [Transation] Fix grammar.
  [TwigBundle] Fix trace to not show 'in at line' when file/line are empty.
2011-11-14 14:32:22 +01:00
Fabien Potencier
0462a89562 [Security] fixed HttpUtils::checkRequestPath() to not catch all exceptions (closes #2637) 2011-11-14 13:10:32 +01:00
Fabien Potencier
8d9ea7c1ce merged branch dpb587/patch-sectok (PR #2414)
Commits
-------

ab9caa0 [Security] Check for request's session before attempting writes.
dabff0e [Security] Support removing tokens from a session.

Discussion
----------

[Security] Support removing tokens from a session.

Currently there is no way to remove a session's security token without invalidating the entire session and all its data (the ContextListener will only update the session if a token is non-null and non-anonymous). This patch fixes that.

I consider this a bug and I found no tests to prove otherwise. Let me know if I'm mistaken. Originally mentioned at https://groups.google.com/d/topic/symfony-devs/ojLvh0WUbfo/discussion

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -

---------------------------------------------------------------------------

by ms937 at 2011/10/24 05:19:21 -0700

This change looks good to me. In fact I'm using similar patch in my app and it works as intended. Also, several other people requested this on the mailing list. Could someone from Symfony team merge this? Thanks.
2011-11-07 23:19:37 +01:00
Henrik Westphal
dec1858223 Fixed typo 2011-10-31 09:00:49 +01:00
Fabien Potencier
851eb73778 removed unused use statements 2011-10-29 11:56:30 +02:00
Danny Berger
ab9caa0a61 [Security] Check for request's session before attempting writes. 2011-10-25 14:19:34 -04:00
Danny Berger
dabff0e4d5 [Security] Support removing tokens from a session. 2011-10-14 20:27:53 -04:00
Fabien Potencier
b4028350d2 [HttpFoundation] standardized cookie paths (an empty path is equivalent to /) 2011-09-28 10:49:50 +02:00
Johannes Schmitt
f300edebe4 fixes several bugs 2011-07-19 16:21:58 +02:00
Johannes Schmitt
b7c4806a5a [Security] fixes #1329 2011-07-13 18:10:58 +02:00
Francis Besset
f91f4dda13 Added the possibility to set cookies with the same name for different domains and paths for Symfony\Component\HttpFoundation\ResponseHeaderBag
ResponseHeaderBag::hasCookie() and ResponseHeaderBag::getCookie() were removed
2011-07-11 23:03:26 +02:00
Fabien Potencier
2f51bc3ef3 [Security] fixed tests 2011-07-11 08:28:02 +02:00
Fabien Potencier
4f8a98033a [Security] removed a hack 2011-07-05 11:00:08 +02:00
Fabien Potencier
cc03b73253 merged branch Herzult/testSecurity (PR #1447)
Commits
-------

164aea4 [Security] Add tests for the channel listener
d51cbc0 [Security] Remove useless attribute in basic authentication listener & test it
91e6dc9 [Security] Add tests for the anonymous authentication listener
3c2affb [Security] Update access listener constructor's prototype and add tests
81afd77 [Security] Add tests for the firewall map
aa6ae33 [Security] Remove useless attribute & var in firewall

Discussion
----------

Test security

---------------------------------------------------------------------------

by lsmith77 at 2011/06/29 13:41:07 -0700

@schmittjoh is probably the person to review this change ..
2011-07-04 12:47:32 +02:00
Antoine Hérault
164aea448a [Security] Add tests for the channel listener 2011-06-26 11:56:08 +02:00
Antoine Hérault
d51cbc09b4 [Security] Remove useless attribute in basic authentication listener & test it 2011-06-26 11:29:43 +02:00
Antoine Hérault
91e6dc9fef [Security] Add tests for the anonymous authentication listener 2011-06-26 11:28:17 +02:00
Antoine Hérault
3c2affb7e7 [Security] Update access listener constructor's prototype and add tests 2011-06-26 10:28:10 +02:00
Antoine Hérault
81afd77ed9 [Security] Add tests for the firewall map 2011-06-26 00:26:42 +02:00
Antoine Hérault
aa6ae33765 [Security] Remove useless attribute & var in firewall 2011-06-25 19:04:35 +02:00
Antoine Hérault
e43cd206b0 [Security] Fix http retry authentication entry point 2011-06-25 18:19:13 +02:00
Antoine Hérault
cb3ad8bb79 [Security] Fix http form authentication entry point 2011-06-25 18:01:08 +02:00
Antoine Hérault
1dfb637858 [Security] Fix http digest authentication entry point 2011-06-25 17:43:23 +02:00
Antoine Hérault
920a209bbc [Security] Fix http basic authentication entry point 2011-06-25 17:15:23 +02:00
Fabien Potencier
1436d8dab7 [Security] added an HttpUtils class to manage logic related to Requests and Responses
This change removes the need for the {_locale} hack.
Now, all paths in the Security component can be:

* An absolute path (/login)
* An absolute URL (http://symfony.com/login)
* A route name (login)

So, if you want to use a path that includes a global parameter (like _locale),
use a route instead of a path.
2011-06-22 14:47:19 +02:00
Fabien Potencier
17cd08dc6c fixed CS 2011-06-08 19:56:59 +02:00
Fabien Potencier
65200aa86a added missing license headers 2011-05-31 10:57:06 +02:00
Fabien Potencier
66c4bc727c [HttpFoundation] renamed Cookie::getExpire() to getExpiresTime() to be consistent with the DomCrawler component 2011-04-13 20:10:39 +02:00