Skip to content

Commit

Permalink
add user name to access log
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Oct 4, 2024
1 parent b695c59 commit e3d3ab0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ var constants = {
X_REAL_IP_HEADER: 'x-real-ip',
CORRELATOR_HEADER: 'fiware-correlator',

GET_ROLES_PATH: '/user'
GET_ROLES_PATH: '/user',
NA: 'N/A'
};


Expand Down
1 change: 1 addition & 0 deletions lib/middleware/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function accountInfo(req, res, next) {
' | Token=' + req.headers['x-auth-token'] +
' | Origin=' + req.connection.remoteAddress +
' | UserId=' + req.userId +
' | UserName=' + req.userName +
' | ServiceId=' + req.serviceId +
' | Service=' + req.service +
' | SubServiceId=' + req.subserviceId +
Expand Down
7 changes: 5 additions & 2 deletions lib/services/keystoneAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ function retrieveUser(req, callback) {
req.serviceId = cachedValue.serviceId;
req.domainName = cachedValue.domainName;
req.userId = cachedValue.userId;
req.userName = cachedValue.userName;

logger.debug('User value processed with value: %j', cachedValue);

Expand Down Expand Up @@ -245,7 +246,8 @@ function retrieveUser(req, callback) {
cachedValue = {
domainName: body.token.project.domain.name,
serviceId: body.token.project.domain.id,
userId: body.token['OS-TRUST:trust'].trustor_user.id
userId: body.token['OS-TRUST:trust'].trustor_user.id,
userName: constants.NA
};

innerCb(null, cachedValue);
Expand All @@ -256,7 +258,8 @@ function retrieveUser(req, callback) {
cachedValue = {
domainName: body.token.user.domain.name,
serviceId: body.token.user.domain.id,
userId: body.token.user.id
userId: body.token.user.id,
userName: body.token.user.name
};

req.userData = cachedValue;
Expand Down

0 comments on commit e3d3ab0

Please sign in to comment.