Skip to content

Include username in log entry if it is available

Eugie Limpin requested to merge el-include-username-on-log into master

What does this MR do and why?

Partially resolves https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/531

Update Telesign callback request logging to include the username associated with the found (if any) Users::PhoneNumberValidation record. This will make it easier to search for Telesign callback request log entries for a given user.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Note: Use the values below as-is for easier testing

  1. Setup Telesign
    $ rails c
    > ApplicationSetting.first.update(telesign_customer_xid: 'test_cust_id', telesign_api_key: 'test_api_key')
  2. Create a test Users::PhoneNumberValidation record
    $ rails c
    > user = FactoryBot.create(:user, email: 'feb2422@ex.com', username: 'feb2422')
    > FactoryBot.create(:phone_number_validation, telesign_reference_xid: '2557312299CC1304904080F4BE17BFB4', user: user)
  3. Follow the application logs
    $ tail -f log/application_json.log
  4. Send a test callback request
    $ curl -X POST http://localhost:3000/-/phone_verification/telesign_callback -H 'Authorization: TSA test_cust_id:bqeIi0UHnk1inbM3rNGN1JoaPx8YVo7tNU6eOxCFsWY=' -H 'Content-Type: application/json' -d '{ "status": { "updated_on": "2016-07-08T20:52:46.417428Z", "code": 200, "description": "Sent" }, "errors": {}, "reference_id": "2557312299CC1304904080F4BE17BFB4" }'
  5. Validate that you get a log entry that looks like
{"severity":"INFO","time":"2024-02-02T08:51:41.207Z","correlation_id":"01HNMG8BN13S9HWYH8J1V33GET",...,"class":"Telesign::TransactionCallback","username":"feb2422","event":"Telesign transaction status update",...}
Edited by Eugie Limpin

Merge request reports

Loading