Skip to content

Commit 326e7e5

Browse files
committed
Tweaks and rewords
1 parent 9d65b3d commit 326e7e5

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed

security/custom_authenticator.rst

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ identifier (e.g. the username or email)::
219219
User Identifier
220220
~~~~~~~~~~~~~~~
221221

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>`.
226226

227227
.. note::
228228

@@ -262,21 +262,39 @@ but it could be any unique value associated with the user.
262262
}
263263
}
264264

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.
273290

274291
.. versionadded:: 7.3
275292

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.
277294

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::
280298

281299
// src/Security/NormalizedUserBadge.php
282300
namespace App\Security;
@@ -319,33 +337,12 @@ suitable for consistent comparison and storage.
319337
}
320338
}
321339

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-
343340
User Credential
344341
~~~~~~~~~~~~~~~
345342

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
347344
the validity of the provided information (such as a password, an API token,
348-
or other custom credentials).
345+
or custom credentials).
349346

350347
The following credential classes are supported by default:
351348

0 commit comments

Comments
 (0)