2323use Authentication \Authenticator \PersistenceInterface ;
2424use Authentication \Authenticator \ResultInterface ;
2525use Authentication \Authenticator \StatelessInterface ;
26- use Authentication \Identifier \IdentifierCollection ;
2726use Authentication \Identifier \IdentifierInterface ;
2827use Cake \Core \InstanceConfigTrait ;
2928use Cake \Routing \Router ;
3029use InvalidArgumentException ;
3130use Psr \Http \Message \ResponseInterface ;
3231use Psr \Http \Message \ServerRequestInterface ;
3332use RuntimeException ;
34- use function Cake \Core \deprecationWarning ;
3533
3634/**
3735 * Authentication Service
@@ -47,13 +45,6 @@ class AuthenticationService implements AuthenticationServiceInterface, Impersona
4745 */
4846 protected ?AuthenticatorCollection $ _authenticators = null ;
4947
50- /**
51- * Identifier collection
52- *
53- * @var \Authentication\Identifier\IdentifierCollection|null
54- */
55- protected ?IdentifierCollection $ _identifiers = null ;
56-
5748 /**
5849 * Authenticator that successfully authenticated the identity.
5950 *
@@ -73,10 +64,7 @@ class AuthenticationService implements AuthenticationServiceInterface, Impersona
7364 *
7465 * - `authenticators` - An array of authentication objects to use for authenticating users.
7566 * You can configure multiple adapters and they will be checked sequentially
76- * when users are identified.
77- * - `identifiers` - An array of identifiers. The identifiers are constructed by the service
78- * and then passed to the authenticators that will pass the credentials to them and get the
79- * user data.
67+ * when users are identified. Each authenticator config can specify its own `identifier`.
8068 * - `identityClass` - The class name of identity or a callable identity builder.
8169 * - `identityAttribute` - The request attribute used to store the identity. Default to `identity`.
8270 * - `unauthenticatedRedirect` - The URL to redirect unauthenticated errors to. See
@@ -100,7 +88,6 @@ class AuthenticationService implements AuthenticationServiceInterface, Impersona
10088 */
10189 protected array $ _defaultConfig = [
10290 'authenticators ' => [],
103- 'identifiers ' => [],
10491 'identityClass ' => Identity::class,
10592 'identityAttribute ' => 'identity ' ,
10693 'queryParam ' => null ,
@@ -117,20 +104,6 @@ public function __construct(array $config = [])
117104 $ this ->setConfig ($ config );
118105 }
119106
120- /**
121- * Access the identifier collection
122- *
123- * @return \Authentication\Identifier\IdentifierCollection
124- */
125- public function identifiers (): IdentifierCollection
126- {
127- if ($ this ->_identifiers === null ) {
128- $ this ->_identifiers = new IdentifierCollection ($ this ->getConfig ('identifiers ' ));
129- }
130-
131- return $ this ->_identifiers ;
132- }
133-
134107 /**
135108 * Access the authenticator collection
136109 *
@@ -139,9 +112,8 @@ public function identifiers(): IdentifierCollection
139112 public function authenticators (): AuthenticatorCollection
140113 {
141114 if ($ this ->_authenticators === null ) {
142- $ identifiers = $ this ->identifiers ();
143115 $ authenticators = $ this ->getConfig ('authenticators ' );
144- $ this ->_authenticators = new AuthenticatorCollection ($ identifiers , $ authenticators );
116+ $ this ->_authenticators = new AuthenticatorCollection ($ authenticators );
145117 }
146118
147119 return $ this ->_authenticators ;
@@ -159,24 +131,6 @@ public function loadAuthenticator(string $name, array $config = []): Authenticat
159131 return $ this ->authenticators ()->load ($ name , $ config );
160132 }
161133
162- /**
163- * Loads an identifier.
164- *
165- * @param string $name Name or class name.
166- * @param array<string, mixed> $config Identifier configuration.
167- * @return \Authentication\Identifier\IdentifierInterface Identifier instance
168- * @deprecated 3.3.0: loadIdentifier() usage is deprecated. Directly pass Identifier to Authenticator.
169- */
170- public function loadIdentifier (string $ name , array $ config = []): IdentifierInterface
171- {
172- deprecationWarning (
173- '3.3.0 ' ,
174- 'loadIdentifier() usage is deprecated. Directly pass ` \'identifier \'` config to the Authenticator. ' ,
175- );
176-
177- return $ this ->identifiers ()->load ($ name , $ config );
178- }
179-
180134 /**
181135 * {@inheritDoc}
182136 *
@@ -291,12 +245,7 @@ public function getIdentificationProvider(): ?IdentifierInterface
291245 return null ;
292246 }
293247
294- $ identifier = $ this ->_successfulAuthenticator ->getIdentifier ();
295- if ($ identifier instanceof IdentifierCollection) {
296- return $ identifier ->getIdentificationProvider ();
297- }
298-
299- return $ identifier ;
248+ return $ this ->_successfulAuthenticator ->getIdentifier ();
300249 }
301250
302251 /**
0 commit comments