8000 New Guard Authentication System (e.g. putting the joy back into security) by weaverryan · Pull Request #14673 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

New Guard Authentication System (e.g. putting the joy back into security) #14673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Sep 24, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
330aa7f
Improving phpdoc on AuthenticationEntryPointInterface so people that …
weaverryan May 17, 2015
05af97c
Initial commit (but after some polished work) of the new Guard authen…
weaverryan May 17, 2015
a0bceb4
adding Guard tests
weaverryan May 17, 2015
873ed28
Renaming the tokens to be clear they are "post" and "pre" auth - also…
weaverryan May 17, 2015
180e2c7
Properly handles "post auth" tokens that have become not authenticated
weaverryan May 17, 2015
6c180c7
Adding an edge case - this should not happen anyways
weaverryan May 17, 2015
c73c32e
Thanks fabbot!
weaverryan May 17, 2015
eb158cb
Updating interface method per suggestion - makes sense to me, Request…
weaverryan May 18, 2015
d693721
Adding periods at the end of exceptions, and changing one class name …
weaverryan May 18, 2015
6edb9e1
Tweaking docblock on interface thanks to @iltar
weaverryan May 18, 2015
ffdbc66
Splitting the getting of the user and checking credentials into two s…
weaverryan May 18, 2015
7de05be
A few more changes thanks to @iltar
weaverryan May 18, 2015
7a94994
Thanks again fabbot!
weaverryan May 18, 2015
81432f9
Adding missing factory registration
weaverryan May 25, 2015
293c8a1
meaningless author and license changes
weaverryan Sep 20, 2015
0501761
Allowing for other authenticators to be checked
weaverryan Sep 20, 2015
31f9cae
Adding a base class to assist with form login authentication
weaverryan Sep 20, 2015
c9d9430
Adding logging on this step and switching the order - not for any hu…
weaverryan Sep 20, 2015
396a162
Tweaks thanks to Wouter
weaverryan Sep 20, 2015
302235e
Fixing a bug where having an authentication failure would log you out.
weaverryan Sep 21, 2015
dd485f4
Adding a new exception and throwing it when the User changes
weaverryan Sep 21, 2015
e353833
fabbot
weaverryan Sep 21, 2015
d763134
Removing unnecessary override
weaverryan Sep 22, 2015
a01ed35
Adding the necessary files so that Guard can be its own installable c…
weaverryan Sep 24, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
meaningless author and license changes
  • Loading branch information
weaverryan committed Sep 20, 2015
commit 293c8a1775af3d78fabc10139578de5642bc2ef1
< 10000 td id="diff-5c782c1bbbe35ede0a92cd5e7ddfe6d6fb5f24197b907c7df2e19a3dfccf0572R8" data-line-number="8" class="blob-num blob-num-addition js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory;

use Symfony\Component\Config\Definition\Builder\NodeDefinition;
Expand All @@ -10,7 +19,7 @@
/**
* Configures the "guard" authentication provider key under a firewall.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class GuardAuthenticationFactory implements SecurityFactoryInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard;

use Symfony\Component\Security\Core\User\UserInterface;
Expand All @@ -8,7 +17,7 @@
/**
* An optional base class that creates a PostAuthenticationGuardToken for you.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
abstract class AbstractGuardAuthenticator implements GuardAuthenticatorInterface
{
Expand All @@ -29,4 +38,4 @@ public function createAuthenticatedToken(UserInterface $user, $providerKey)
$user->getRoles()
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard\Firewall;

use Symfony\Component\HttpFoundation\Request;
Expand All @@ -18,7 +27,7 @@
/**
* Authentication listener for the "guard" system.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class GuardAuthenticationListener implements ListenerInterface
{
Expand Down Expand Up @@ -177,4 +186,4 @@ private function triggerRememberMe(GuardAuthenticatorInterface $guardAuthenticat

$this->rememberMeServices->loginSuccess($request, $response, $token);
}
}
}
13 changes: 11 additions & 2 deletions src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand All @@ -18,7 +27,7 @@
* By having the logic here instead of the listener, more of the process
* can be called directly (e.g. for manual authentication) or overridden.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class GuardAuthenticatorHandler
{
Expand Down Expand Up @@ -122,4 +131,4 @@ public function handleAuthenticationFailure(AuthenticationException $authenticat
is_object($response) ? get_class($response) : gettype($response)
));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard;

use Symfony\Component\HttpFoundation\Request;
Expand All @@ -18,7 +27,7 @@
* process to give you the power to control most parts of the process from
* one location.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
interface GuardAuthenticatorInterface extends AuthenticationEntryPointInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard\Provider;
Copy link
Member

Choose a reason for hiding this comment

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

I propose to move this namespace into Guard\Authentication, just as done in Security Core. Or move the class in Guard\Authentication directly (to avoid long FQCNs). The -AuthenticationProvider prefix already makes it clear it's an authentication provider, no need to duplicate that in the namespaces imo (in my ideal world, it would be Guard\Authentication\Provider\Guard).

Copy link
Member Author

Choose a reason for hiding this comment

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

Finally updating this PR :). I don't understand what you're proposing here - when you suggest Guard\Authentication... - do you actually mean that, or actually Symfony\Component\Security\Guard\Authentication...? I'm not convinced I have the classes organized in the most efficient way, and it's an easy change to still make.


use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
Expand All @@ -17,7 +26,7 @@
* Responsible for accepting the PreAuthenticationGuardToken and calling
* the correct authenticator to retrieve the authenticated token.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class GuardAuthenticationProvider implements AuthenticationProviderInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard\Token;

/**
Expand All @@ -9,7 +18,7 @@
* are handled by the guard auth system) must implement this
* interface.
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
interface GuardTokenInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard\Token;

use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
Expand All @@ -12,7 +21,7 @@
* If you're using Guard authentication, you *must* use a class that implements
* GuardTokenInterface as your authenticated token (like this class).
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>n@gmail.com>
*/
class PostAuthenticationGuardToken extends AbstractToken implements GuardTokenInterface
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Guard\Token;

use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
Expand All @@ -11,7 +20,7 @@
* immediately by the GuardAuthenticationProvider. If authentication is
* successful, a different authenticated token is returned
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Ryan Weaver <ryan@knpuniversity.com>
*/
class PreAuthenticationGuardToken extends AbstractToken implements GuardTokenInterface
{
Expand Down
0