Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[MonologBridge] Add TokenProcessor#21086
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
maidmaid commentedDec 28, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
If this feature will be merged, is it a good idea to register this processor in |
Would this add the token to every log line? Because I don't want to see the token added 10x if my log contains 10 log lines to be honest. The idea is great though, I'm using a custom formatter for the logging at the moment and I rather have this in the core. |
@iltar Yes it will. That's how processor works. But:
|
I have improved token normalization that now is more json-like/readable:
|
$records['extra']['token'] = (string) $token; | ||
$records['extra']['token'] = array( | ||
'username' => $token->getUsername(), | ||
'auth.' => $token->isAuthenticated(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I suggest to call this keyauthenticated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Indeed
@@ -25,6 +25,7 @@ public function __invoke(array $record) | |||
'timestamp' => $record['datetime']->getTimestamp(), | |||
'message' => $record['message'], | |||
'priority' => $record['level'], | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should be reverted
'auth.' => $token->isAuthenticated(), | ||
'roles' => array_map(function (Role $role) { | ||
return $role->getRole(); | ||
}, $token->getRoles()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should be on one line
use Symfony\Component\Security\Core\Role\Role; | ||
/** | ||
* TokenProcessor adds token extra info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
"Adds the current security token to the log entry."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Indeed, it's better.
return $records; | ||
} | ||
public function isDeniedProcess() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is this method really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In CLI mode,extra.token
should not be added, for example in commands but not in tests. This method allowsto mock this behavior in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
In CLI mode, extra.token should not be added
Why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I was more referring to this being a dedicated method while it could easily be inlined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Furthermore, a method beingpublic
is an extension point which we would have to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Indeed, this is not very helpful. I have removed this method.
You need to add the |
$records['extra']['token'] = array( | ||
'username' => $token->getUsername(), | ||
'authenticated' => $token->isAuthenticated(), | ||
'roles' => array_map(function (Role $role) { return $role->getRole(); }, $token->getRoles()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should beRoleInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
RoleInterface
is now deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
And not yet removed, they are still returned fromgetRoles
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍 it's done
I updated the |
AppVeyor break tests are related? |
AppVeyor Failure seems unrelated. |
ac46318
toef3e18c
Compare9210609
to26b9d1f
ComparePR ready to merge since some time :) |
👍 |
@@ -23,6 +23,7 @@ | |||
"require-dev": { | |||
"symfony/console": "~2.8|~3.0|~4.0", | |||
"symfony/event-dispatcher": "~2.8|~3.0|~4.0", | |||
"symfony/security-core": "~2.8|~3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
missing|~4.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
RoleInterface
is used here, and will be removed in 4.0.
nicolas-grekasJul 12, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
then I suggest to remove the type hint, it's purely internal and doesn't justify a deps limitation
Thank you@maidmaid. |
This PR was merged into the 3.4 branch.Discussion----------[MonologBridge] Add TokenProcessor| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/a``TokenProcessor`` is an out-of-the-box class that adds token in extra info log, like this:```[2016-12-29 14:48:09] app.INFO: admin connected! [] {"token":{ "username":"admin", "authenticated":true, "roles":["ROLE_ADMIN"]}}```Commits-------3763515 Add TokenProcessor
Uh oh!
There was an error while loading.Please reload this page.
TokenProcessor
is an out-of-the-box class that adds token in extra info log, like this: