Knowledge Base > Diffblue Cover Reports > 4. Authenticating Cover Reports Uploads

Authenticating Cover Reports Uploads

By default, Diffblue Cover will allow any user to upload files to Cover Reports. However, you may want to limit access so that only certain users can upload files.

For example, you may choose to enable authentication if you only want your CI processes to upload data for a project, so that data is comparable and uploaded with a consistent timespan.

Enabling authentication on upload

First, you will have to stop your Cover Reports instance, if it is currently running:

docker compose down

Next, take a look inside your docker-compose.yml file. Inside this file, you should see some code that looks like this:

  report-web:
    depends_on:
      postgres:
        condition: service_started
      redash:
        condition: service_started
    environment:
      DASHBOARD_REDASHURL: http://redash:5000/
      DASHBOARD_REDASHUSEREMAIL: [email protected]

Add in two new variables: DASHBOARD_REQUIREDUSERNAME and DASHBOARD_REQUIREDPASSWORD, providing them with your own chosen username and password. For example, if you chose username and password (which is not recommended), your docker-compose.yml file should now look like this:

  report-web:
    depends_on:
      postgres:
        condition: service_started
      redash:
        condition: service_started
    environment:
      DASHBOARD_REQUIREDUSERNAME: username
      DASHBOARD_REQUIREDPASSWORD: password
      DASHBOARD_REDASHURL: http://redash:5000/
      DASHBOARD_REDASHUSEREMAIL: [email protected]

Note Due to a know issue with certain text, we advise that you use ASCII characters only in your username and password. In addition, please do not use an empty string as a username or password: this may cause unexpected behaviour.

Finally, save the changes you have made to docker-compose.yml and start up your Cover Reports instance:

docker compose up

Uploading data to Cover Reports with authentication enabled

Now that you have enabled authentication, you will be unable to upload data to Cover Reports as before.

You will now have to supply two extra options when uploading data: --report-username and --report-password. For the upload to be successful, the values that you pass via these options must match the username and password set in the docker-compose.yml file earlier.

Using the example before, with a set username and password of username and password, a command to generate and upload data to Cover Reports might look like:

dcover create
--coverage-reports
--report http://cover-reports-service
--project "customer-markets.trading.name.name"
--name "Branch: 1234/feature-TG12345"
--report-username "username"
--report-password "password"

The same options can also be used with the upload command. An example with dcover upload might look like:

dcover upload http://cover-reports-service
--project "customer-markets.trading.name.name"
--name "Branch: 1234/feature-TG12345"
--report-username "username"
--report-password "password"

Using Environment Variables

If you don’t want to supply the --report-username and --report-password options each time, you can instead use environment variables.

The environment variables that you’ll need to set are:

  • DIFFBLUE_REPORT_USERNAME
  • DIFFBLUE_REPORT_PASSWORD

As with the command line options, these variables must match the username and password set in docker-compose.yml for your Cover Reports upload to be successful.

Suggested next page

Navigating through Cover Reports