Skip to content

Add Jira Connect public key store setting

What does this MR do and why?

This is the first step to replace the gitlab.jira_connect.enable_public_keys_storage config with an application setting.

The config was introduced as a quick way to improve the development experience for the GitLab for Jira app (!105257 (merged)). But our guidelines are to use ApplicationSetting instead of gitlab.yml for new settings.

We cannot replace the config in one step because we have to make sure it is enabled for GitLab.com but disabled for self-managed. The plan is to:

  1. Introduce the Enable public key storage setting. (This MR)
  2. Enable the setting on GitLab.com
  3. Remove the jira_connect.enable_public_keys_storage config.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Create a JiraConnectInstallaion.
    jira_installation = JiraConnectInstallation.create(client_key: '1234', shared_secret: '123', base_url: 'http://test.atlassian.net', instance_url: 'https://example.com')
  2. Generate a JWT token.
    jwt = JiraConnect::CreateAsymmetricJwtService.new(jira_installation).execute
  3. Fetch the kid header from the token.
    Atlassian::Jwt.decode(jwt, nil, false)[1]['kid']
  4. Fetch the public key using the kid header by visiting http://127.0.0.1:3000/-/jira_connect/public_keys/<kid>.
  5. This should show a 404 error.
  6. Go to http://127.0.0.1:3000/admin/application_settings/general.
  7. expand the GitLab for Jira App section.
  8. Select Enable public key storage.
  9. Select Save changes.
  10. Repeat steps 2. - 4. (You can re-use the previous kid but public keys are only available for 5 minutes).
  11. The page should now show the public key.

MR acceptance checklist

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

Related to #384896 (closed)

Edited by Andy Schoenen

Merge request reports