Skip to content

Commit d02a786

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [Form] Document using TranslatableMessage in form Fields [symfony#19122] Reword [SecurityBundle] Improve support for authenticators that don't need a user provider
2 parents 3a3577e + c8fab23 commit d02a786

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
@@ -1013,6 +1013,8 @@ multiple firewalls, the "context" could actually be shared:
10131013
ignored and you won't be able to authenticate on multiple firewalls at the
10141014
same time.
10151015

1016+
.. _reference-security-stateless:
1017+
10161018
stateless
10171019
~~~~~~~~~
10181020

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
@@ -697,6 +697,41 @@ create your own User from the claims, you must
697697
}
698698
}
699699

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

0 commit comments

Comments
 (0)