diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 03:08:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 03:08:54 +0000 |
commit | 5ee120f46740efac7b8a460d7a92e4da82f4fb0b (patch) | |
tree | b44d3bef04e9db472913289e6b53e58a14cb3e61 /app/controllers | |
parent | 72721699f11187199e89631ce0b5e3d2f7c167e9 (diff) | |
download | gitlab-ce-5ee120f46740efac7b8a460d7a92e4da82f4fb0b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/oauth/applications_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/oauth/token_info_controller.rb | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index f0e6cebe0e4..2c3e60d12b7 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -8,6 +8,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController include Gitlab::Experimentation::ControllerConcern include InitializesCurrentUserMode + # Defined by the `Doorkeeper::ApplicationsController` and is redundant as we call `authenticate_user!` below. Not + # defining or skipping this will result in a `403` response to all requests. + skip_before_action :authenticate_admin! + prepend_before_action :verify_user_oauth_applications_enabled, except: :index prepend_before_action :authenticate_user! before_action :add_gon_variables diff --git a/app/controllers/oauth/token_info_controller.rb b/app/controllers/oauth/token_info_controller.rb new file mode 100644 index 00000000000..492c24b53b1 --- /dev/null +++ b/app/controllers/oauth/token_info_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class Oauth::TokenInfoController < Doorkeeper::TokenInfoController + def show + if doorkeeper_token && doorkeeper_token.accessible? + token_json = doorkeeper_token.as_json + + # maintain backwards compatibility + render json: token_json.merge( + 'scopes' => token_json[:scope], + 'expires_in_seconds' => token_json[:expires_in] + ), status: :ok + else + error = Doorkeeper::OAuth::ErrorResponse.new(name: :invalid_request) + response.headers.merge!(error.headers) + render json: error.body, status: error.status + end + end +end |