Add and expose Jira app OAuth application ID
What does this MR do and why?
This adds a new application setting, so users can enter the ID of the OAuth application they created to use the GitLab for Jira app on self-managed.
GitLab.com will serve as a proxy for the app. This means it will need to fetch the application ID from the self-managed instance in order to initialize the OAuth login flow. Therefor, the application ID setting is publicly exposed.
Once the feature is done, the workflow will be like this:
- User installs the GitLab for Jira app
- User chooses self-managed and enters the GitLab instance URL like in this screenshot
- Frontend calls
http://gl-instance-url.com/-/jira_connect/oauth_application_id
and fetches the application ID - Frontend uses the application ID to initialize an OAuth flow, log in the user, and fetch a user token to make API requests on the instance.
This MR does not include documentation or API changes because it is behind the jira_connect_oauth_self_managed
feature flag and the jira_connect_oauth
feature flag
Related issue: #353328 (closed) and #338459 (closed)
Database
This adds two new migrations:
- Add
jira_connect_application_key
toapplication_settings
- Add text limit for
jira_connect_application_key
Migration up:
== 20220513114706 AddJiraConnectApplicationIdApplicationSetting: migrating ====
-- add_column(:application_settings, :jira_connect_application_key, :text)
-> 0.0097s
== 20220513114706 AddJiraConnectApplicationIdApplicationSetting: migrated (0.0098s)
== 20220513114850 AddTextLimitToJiraConnectApplicationIdApplicationSetting: migrating
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0030s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE application_settings\nADD CONSTRAINT check_e2dd6e290a\nCHECK ( char_length(jira_connect_application_key) <= 255 )\nNOT VALID;\n")
-> 0.0124s
-- current_schema()
-> 0.0061s
-- execute("SET statement_timeout TO 0")
-> 0.0014s
-- execute("ALTER TABLE application_settings VALIDATE CONSTRAINT check_e2dd6e290a;")
-> 0.0265s
-- execute("RESET statement_timeout")
-> 0.0013s
== 20220513114850 AddTextLimitToJiraConnectApplicationIdApplicationSetting: migrated (0.1005s)
Migration down:
== 20220513114850 AddTextLimitToJiraConnectApplicationIdApplicationSetting: reverting
-- transaction_open?()
-> 0.0000s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE application_settings\nDROP CONSTRAINT IF EXISTS check_e2dd6e290a\n")
-> 0.0056s
== 20220513114850 AddTextLimitToJiraConnectApplicationIdApplicationSetting: reverted (0.0485s)
== 20220513114706 AddJiraConnectApplicationIdApplicationSetting: reverting ====
-- remove_column(:application_settings, :jira_connect_application_key, :text)
-> 0.0058s
== 20220513114706 AddJiraConnectApplicationIdApplicationSetting: reverted (0.0144s)
Screenshots or screen recordings
See &5650 (closed)
How to set up and validate locally
- On rails console, run
Feature.enable(:jira_connect_oauth_self_managed)
- Visit
http://localhost:3000/admin/application_settings/general
- Scroll down and expand the GitLab for Jira App section
- Enter any value
- Visit
http://localhost:3000/-/jira_connect/oauth_application_id
- See the value you entered
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.