summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Baum <ibaum@gitlab.com>2018-09-07 11:06:08 -0500
committerIan Baum <ibaum@gitlab.com>2018-09-07 11:06:08 -0500
commit582d2da0b627be83783540d21c45dbc9e0cb53b9 (patch)
treeb57b9f5656c9f3e02958a8e6347ebcab7a8175bc
parent5b52423628bcb09aa66120cd14f33c94e1f19a5e (diff)
downloadgitlab-ce-flat-rails5-gemfile.tar.gz
Removing doorkeeper monkey patchflat-rails5-gemfile
-rw-r--r--config/initializers/doorkeeper.rb50
1 files changed, 0 insertions, 50 deletions
diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb
index f321b4ea763..fe66a696822 100644
--- a/config/initializers/doorkeeper.rb
+++ b/config/initializers/doorkeeper.rb
@@ -106,53 +106,3 @@ Doorkeeper.configure do
base_controller '::Gitlab::BaseDoorkeeperController'
end
-
-# Monkey patch to avoid creating new applications if the scope of the
-# app created does not match the complete list of scopes of the configured app.
-# It also prevents the OAuth authorize application window to appear every time.
-
-# Remove after we upgrade the doorkeeper gem from version 4.3.2
-if Doorkeeper.gem_version > Gem::Version.new('4.3.2')
- raise "Doorkeeper was upgraded, please remove the monkey patch in #{__FILE__}"
-end
-
-module Doorkeeper
- module AccessTokenMixin
- module ClassMethods
- def matching_token_for(application, resource_owner_or_id, scopes)
- resource_owner_id =
- if resource_owner_or_id.respond_to?(:to_key)
- resource_owner_or_id.id
- else
- resource_owner_or_id
- end
-
- tokens = authorized_tokens_for(application.try(:id), resource_owner_id)
- tokens.detect do |token|
- scopes_match?(token.scopes, scopes, application.try(:scopes))
- end
- end
-
- def scopes_match?(token_scopes, param_scopes, app_scopes)
- return true if token_scopes.empty? && param_scopes.empty?
-
- (token_scopes.sort == param_scopes.sort) &&
- Doorkeeper::OAuth::Helpers::ScopeChecker.valid?(
- param_scopes.to_s,
- Doorkeeper.configuration.scopes,
- app_scopes)
- end
-
- def authorized_tokens_for(application_id, resource_owner_id)
- ordered_by(:created_at, :desc)
- .where(application_id: application_id,
- resource_owner_id: resource_owner_id,
- revoked_at: nil)
- end
-
- def last_authorized_token_for(application_id, resource_owner_id)
- authorized_tokens_for(application_id, resource_owner_id).first
- end
- end
- end
-end