Skip to content

Commit af8cf4b

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [Form] Document using TranslatableMessage in form Fields [symfony#19122] Reword [SecurityBundle] Improve support for authenticators that don't need a user provider
2 parents f1c0f13 + 4beb87e commit af8cf4b

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

reference/configuration/security.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ multiple firewalls, the "context" could actually be shared:
10251025
ignored and you won't be able to authenticate on multiple firewalls at the
10261026
same time.
10271027

1028+
.. _reference-security-stateless:
1029+
10281030
stateless
10291031
~~~~~~~~~
10301032

reference/forms/types/options/button_label.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``label``
22
~~~~~~~~~
33

4-
**type**: ``string`` **default**: The label is "guessed" from the field name
4+
**type**: ``string`` or ``TranslatableMessage`` **default**: The label is "guessed" from the field name
55

66
Sets the label that will be displayed on the button. The label can also
77
be directly set inside the template:

reference/forms/types/options/placeholder.rst.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``placeholder``
22
~~~~~~~~~~~~~~~
33

4-
**type**: ``string`` or ``boolean``
4+
**type**: ``string`` or ``TranslatableMessage`` or ``boolean``
55

66
This option determines whether or not a special "empty" option (e.g. "Choose
77
an option") will appear at the top of a select widget. This option only
@@ -14,6 +14,9 @@ applies if the ``multiple`` option is set to false.
1414

1515
$builder->add('states', ChoiceType::class, [
1616
'placeholder' => 'Choose an option',
17+
18+
// or if you want to translate the text
19+
'placeholder' => new TranslatableMessage('form.placeholder.select_option', [], 'form'),
1720
]);
1821

1922
* Guarantee that no "empty" value option is displayed::

security/access_token.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,41 @@ create your own User from the claims, you must
705705
}
706706
}
707707

708+
Creating Users from Token
709+
-------------------------
710+
711+
.. versionadded:: 6.3
712+
713+
The possibility to omit the user provider in case of stateless firewalls
714+
was introduced in Symfony 6.3.
715+
716+
Some types of tokens (for instance OIDC) contain all information required
717+
to create a user entity (e.g. username and roles). In this case, you don't
718+
need a user provider to create a user from the database::
719+
720+
// src/Security/AccessTokenHandler.php
721+
namespace App\Security;
722+
723+
// ...
724+
class AccessTokenHandler implements AccessTokenHandlerInterface
725+
{
726+
// ...
727+
728+
public function getUserBadgeFrom(string $accessToken): UserBadge
729+
{
730+
// get the data from the token
731+
$payload = ...;
732+
733+
return new UserBadge(
734+
$payload->getUserId(),
735+
fn (string $userIdentifier) => new User($userIdentifier, $payload->getRoles())
736+
);
737+
}
738+
}
739+
740+
When using this strategy, you can omit the ``user_provider`` configuration
741+
for :ref:`stateless firewalls <reference-security-stateless>`.
742+
708743
.. _`JSON Web Tokens (JWT)`: https://datatracker.ietf.org/doc/html/rfc7519
709744
.. _`SAML2 (XML structures)`: https://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html
710745
.. _`RFC6750`: https://datatracker.ietf.org/doc/html/rfc6750

0 commit comments

Comments
 (0)