Skip to content

[Security] Replace deprecated PassportInterface occurrences by Passport #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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2021

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Aug 6, 2021

Fixes #15593

@@ -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?

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:

public function createAuthenticatedToken(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);
}

public function createToken(PassportInterface $passport, string $firewallName): TokenInterface
{
    // @deprecated since Symfony 5.4, in 6.0 change to:
    // return $this->authenticator->createToken($passport, $firewallName);
    return method_exists($this->authenticator, 'createToken')
        ? $this->authenticator->createToken($passport, $firewallName)
        : $this->authenticator->createAuthenticatedToken($passport, $firewallName);
}

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

Copy link
Member

@wouterj wouterj Aug 9, 2021

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) use createToken(Passport $passport, ...)

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

@carsonbot carsonbot changed the title Replace deprecated PassportInterface occurrences by Passport [Security] Replace deprecated PassportInterface occurrences by Passport Aug 9, 2021
@javiereguiluz javiereguiluz added this to the 5.4 milestone Aug 9, 2021
@javiereguiluz
Copy link
Member

Thank you Robin.

@javiereguiluz javiereguiluz merged commit 5872939 into symfony:5.4 Aug 9, 2021
@chalasr chalasr deleted the passport-interface-deprec branch August 9, 2021 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security] Deprecate PassportInterface
4 participants