-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Changes from 1 commit
330aa7f
05af97c
a0bceb4
873ed28
180e2c7
6c180c7
c73c32e
eb158cb
d693721
6edb9e1
ffdbc66
7de05be
7a94994
81432f9
293c8a1
0501761
31f9cae
c9d9430
396a162
302235e
dd485f4
e353833
d763134
a01ed35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
… adding an interface The reason is that the GuardAuthenticationProvider *must* respond to *all* tokens created by the system - both "pre auth" and "post auth" tokens. The reason is that if a "post auth" token becomes not authenticated (e.g. because the user changes between requests), then it may be passed to the provider system. If no providers respond (which was the case before this commit), then AuthenticationProviderManager throws an exception. The next commit will properly handle these "post auth" + "no-longer-authenticated" tokens, which should cause a log out.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Security\Guard\Token; | ||
|
||
/** | ||
* An empty interface that both guard tokens implement | ||
* | ||
* This interface is used by the GuardAuthenticationProvider to know | ||
* that a token belongs to its system. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An interface that knows about its implementations? ;) What about replacing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call - I updated that and a few other bits of the words here :) |
||
* | ||
* @author Ryan Weaver <weaverryan@gmail.com> | ||
*/ | ||
interface GuardTokenInterface | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* | ||
* @author Ryan Weaver <weaverryan@gmail.com> | ||
*/ | ||
class NonAuthenticatedGuardToken extends AbstractToken | ||
class PreAuthenticationGuardToken extends AbstractToken implements GuardTokenInterface | ||
{ | ||
private $credentials; | ||
private $guardProviderKey; | ||
|
@@ -51,6 +51,6 @@ public function getCredentials() | |
|
||
public function setAuthenticated($authenticated) | ||
{ | ||
throw new \Exception('The NonAuthenticatedGuardToken is *always* not authenticated'); | ||
throw new \Exception('The PreAuthenticationGuardToken is *always* not authenticated'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Even if you decide not to change it, the exception should have a dot in its message at the end. edit: I see more exception messages in the PR that are missing dots There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, thank you - I agree on both points! I've added dots, so if you see any missing now, please let me know! |
||
} | ||
} |
There was a problem hiding this comment.
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 inGuard\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 beGuard\Authentication\Provider\Guard
).There was a problem hiding this comment.
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 actuallySymfony\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.