Code Monkey home page Code Monkey logo

Comments (6)

nicklas-dohrn avatar nicklas-dohrn commented on June 12, 2024

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.

acwwat avatar acwwat commented on June 12, 2024

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.

MANUGUPTASAP avatar MANUGUPTASAP commented on June 12, 2024

Hi @acwwat @nicklas-dohrn

Do we have any update on this issue ?
I am also looking for similar kind of feature.

Thanks

from cf-nodejs-logging-support.

nicklas-dohrn avatar nicklas-dohrn commented on June 12, 2024

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.

christiand93 avatar christiand93 commented on June 12, 2024

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.

christiand93 avatar christiand93 commented on June 12, 2024

This feature is available as of version 6.11.0

from cf-nodejs-logging-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.