Add Jira Connect public key storage
All threads resolved!
All threads resolved!
Compare changes
Files
7@@ -2,16 +2,15 @@
This is part of #372967 (closed). See !96818 (closed) for a full context MR.
When a user installs the GitLab for Jira app we receive an installed hook. It includes a JWT token that we have to verify using a public key. The public key is fetched from connect-install-keys.atlassian.com
(see lib/atlassian/jira_connect/jwt/asymmetric.rb:15).
To make the app available for self-managed users, GitLab.com will serve as a proxy. It forwards the installed hook to the self-managed instance, but generates a new JWT token. To make this work, we need to:
https://connect-install-keys.atlassian.com
and can be pointed to https://gitlab.com/-/jira_connect/-/jira_connect/public_keys
.instance_url
is updated.I explained the problem in more detail in #372967 (closed)
rails c
jira_connect_oauth_self_managed
feature: Feature.enable(:jira_connect_oauth_self_managed)
# Create a JiraConnect installation
installation = JiraConnectInstallation.create(client_key: '123', shared_secret: '123', base_url: 'https://sample.atlassian.net')
# Generate a new JWT token for the installation
jwt = JiraConnect::CreateAsymmetricJwtService.new(installation).execute
# Fetch the public key ID from the JWT header. The 3rd parameter defines if the decoding should be verified with a public key. In this case, it is not.
key_id = Atlassian::Jwt.decode(jwt, nil, false, algorithm: 'RS256').last['kid']
# Retrieve the public key from storage
public_key_string = Gitlab::HTTP.get('http://127.0.0.1:3000/-/jira_connect/public_keys/' + key_id).body
# Read the public key
public_key = OpenSSL::PKey.read(public_key_string)
# Do a verified decoding of the JWT using the public key
Atlassian::Jwt.decode(jwt, public_key, true, algorithm: 'RS256').first.present?
true
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.