|
12 | 12 | namespace Symfony\Component\Security\Guard;
|
13 | 13 |
|
14 | 14 | use Symfony\Component\HttpFoundation\Request;
|
| 15 | +use Symfony\Component\HttpFoundation\Response; |
| 16 | +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
| 17 | +use Symfony\Component\Security\Core\Exception\AuthenticationException; |
| 18 | +use Symfony\Component\Security\Core\User\UserInterface; |
| 19 | +use Symfony\Component\Security\Core\User\UserProviderInterface; |
| 20 | +use Symfony\Component\Security\Guard\Token\GuardTokenInterface; |
| 21 | +use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; |
15 | 22 |
|
16 | 23 | /**
|
17 | 24 | * The interface for all "guard" authenticators.
|
|
23 | 30 | * @author Ryan Weaver <ryan@knpuniversity.com>
|
24 | 31 | * @author Amaury Leroux de Lens <amaury@lerouxdelens.com>
|
25 | 32 | */
|
26 |
| -interface AuthenticatorInterface extends GuardAuthenticatorInterface |
| 33 | +interface AuthenticatorInterface extends AuthenticationEntryPointInterface |
27 | 34 | {
|
28 | 35 | /**
|
29 | 36 | * Does the authenticator support the given Request?
|
@@ -60,4 +67,104 @@ public function supports(Request $request);
|
60 | 67 | * @throws \UnexpectedValueException If null is returned
|
61 | 68 | */
|
62 | 69 | public function getCredentials(Request $request);
|
| 70 | + |
| 71 | + /** |
| 72 | + * Return a UserInterface object based on the credentials. |
| 73 | + * |
| 74 | + * The *credentials* are the return value from getCredentials() |
| 75 | + * |
| 76 | + * You may throw an AuthenticationException if you wish. If you return |
| 77 | + * null, then a UsernameNotFoundException is thrown for you. |
| 78 | + * |
| 79 | + * @param mixed $credentials |
| 80 | + * @param UserProviderInterface $userProvider |
| 81 | + * |
| 82 | + * @throws AuthenticationException |
| 83 | + * |
| 84 | + * @return UserInterface|null |
| 85 | + */ |
| 86 | + public function getUser($credentials, UserProviderInterface $userProvider); |
| 87 | + |
| 88 | + /** |
| 89 | + * Returns true if the credentials are valid. |
| 90 | + * |
| 91 | + * If any value other than true is returned, authentication will |
| 92 | + * fail. You may also throw an AuthenticationException if you wish |
| 93 | + * to cause authentication to fail. |
| 94 | + * |
| 95 | + * The *credentials* are the return value from getCredentials() |
| 96 | + * |
| 97 | + * @param mixed $credentials |
| 98 | + * @param UserInterface $user |
| 99 | + * |
| 100 | + * @return bool |
| 101 | + * |
| 102 | + * @throws AuthenticationException |
| 103 | + */ |
| 104 | + public function checkCredentials($credentials, UserInterface $user); |
| 105 | + |
| 106 | + /** |
| 107 | + * Create an authenticated token for the given user. |
| 108 | + * |
| 109 | + * If you don't care about which token class is used or don't really |
| 110 | + * understand what a "token" is, you can skip this method by extending |
| 111 | + * the AbstractGuardAuthenticator class from your authenticator. |
| 112 | + * |
| 113 | + * @see AbstractGuardAuthenticator |
| 114 | + * |
| 115 | + * @param UserInterface $user |
| 116 | + * @param string $providerKey The provider (i.e. firewall) key |
| 117 | + * |
| 118 | + * @return GuardTokenInterface |
| 119 | + */ |
| 120 | + public function createAuthenticatedToken(UserInterface $user, $providerKey); |
| 121 | + |
| 122 | + /** |
| 123 | + * Called when authentication executed, but failed (e.g. wrong username password). |
| 124 | + * |
| 125 | + * This should return the Response sent back to the user, like a |
| 126 | + * RedirectResponse to the login page or a 403 response. |
| 127 | + * |
| 128 | + * If you return null, the request will continue, but the user will |
| 129 | + * not be authenticated. This is probably not what you want to do. |
| 130 | + * |
| 131 | + * @param Request $request |
| 132 | + * @param AuthenticationException $exception |
| 133 | + * |
| 134 | + * @return Response|null |
| 135 | + */ |
| 136 | + public function onAuthenticationFailure(Request $request, AuthenticationException $exception); |
10000
| 137 | + |
| 138 | + /** |
| 139 | + * Called when authentication executed and was successful! |
| 140 | + * |
| 141 | + * This should return the Response sent back to the user, like a |
| 142 | + * RedirectResponse to the last page they visited. |
| 143 | + * |
| 144 | + * If you return null, the current request will continue, and the user |
| 145 | + * will be authenticated. This makes sense, for example, with an API. |
| 146 | + * |
| 147 | + * @param Request $request |
| 148 | + * @param TokenInterface $token |
| 149 | + * @param string $providerKey The provider (i.e. firewall) key |
| 150 | + * |
| 151 | + * @return Response|null |
| 152 | + */ |
| 153 | + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey); |
| 154 | + |
| 155 | + /** |
| 156 | + * Does this method support remember me cookies? |
| 157 | + * |
| 158 | + * Remember me cookie will be set if *all* of the following are met: |
| 159 | + * A) This method returns true |
| 160 | + * B) The remember_me key under your firewall is configured |
| 161 | + * C) The "remember me" functionality is activated. This is usually |
| 162 | + * done by having a _remember_me checkbox in your form, but |
| 163 | + * can be configured by the "always_remember_me" and "remember_me_parameter" |
| 164 | + * parameters under the "remember_me" firewall key |
| 165 | + * D) The onAuthenticationSuccess method returns a Response object |
| 166 | + * |
| 167 | + * @return bool |
| 168 | + */ |
| 169 | + public function supportsRememberMe(); |
63 | 170 | }
|
0 commit comments