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

User is not set when logged in programatically #706

Closed
nesl247 opened this issue Mar 27, 2023 · 8 comments · Fixed by #720
Closed

User is not set when logged in programatically #706

nesl247 opened this issue Mar 27, 2023 · 8 comments · Fixed by #720

Comments

@nesl247
Copy link

nesl247 commented Mar 27, 2023

Currently the user data is set via

$userData = new UserDataBag();
$userData->setIpAddress($event->getRequest()->getClientIp());
if (null !== $this->tokenStorage) {
$this->setUserData($userData, $this->tokenStorage->getToken());
}
$this->hub->configureScope(static function (Scope $scope) use ($userData): void {
$scope->setUser($userData);
});

However, this means that programmatic logins do not add the user data to the event. Instead, an authentication listener should be used so that anywhere a user is logged in, the data is added to the span.

@antonpirker
Copy link
Member

Hey @nesl247 !

Thanks for writing in!
Our own PHP wizard @cleptric is currently out of office, so he will have a look at this when he returns next week.

@xosofox
Copy link

xosofox commented Apr 19, 2023

Looks like a change from TokenStorage to Security could help to get the user in more cases.

However, Symfony\Component\Security\Core\Security is deprecated in favor of Symfony\Bundle\SecurityBundle\Security, so the bundle would be another dependency for the project.

Not sure though, if the TokenStorage is meant to stay and a change is required anyway

@nesl247
Copy link
Author

nesl247 commented Apr 27, 2023

@xosofox I'm not sure how that would assist? The listener is only on request, not on authentication success, which is the entire point of this issue.

@antonpirker any update?

@cleptric
Copy link
Member

We’ll look at this at a later date, but it’s in our backlog.

@ste93cry
Copy link
Collaborator

Just to let you know so that we avoid double work, I’m working to see what we can do to solve this issue. I hope to open a PR soon with the changes 🔜

@ste93cry
Copy link
Collaborator

@nesl247 we're really close to merge the PR that should fix the problem. It would be cool if you could try the branch and let me know if everything works properly 😃

@nesl247
Copy link
Author

nesl247 commented Jul 27, 2023

@nesl247 we're really close to merge the PR that should fix the problem. It would be cool if you could try the branch and let me know if everything works properly 😃

Unfortunately the code base we were running into this issue on became a PoC we put aside. We'll eventually run into this problem again in our current code base, but it'll be a little bit before I get there, so I don't really have a way to test it out in a production or even a pre-production environment.

@ste93cry
Copy link
Collaborator

Don’t worry, thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants