Skip to content

Commit d6fd56a

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [Security] Move Passport Attributes to their own section Clarify instructions by changing project name to project directory
2 parents 2a4693f + d634560 commit d6fd56a

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

best_practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ to create new Symfony applications:
3030

3131
.. code-block:: terminal
3232
33-
$ symfony new my_project_name
33+
$ symfony new my_project_directory
3434
3535
Under the hood, this Symfony binary command executes the needed `Composer`_
3636
command to :ref:`create a new Symfony application <creating-symfony-applications>`

security/custom_authenticator.rst

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,39 +342,39 @@ would initialize the passport like this::
342342
}
343343
}
344344

345-
.. tip::
345+
Passport Attributes
346+
-------------------
346347

347-
Besides badges, passports can define attributes, which allows the
348-
``authenticate()`` method to store arbitrary information in the
349-
passport to access it from other authenticator methods (e.g.
350-
``createToken()``)::
348+
.. versionadded:: 5.2
351349

352-
// ...
353-
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
350+
Passport attributes were introduced in Symfony 5.2.
354351

355-
class LoginAuthenticator extends AbstractAuthenticator
356-
{
357-
// ...
352+
Besides badges, passports can define attributes, which allows the ``authenticate()``
353+
method to store arbitrary information in the passport to access it from other
354+
authenticator methods (e.g. ``createAuthenticatedToken()``)::
358355

359-
public function authenticate(Request $request): Passport
360-
{
361-
// ... process the request
356+
// ...
357+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
362358

363-
$passport = new SelfValidatingPassport(new UserBadge($username), []);
359+
class LoginAuthenticator extends AbstractAuthenticator
360+
{
361+
// ...
364362

365-
// set a custom attribute (e.g. scope)
366-
$passport->setAttribute('scope', $oauthScope);
363+
public function authenticate(Request $request): PassportInterface
364+
{
365+
// ... process the request
367366

368-
return $passport;
369-
}
367+
$passport = new SelfValidatingPassport(new UserBadge($username), []);
370368

371-
public function createToken(Passport $passport, string $firewallName): TokenInterface
372-
{
373-
// read the attribute value
374-
return new CustomOauthToken($passport->getUser(), $passport->getAttribute('scope'));
375-
}
376-
}
369+
// set a custom attribute (e.g. scope)
370+
$passport->setAttribute('scope', $oauthScope);
377371

378-
.. versionadded:: 5.2
372+
return $passport;
373+
}
379374

380-
Passport attributes were introduced in Symfony 5.2.
375+
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
376+
{
377+
// read the attribute value
378+
return new CustomOauthToken($passport->getUser(), $passport->getAttribute('scope'));
379+
}
380+
}

setup.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ application:
5353
.. code-block:: terminal
5454
5555
# run this if you are building a traditional web application
56-
$ symfony new my_project_name --version=5.4 --full
56+
$ symfony new my_project_directory --version=5.4 --full
5757
5858
# run this if you are building a microservice, console application or API
59-
$ symfony new my_project_name --version=5.4
59+
$ symfony new my_project_directory --version=5.4
6060
6161
The only difference between these two commands is the number of packages
6262
installed by default. The ``--full`` option installs all the packages that you
@@ -68,13 +68,13 @@ Symfony application using Composer:
6868
.. code-block:: terminal
6969
7070
# run this if you are building a traditional web application
71-
$ composer create-project symfony/website-skeleton:"^5.4" my_project_name
71+
$ composer create-project symfony/website-skeleton:"^5.4" my_project_directory
7272
7373
# run this if you are building a microservice, console application or API
74-
$ composer create-project symfony/skeleton:"^5.4" my_project_name
74+
$ composer create-project symfony/skeleton:"^5.4" my_project_directory
7575
7676
No matter which command you run to create the Symfony application. All of them
77-
will create a new ``my_project_name/`` directory, download some dependencies
77+
will create a new ``my_project_directory/`` directory, download some dependencies
7878
into it and even generate the basic directories and files you'll need to get
7979
started. In other words, your new application is ready!
8080

@@ -260,20 +260,20 @@ stable version. If you want to use an LTS version, add the ``--version`` option:
260260
.. code-block:: terminal
261261
262262
# use the most recent LTS version
263-
$ symfony new my_project_name --version=lts
263+
$ symfony new my_project_directory --version=lts
264264
265265
# use the 'next' Symfony version to be released (still in development)
266-
$ symfony new my_project_name --version=next
266+
$ symfony new my_project_directory --version=next
267267
268268
# you can also select an exact specific Symfony version
269-
$ symfony new my_project_name --version=5.4
269+
$ symfony new my_project_directory --version=5.4
270270
271271
The ``lts`` and ``next`` shortcuts are only available when using Symfony to
272272
create new projects. If you use Composer, you need to tell the exact version:
273273

274274
.. code-block:: terminal
275275
276-
$ composer create-project symfony/skeleton:"^5.4" my_project_name
276+
$ composer create-project symfony/skeleton:"^5.4" my_project_directory
277277
278278
The Symfony Demo application
279279
----------------------------
@@ -286,7 +286,7 @@ Run this command to create a new project based on the Symfony Demo application:
286286

287287
.. code-block:: terminal
288288
289-
$ symfony new my_project_name --demo
289+
$ symfony new my_project_directory --demo
290290
291291
Start Coding!
292292
-------------

0 commit comments

Comments
 (0)