Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Replace deprecatedPassportInterface occurrences byPassport#15594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletionssecurity/authenticator_manager.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -300,7 +300,7 @@ method that fits most use-cases::
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;

class ApiKeyAuthenticator extends AbstractAuthenticator
Expand All@@ -315,7 +315,7 @@ method that fits most use-cases::
return $request->headers->has('X-AUTH-TOKEN');
}

public function authenticate(Request $request):PassportInterface
public function authenticate(Request $request):Passport
{
$apiToken = $request->headers->get('X-AUTH-TOKEN');
if (null === $apiToken) {
Expand DownExpand Up@@ -474,7 +474,7 @@ using :ref:`the user provider <security-user-providers>`::
$this->userRepository = $userRepository;
}

public function authenticate(Request $request):PassportInterface
public function authenticate(Request $request):Passport
{
// ...

Expand DownExpand Up@@ -570,11 +570,11 @@ would initialize the passport like this::
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;

class LoginAuthenticator extends AbstractAuthenticator
{
public function authenticate(Request $request):PassportInterface
public function authenticate(Request $request):Passport
{
$password = $request->request->get('password');
$username = $request->request->get('username');
Expand DownExpand Up@@ -604,7 +604,7 @@ would initialize the passport like this::
{
// ...

public function authenticate(Request $request):PassportInterface
public function authenticate(Request $request):Passport
{
// ... process the request

Expand All@@ -616,7 +616,7 @@ would initialize the passport like this::
return $passport;
}

public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
public function createAuthenticatedToken(Passport $passport, string $firewallName): TokenInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The method should also be renamed, right?

chalasr reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I renamed while merging ... but I have a question. The new code is:

publicfunctioncreateAuthenticatedToken(PassportInterface$passport,string$firewallName):TokenInterface{trigger_deprecation('symfony/ldap','5.4','Method "%s()" is deprecated, use "%s::createToken()" instead.',__METHOD__,__CLASS__);return$this->createToken($passport,$firewallName);}publicfunctioncreateToken(PassportInterface$passport,string$firewallName):TokenInterface{// @deprecated since Symfony 5.4, in 6.0 change to:// return $this->authenticator->createToken($passport, $firewallName);returnmethod_exists($this->authenticator,'createToken')        ?$this->authenticator->createToken($passport,$firewallName)        :$this->authenticator->createAuthenticatedToken($passport,$firewallName);}

So, the method iscreateToken(PassportInterface $passport, ...) but in the docs we usecreateToken(Passport $passport, ...) Do you see a problem here? Thanks!

Copy link
Member

@wouterjwouterjAug 9, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That is a typo in the LDAP authenticator indeed. Other authenticators (including the interface) usecreateToken(Passport $passport, ...)

(and it's not a PHP error, as it's widening the scope of the interface, and thus allowed)

javiereguiluz reacted with thumbs up emoji
{
// read the attribute value
return new CustomOauthToken($passport->getUser(), $passport->getAttribute('scope'));
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp