@@ -219,10 +219,10 @@ identifier (e.g. the username or email)::
219
219
User Identifier
220
220
~~~~~~~~~~~~~~~
221
221
222
- The user identifier is a unique string that identifies the user. It is used
223
- to load the user using :ref: ` the user provider < security-user-providers >`.
224
- This identifier is often something like the user's email address or username,
225
- but it could be any unique value associated with the user.
222
+ The user identifier is a unique string that identifies the user. It is often
223
+ something like their email address or username, but it can be any unique value
224
+ associated with the user. It allows loading the user through the configured
225
+ :ref: ` user provider < security- user-providers >` .
226
226
227
227
.. note ::
228
228
@@ -262,21 +262,39 @@ but it could be any unique value associated with the user.
262
262
}
263
263
}
264
264
265
- It is a good practice to normalize the user identifier before using it.
266
- For example, this ensures that variations such as "john.doe", "John.Doe",
267
- or "JOHN.DOE" refer to the same user.
268
- Normalization can include converting the identifier to lowercase
269
- and trimming unnecessary spaces.
270
- You can optionally pass a user identifier normalizer as third argument to the
271
- ``UserBadge ``. This callable receives the ``$userIdentifier ``
272
- and must return a normalized user identifier as a string.
265
+ It's a good practice to normalize the user identifier before using it. This
266
+ ensures that variations like "john.doe", "John.Doe", or "JOHN.DOE" are treated
267
+ as the same user.
268
+
269
+ Normalization typically involves converting the identifier to lowercase and
270
+ trimming extra spaces. For example, Google considers the following email
271
+ addresses equivalent: ``john.doe@gmail.com ``, ``j.hon.d.oe@gmail.com ``, and
272
+ ``johndoe@gmail.com ``. This is due to normalization rules that remove dots and
273
+ lowercase the address.
274
+
275
+ In enterprise environments, users might authenticate using different identifier
276
+ formats, such as:
277
+
278
+ * ``john.doe@acme.com ``
279
+ * ``acme.com\jdoe ``
280
+ * ``https://acme.com/+jdoe ``
281
+ * ``acct:jdoe@acme.com ``
282
+
283
+ Applying normalization (e.g. lowercasing, trimming, or unifying formats) helps
284
+ ensure consistent identity resolution and prevents duplication caused by
285
+ format differences.
286
+
287
+ In Symfony applications, you can optionally pass a user identifier normalizer as
288
+ the third argument to the ``UserBadge ``. This callable receives the ``$userIdentifier ``
289
+ and must return a normalized string.
273
290
274
291
.. versionadded :: 7.3
275
292
276
- The support of the user identifier normalizer was introduced in Symfony 7.3.
293
+ Support for user identifier normalizers was introduced in Symfony 7.3.
277
294
278
- For instance, the example below uses a normalizer that converts usernames to a normalized, ASCII-only, lowercase format,
279
- suitable for consistent comparison and storage.
295
+ For instance, the example below uses a normalizer that converts usernames to
296
+ a normalized, ASCII-only, lowercase format suitable for consistent comparison
297
+ and storage::
280
298
281
299
// src/Security/NormalizedUserBadge.php
282
300
namespace App\Security;
@@ -319,33 +337,12 @@ suitable for consistent comparison and storage.
319
337
}
320
338
}
321
339
322
- .. note ::
323
-
324
- For example, Google treats the following email addresses as equivalent:
325
- ``john.doe@gmail.com ``, ``j.hon.d.oe@gmail.com ``, and ``johndoe@gmail.com ``.
326
- This is because Google applies normalization rules that remove dots
327
- and convert the address to lowercase (though behavior varies across services).
328
-
329
- .. note ::
330
-
331
- In enterprise environments, a user may authenticate using different formats
332
- of their identifier, such as:
333
-
334
- - ``john.doe@acme.com ``
335
- - ``acme.com\jdoe ``
336
- - ``https://acme.com/+jdoe ``
337
- - ``acct:jdoe@acme.com ``
338
-
339
- Applying normalization (e.g., trimming, lowercasing, or format unification)
340
- helps ensure consistent identity recognition across systems and prevents
341
- duplicates caused by format variations.
342
-
343
340
User Credential
344
341
~~~~~~~~~~~~~~~
345
342
346
- The user credential is used to authenticate the user i.e. to verify
343
+ The user credential is used to authenticate the user; that is, to verify
347
344
the validity of the provided information (such as a password, an API token,
348
- or other custom credentials).
345
+ or custom credentials).
349
346
350
347
The following credential classes are supported by default:
351
348
0 commit comments