Skip to content

[Security] add impersonator_user to "User was reloaded" log message #24026

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

Closed
wants to merge 3 commits into from

Conversation

gharlan
Copy link
Contributor

@gharlan gharlan commented Aug 29, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

My main concern is this: I use the swift monolog handler to get emails for exceptions.
I would like to see the impersonator in these mails.

But I'm not sure, if this is a good place for the log message.

@gharlan
Copy link
Contributor Author

gharlan commented Aug 29, 2017

It looks like this:

screenshot 2017-08-29 19 17 57

@chalasr chalasr self-requested a review August 29, 2017 17:46
@chalasr
Copy link
Member

chalasr commented Aug 29, 2017

The new entry seems redundant with the previous one (logged by refreshUser()), couldn't we enhance it instead?

@chalasr chalasr added this to the 3.4 milestone Aug 29, 2017
@gharlan
Copy link
Contributor Author

gharlan commented Aug 29, 2017

I agree and would be happy to reduce the messages.
But I'm not sure if the "User was reloaded from a user provider" message is the "correct" place to provide the impersonator.

@chalasr
Copy link
Member

chalasr commented Aug 29, 2017

Actually only the user is refreshed, not the token itself :)
Personally I'm fine with adding such info to the existing log (the key should be impersonator_username to be consistent with username and because user feels like it holds the whole user object).
About the token_class var, I think that having it in the very first log (Read existing security token from session.) would be useful as well, WDYT?

@gharlan
Copy link
Contributor Author

gharlan commented Aug 30, 2017

Like this (code changed)?

screenshot 2017-08-30 11 12 43

$this->logger->debug('User was reloaded from a user provider.', array(
'provider' => get_class($provider),
'username' => $refreshedUser->getUsername(),
'impersonator_username' => $impersonatorUsername,
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to see this info only on switching user, so maybe impersonator_username could be ignored if is it null?

Copy link
Member

Choose a reason for hiding this comment

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

agreed, let's not add it if no switch_user in place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldnt it be impersonated_username?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right :) i mixed up.

In some cases you may need to get the object that represents the impersonating user rather than the impersonated user.

impersonating_username then?

cc @gharlan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Right :) 👍

@gharlan gharlan changed the title [Security] add log message containing user and impersonator_user [Security] add impersonator_user to "User was reloaded" log message Aug 31, 2017
@fabpot
Copy link
Member

fabpot commented Aug 31, 2017

Thank you @gharlan.

@fabpot fabpot closed this Aug 31, 2017
fabpot added a commit that referenced this pull request Aug 31, 2017
…" log message (gharlan)

This PR was squashed before being merged into the 3.4 branch (closes #24026).

Discussion
----------

[Security] add impersonator_user to "User was reloaded" log message

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

My main concern is this: I use the swift monolog handler to get emails for exceptions.
I would like to see the impersonator in these mails.

But I'm not sure, if this is a good place for the log message.

Commits
-------

fc44215 [Security] add impersonator_user to "User was reloaded" log message
@gharlan gharlan deleted the log_token branch August 31, 2017 18:46
xabbuh added a commit to symfony/symfony-docs that referenced this pull request Sep 1, 2017
…ing user" (chalasr)

This PR was merged into the 2.7 branch.

Discussion
----------

[Security] Use "impersonator user" instead of "impersonating user"

Feels better to me, it's also consistent with the profiler's security panel (and a log being introduced in symfony/symfony#24026).

Commits
-------

6509fc9 Use "impersonator user" instead of "impersonating user"
This was referenced Oct 18, 2017
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