Comments (6)
Hello acwwat,
You are totally right that the current Readme and implementation is inconsistent.
I looked into this Issue and I found only very sparse Information about remote user usage in nodejs
(some mentioning on Stackoverflow about getRemoteUser in express.js from 2013, but this is outdated information as there is no mention about remoteUser or remote_user in express, restify or nodejs.
So at this point I can only guess, that this might be a set header in a given request, and I named it "remote-user" for extraction by our library.
(currently only available at /master on this repo)
Is this the functionality you are seeking, or is there any standard regarding this topic I missed?
Regards,
Nicklas
from cf-nodejs-logging-support.
Hi Nicklas,
Thanks for your response. Yes this is a functionality I am seeking. More generally, I am looking for similar behavior as @sap/logging where when enabled, the logged in user ID is set in the remote_user field. Here are couple code snippets from @sap/logging which I've been examining that gives some implementation details.
In lib/contexts/EntryContexts.js, observe that it returns req.user.id (which is set by the passport JWT strategy via @sap/wssec) if it exists:
get user() {
const req = this._req;
return req && req.user && req.user.id;
}
I double checked that req.user and req.user.id are standard in passport.js: http://www.passportjs.org/docs/authenticate/
In lib/formats/CFLog.js, observe that it sets the remote_user property in the log record to req.user.id per the code above:
entry['remote_user'] = this._env.logUser ? (entryCtx.user || UNKNOWN_STRING) : 'redacted';
Perhaps to enable the LOG_REMOTE_USER feature, we can follow similar logic in config.js, if I am not way off with my understanding. Please take a look and let me know what you think. Thank you.
Regards,
Anthony
from cf-nodejs-logging-support.
Do we have any update on this issue ?
I am also looking for similar kind of feature.
Thanks
from cf-nodejs-logging-support.
Hello all,
Sorry for me missing to answer here.
the functionality mentioned above is already implemented some time ago.
remote-user is the field where the information is load into, when i last updated the issue.
If you need to overwrite this funcionality, or want to provide different information in the "remote-user" field,
you are able to do it like this:
remote_user_information = this._env.logUser ? (entryCtx.user || UNKNOWN_STRING) : 'redacted';
log.info("write different remote user info", {"remote_user": remote_user_information});
I leave this one open, if this is not the idea you had in mind.
from cf-nodejs-logging-support.
Hi,
I have checked if we can provide a suitable solution for this issue. Reading the user ID from req.user.id
definitely makes sense especially since @sap/application router, passport and CAP support this field. #97 updates the related field configuration and should fix this issue.
from cf-nodejs-logging-support.
This feature is available as of version 6.11.0
from cf-nodejs-logging-support.
Related Issues (20)
- Array with stacktrace is stringified and resulting JSON is incorrect HOT 3
- Removing unnecessary logs HOT 3
- Avoid publishing dev folders like docs & tools HOT 5
- Mend reports for jsonwebtoken-8.5.1 please consider upgrade jsonwebtoken to ^9.0.0 HOT 1
- Possible vulnerability due to missing JWT public key type check
- logMessage is not using the customFields in v7 HOT 2
- CorrelationId not set when creating Child Logger HOT 4
- Fastify support HOT 15
- Winston Support in v7 HOT 3
- Custom fields always converted to strings, even if not necessary.
- custom fields are not logged correctly for request logger HOT 1
- cf-nodejs-logging-support and @sap/logging HOT 4
- using req. context logger in qunit test with nock
- tenant_id still missing in the request logger HOT 3
- ReferenceError: defaultConfig is not defined HOT 1
- Switch off the INFO log on KIBANA HOT 1
- Switch logLevel HOT 3
- Clear (my) confusion: cf-nodejs-logging-support vs @sap/logging HOT 7
- Logs contain incorrect url in "request" field HOT 2
- Extraction of logging level fails with window object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cf-nodejs-logging-support.