diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /app/controllers/jira_connect | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'app/controllers/jira_connect')
3 files changed, 39 insertions, 6 deletions
diff --git a/app/controllers/jira_connect/events_controller.rb b/app/controllers/jira_connect/events_controller.rb index 1ea0a92662b..327192857f6 100644 --- a/app/controllers/jira_connect/events_controller.rb +++ b/app/controllers/jira_connect/events_controller.rb @@ -7,11 +7,13 @@ class JiraConnect::EventsController < JiraConnect::ApplicationController before_action :verify_asymmetric_atlassian_jwt! def installed - return head :ok if current_jira_installation + unless Feature.enabled?(:jira_connect_installation_update, default_enabled: :yaml) + return head :ok if current_jira_installation + end - installation = JiraConnectInstallation.new(event_params) + success = current_jira_installation ? update_installation : create_installation - if installation.save + if success head :ok else head :unprocessable_entity @@ -28,8 +30,24 @@ class JiraConnect::EventsController < JiraConnect::ApplicationController private - def event_params - params.permit(:clientKey, :sharedSecret, :baseUrl).transform_keys(&:underscore) + def create_installation + JiraConnectInstallation.new(create_params).save + end + + def update_installation + current_jira_installation.update(update_params) + end + + def create_params + transformed_params.permit(:client_key, :shared_secret, :base_url) + end + + def update_params + transformed_params.permit(:shared_secret, :base_url) + end + + def transformed_params + @transformed_params ||= params.transform_keys(&:underscore) end def verify_asymmetric_atlassian_jwt! @@ -43,7 +61,7 @@ class JiraConnect::EventsController < JiraConnect::ApplicationController def jwt_verification_claims { aud: jira_connect_base_url(protocol: 'https'), - iss: event_params[:client_key], + iss: transformed_params[:client_key], qsh: Atlassian::Jwt.create_query_string_hash(request.url, request.method, jira_connect_base_url) } end diff --git a/app/controllers/jira_connect/oauth_callbacks_controller.rb b/app/controllers/jira_connect/oauth_callbacks_controller.rb new file mode 100644 index 00000000000..f603a563402 --- /dev/null +++ b/app/controllers/jira_connect/oauth_callbacks_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# This controller's role is to serve as a landing page +# that users get redirected to after installing and authenticating +# The GitLab.com for Jira App (https://marketplace.atlassian.com/apps/1221011/gitlab-com-for-jira-cloud) +# +class JiraConnect::OauthCallbacksController < ApplicationController + feature_category :integrations + + def index; end +end diff --git a/app/controllers/jira_connect/subscriptions_controller.rb b/app/controllers/jira_connect/subscriptions_controller.rb index fcd95c7942c..ec6ba07a125 100644 --- a/app/controllers/jira_connect/subscriptions_controller.rb +++ b/app/controllers/jira_connect/subscriptions_controller.rb @@ -16,6 +16,10 @@ class JiraConnect::SubscriptionsController < JiraConnect::ApplicationController p.style_src(*style_src_values) end + before_action do + push_frontend_feature_flag(:jira_connect_oauth, @user, default_enabled: :yaml) + end + before_action :allow_rendering_in_iframe, only: :index before_action :verify_qsh_claim!, only: :index before_action :authenticate_user!, only: :create |