-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Option to disable 'request-id' header #4192
Option to disable 'request-id' header #4192
Comments
It is already doable (not straight forward tbh)
What I understood is that you don't want to log the |
@Eomm Thank you for the quick reply. This is the internal code: The only way is to (like you did) change the |
Oh, I got it! The issue here is to choose the priority of the genId option over the header 👍🏼 Yeah, I agree! Would you like to submit a pr? |
I think a better implementation is to move that Would you like to send a PR? |
@mcollina Sorry, I don't think I understand how/what you mean. Simply |
Just move the check inside |
Okey, I have a PR, it's my first one ever. It does not use the Maybe in 2 weeks I have time to dig deeper... |
* add option to disable/ignore request-id header fixes #4192 * add more restrictive schema definition * update configValidator generated by running 'node build/build-validation.js' after change on 'build-validation.js' * move logic into reqIdGenFactory * update docs for requestHeaderId Adding documentation for opt-out of 'requestHeaderId'
* add option to disable/ignore request-id header fixes #4192 * add more restrictive schema definition * update configValidator generated by running 'node build/build-validation.js' after change on 'build-validation.js' * move logic into reqIdGenFactory * change default value from requestIdHeader Changes default from 'request-id' to `false`. Making it opt-in instead of opt-out. NOTE: when user sets requestIdHeader to `true` the behavior is the same as if it was set to `false` because `req.headers[true] || genReqId(req)` is equivalent to `genReqId(req)` (req.headers[true] is undefined). TL;DR requestIdHeader must be a string, else it will be 'ignored'. Solution: Provide a default value for requestIdHeader when `true` or throw. * remove comment * adapt --------- Co-authored-by: Uzlopak <[email protected]>
Prerequisites
🚀 Feature Proposal
Add a option to disable
requestIdHeader
overwritinggenReqId
Motivation
As far as I understand, fastify will by default use the value of the
requestIdHeader
,if such a header is present in the request, over thegenReqId
value.Now, one does not necessarily know that a server is a fastify server, and one can change (obfuscate) the header key, but essentially a malicious actor could pass the same request-id for all requests and therefore reduce the quality of the logs. If one is trying to investigate an incident multiple requests now share the same id.
This is of low impact I'd assume, still I think it would be nice to disable this behaviour in a proper way instead of relying on obfuscation.
Example
The text was updated successfully, but these errors were encountered: