Skip to content

Add access token information to API log

Joern Schneeweisz requested to merge js/add_token_to_logging into master

What does this MR do and why?

This MR will add information about the used access token to the API log.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

image

How to set up and validate locally

  1. Create an access token at http://localhost:3000/-/profile/personal_access_tokens
  2. Use the created access token to access the api:
 curl http://localhost:3000/api/v4/user -H "private-token: <token>"
  1. Observe the token information in gitlab/log/api_json.log:
{
  "time": "2022-07-16T17:34:23.235Z",
  "severity": "INFO",
  "duration_s": 0.15425,
  "db_duration_s": 0.02159,
  "view_duration_s": 0.13266,
  "status": 200,
  "method": "GET",
  "path": "/api/v4/user",
  "params": [],
  "host": "localhost",
  "remote_ip": "127.0.0.1",
  "ua": "curl/7.84.0",
  "route": "/api/:version/user",
  "user_id": 103,
  "username": "project_8_bot",
  "token_type": "PersonalAccessToken",
  "token_id": 9,
...
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Joern Schneeweisz

Merge request reports