Skip to content

[MonologBridge] Added SwitchUserTokenProcessor to log the impersonator #37704

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

Conversation

ihortymoshenko
Copy link

@ihortymoshenko ihortymoshenko commented Jul 29, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

This pull request adds the ability to log the impersonator user in case of user impersonation feature usage. The current TokenProcessor logs only the current token and there are no ability to simply log the original token, so we need to copy-paste the TokenProcessor and change a few lines to log the original token

@ihortymoshenko ihortymoshenko force-pushed the feature/monolog-bridge-processor-switch-user-token branch 5 times, most recently from 862ad2b to 3ea8997 Compare July 30, 2020 08:05
@nicolas-grekas nicolas-grekas changed the title [MonologBridge] Added SwitchUserTokenProcessor to log the impersonato… [MonologBridge] Added SwitchUserTokenProcessor to log the impersonator Jul 30, 2020
@nicolas-grekas nicolas-grekas added this to the next milestone Jul 30, 2020
@lyrixx
Copy link
Member

lyrixx commented Jul 30, 2020

Hello,

Thanks for your first contribution.

I like a lot your idea 👍🏼 Thanks.

I have a question about the implementation : Why did you choose the create two Processor instead of doing all the work in the existing processor?

@ihortymoshenko
Copy link
Author

ihortymoshenko commented Jul 31, 2020

@lyrixx,

I have added the second processor in order to separate processing of tokens. In my opinion, tokens should be processed by their own processors. Moreover, some projects may not use user impersonation feature, and an abstract processor provides the ability to easily implement your own processor

*/
protected function getKey(): string
{
return 'original_token';
Copy link
Contributor

@ogizanagi ogizanagi Aug 12, 2020

Choose a reason for hiding this comment

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

I know it's the legacy naming, but I don't really like original_token which kind of misses some context. What about impersonating_token or impersonator_token instead?

Copy link
Author

Choose a reason for hiding this comment

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

I have used the original_token key because of the original (impersonator) token's getter has name getOriginalToken. As for me, the impersonator_token key is more suitable, but I am not sure that is a good idea to change the original_token key to impersonator_token until the original token's getter is renamed to getImpersonatorToken

Copy link
Contributor

Choose a reason for hiding this comment

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

As someone looking at the logs or Sentry reports for instance, impersonator_token is more meaningful than original_token though. The internal name in the code does not matter in this regard.

Copy link
Author

Choose a reason for hiding this comment

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

I can rename

Copy link
Member

Choose a reason for hiding this comment

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

I would use impersonator_token.

Copy link
Author

Choose a reason for hiding this comment

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

Changed to impersonator_token

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

LGTM (apart from the renaming of the key)

*/
protected function getKey(): string
{
return 'original_token';
Copy link
Member

Choose a reason for hiding this comment

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

I would use impersonator_token.

@fabpot fabpot force-pushed the feature/monolog-bridge-processor-switch-user-token branch from 885a1d7 to 2f8651d Compare September 7, 2020 13:03
@fabpot
Copy link
Member

fabpot commented Sep 7, 2020

Thank you @IgorTimoshenko.

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.

6 participants