Skip to content

Commit a61d7f3

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

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
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: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -335,35 +335,35 @@ would initialize the passport like this::
335335
}
336336
}
337337

338-
.. tip::
338+
Passport Attributes
339+
-------------------
340+
341+
Besides badges, passports can define attributes, which allows the ``authenticate()``
342+
method to store arbitrary information in the passport to access it from other
343+
authenticator methods (e.g. ``createAuthenticatedToken()``)::
339344

340-
Besides badges, passports can define attributes, which allows the
341-
``authenticate()`` method to store arbitrary information in the
342-
passport to access it from other authenticator methods (e.g.
343-
``createToken()``)::
345+
// ...
346+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
344347

348+
class LoginAuthenticator extends AbstractAuthenticator
349+
{
345350
// ...
346-
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
347351

348-
class LoginAuthenticator extends AbstractAuthenticator
352+
public function authenticate(Request $request): PassportInterface
349353
{
350-
// ...
354+
// ... process the request
351355

352-
public function authenticate(Request $request): Passport
353-
{
354-
// ... process the request
356+
$passport = new SelfValidatingPassport(new UserBadge($username), []);
355357

356-
$passport = new SelfValidatingPassport(new UserBadge($username), []);
358+
// set a custom attribute (e.g. scope)
359+
$passport->setAttribute('scope', $oauthScope);
357360

358-
// set a custom attribute (e.g. scope)
359-
$passport->setAttribute('scope', $oauthScope);
360-
361-
return $passport;
362-
}
361+
return $passport;
362+
}
363363

364-
public function createToken(Passport $passport, string $firewallName): TokenInterface
365-
{
366-
// read the attribute value
367-
return new CustomOauthToken($passport->getUser(), $passport->getAttribute('scope'));
368-
}
364+
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
365+
{
366+
// read the attribute value
367+
return new CustomOauthToken($passport->getUser(), $passport->getAttribute('scope'));
369368
}
369+
}

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 --full
56+
$ symfony new my_project_directory --full
5757
5858
# run this if you are building a microservice, console application or API
59-
$ symfony new my_project_name
59+
$ symfony new my_project_directory
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 my_project_name
71+
$ composer create-project symfony/website-skeleton my_project_directory
7272
7373
# run this if you are building a microservice, console application or API
74-
$ composer create-project symfony/skeleton my_project_name
74+
$ composer create-project symfony/skeleton 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)