Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-71189

Show username instead of user key in the audit logs when a user is added to a project role

    XMLWordPrintable

Details

    Description

      Description

      When a user is added to a project role, when checking the Audit logs, this user is referred to by its "user key" instead of its username:

      With the recent GDPR changes introduced in Jira 8.4, the user keys or newly created users have the format JIRAUSERXXXXX, which makes it impossible to know which users were added to a specific role from the Audit Logs. Instead, the Jira admin user needs to have access to the DB and query the app_user table to find the relationship between the user key and the user name.

      Step to reproduce

      1. Install Jira 8.4 or any higher version
      2. Create a new user
      3. Add this user to any project role
      4. Go to the page ⚙ > System > Audit Logs
      5. Look for the entry corresponding to the addition of the user to a project role, and verify that the user key is displayed instead of the username

      Suggestion

      Instead of using user_key, the Audit Logs should show the username as it's more relevant to the users. Note that it's already the case when a user is added to a group (as shown in the screenshot below), so the Audit Logs should be consistent and show the username whenever some modifications is made to a user.

      Workaround

      You may leverage the following front-end based workaround, which upon loading the Project based or Global based audit logs, will dynamically look up and replace user keys with their user names. It has been tested on Jira 8.20.10 only, it might not work on other versions.

      Installing

      1. Add the following script to Jira's Announcement Banner: JRASERVER-71189-v3.js

      Theory of operation

      • We place a script in Jira's announcement banner. It only loads on the Audit log pages
      • When a user clicks on a button, the script check's if the row for the button is a "Project role changed" row. If it is, then it will find user keys within the audit entry, and individually sends a request to the server to obtain the user object for the keys listed
      • The returned value from the server contains the username and the user key. The script finds all other occurrences to this user key within the Audit log page, and replaces them with the user key. This is a performance optimisation to avoid repeat lookups. It also marks the changed entries as modified, so entries already resolved won't get resolved again upon row expansion/contraction
      • The script considers contacting the server as little as possible. For any given page of data, a user key is only requested once, even if it has multiple entries in the page. Data isn't loaded in bulk, so the maximum sequentially queued requests to the server is equal to the unique number of usernames within the row that was expanded

      Limitations

      • It is only tested in Jira 8.20.10. While I tried to make it as resilient to version changes as possible, there is no guarantee it would work on a future version of Jira
      • It does not fix the audit log REST API nor does it fix the export feature

       

      Attachments

        1. AuditLog_UserManagement.png
          AuditLog_UserManagement.png
          32 kB
        2. AuditLog_ProjectRole.png
          AuditLog_ProjectRole.png
          65 kB
        3. JRASERVER-71189-v3.js
          5 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jrey Julien Rey
              Votes:
              47 Vote for this issue
              Watchers:
              37 Start watching this issue

              Dates

                Created:
                Updated: