Skip to content
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

[Security] UserBadge->userLoader always overwritten by AccessTokenAuthenticator->userProvider when later is set regardless of former #51446

Closed
kaznovac opened this issue Aug 21, 2023 · 2 comments

Comments

@kaznovac
Copy link
Contributor

Symfony version(s) affected

6.3.3

Description

This is not conforming behavior to the documentation on the UserBadge.

How to reproduce

Implement AccessTokenHandler returning the UserBadge with custom userLoader

<?php

namespace App\Security;

use App\Services\UserService;
use SensitiveParameter;
use Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;

final class AccessTokenHandler implements AccessTokenHandlerInterface
{
    public function __construct(
        private UserService $userService,
    ) {
    }

    public function getUserBadgeFrom(
        #[SensitiveParameter]
        string $accessToken,
    ): UserBadge {
        $user = $this->userService->getUserByAccessToken($accessToken);

        return new UserBadge(
            userIdentifier: $user->getUserIdentifier(),
            userLoader: fn() => $user,
        );
    }
}

Possible Solution

No response

Additional Context

No response

@guillaumesmo
Copy link
Contributor

Duplicate of #50511

@stof
Copy link
Member

stof commented Aug 25, 2023

Closing this thanks to #51104

@stof stof closed this as completed Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants