Skip to content

Commit

Permalink
use eezee instead falcon (#5)
Browse files Browse the repository at this point in the history
* use katinguele instead falcon

* change to eezee
  • Loading branch information
linqueta authored Dec 23, 2019
1 parent b9dc240 commit b3359f4
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 83 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

source 'https://rubygems.org'

gem 'falcon', github: 'petlove/falcon'

gemspec
122 changes: 58 additions & 64 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,70 +1,63 @@
GIT
remote: https://github.com/petlove/falcon.git
revision: 374a3a98c4258c72762b4a29821b2458fbe32b67
specs:
falcon (1.0.0)
faraday (>= 0.17.0)

PATH
remote: .
specs:
pitbull (2.0.0)
activesupport (>= 5.0)
falcon
eezee (>= 1.0.9)

GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.2)
actionpack (= 6.0.2)
actioncable (6.0.2.1)
actionpack (= 6.0.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.2)
actionpack (= 6.0.2)
activejob (= 6.0.2)
activerecord (= 6.0.2)
activestorage (= 6.0.2)
activesupport (= 6.0.2)
actionmailbox (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
mail (>= 2.7.1)
actionmailer (6.0.2)
actionpack (= 6.0.2)
actionview (= 6.0.2)
activejob (= 6.0.2)
actionmailer (6.0.2.1)
actionpack (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.2)
actionview (= 6.0.2)
activesupport (= 6.0.2)
rack (~> 2.0)
actionpack (6.0.2.1)
actionview (= 6.0.2.1)
activesupport (= 6.0.2.1)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.2)
actionpack (= 6.0.2)
activerecord (= 6.0.2)
activestorage (= 6.0.2)
activesupport (= 6.0.2)
actiontext (6.0.2.1)
actionpack (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
nokogiri (>= 1.8.5)
actionview (6.0.2)
activesupport (= 6.0.2)
actionview (6.0.2.1)
activesupport (= 6.0.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.2)
activesupport (= 6.0.2)
activejob (6.0.2.1)
activesupport (= 6.0.2.1)
globalid (>= 0.3.6)
activemodel (6.0.2)
activesupport (= 6.0.2)
activerecord (6.0.2)
activemodel (= 6.0.2)
activesupport (= 6.0.2)
activestorage (6.0.2)
actionpack (= 6.0.2)
activejob (= 6.0.2)
activerecord (= 6.0.2)
activemodel (6.0.2.1)
activesupport (= 6.0.2.1)
activerecord (6.0.2.1)
activemodel (= 6.0.2.1)
activesupport (= 6.0.2.1)
activestorage (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
marcel (~> 0.3.1)
activesupport (6.0.2)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand All @@ -84,8 +77,10 @@ GEM
diff-lcs (1.3)
docile (1.3.2)
dotenv (2.7.5)
eezee (1.0.9)
faraday (~> 0.17, >= 0.17.0)
erubi (1.9.0)
faker (2.8.1)
faker (2.9.0)
i18n (>= 1.6, < 1.8)
faraday (0.17.1)
multipart-post (>= 1.2, < 3)
Expand Down Expand Up @@ -122,32 +117,32 @@ GEM
byebug (~> 11.0)
pry (~> 0.10)
public_suffix (4.0.1)
rack (2.0.7)
rack (2.0.8)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.2)
actioncable (= 6.0.2)
actionmailbox (= 6.0.2)
actionmailer (= 6.0.2)
actionpack (= 6.0.2)
actiontext (= 6.0.2)
actionview (= 6.0.2)
activejob (= 6.0.2)
activemodel (= 6.0.2)
activerecord (= 6.0.2)
activestorage (= 6.0.2)
activesupport (= 6.0.2)
rails (6.0.2.1)
actioncable (= 6.0.2.1)
actionmailbox (= 6.0.2.1)
actionmailer (= 6.0.2.1)
actionpack (= 6.0.2.1)
actiontext (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
activemodel (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
bundler (>= 1.3.0)
railties (= 6.0.2)
railties (= 6.0.2.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.2)
actionpack (= 6.0.2)
activesupport (= 6.0.2)
railties (6.0.2.1)
actionpack (= 6.0.2.1)
activesupport (= 6.0.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
Expand All @@ -174,7 +169,7 @@ GEM
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.0)
rubocop (0.77.0)
rubocop (0.78.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
Expand Down Expand Up @@ -203,7 +198,7 @@ GEM
sprockets (>= 3.0.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (1.0.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
Expand All @@ -225,7 +220,6 @@ DEPENDENCIES
bundler (~> 2.0)
dotenv (~> 2.7.5)
faker
falcon!
pitbull!
pry-byebug (>= 3.7.0)
rails (>= 3.8.2)
Expand Down
2 changes: 1 addition & 1 deletion lib/pitbull.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'active_support/all'
require 'falcon'
require 'eezee'
require 'pitbull/version'
require 'pitbull/configuration'
require 'pitbull/strategies/static'
Expand Down
16 changes: 8 additions & 8 deletions lib/pitbull/configuration/authorization_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class AuthorizationApi
:authorization_token_value

def after_configure
Falcon.configure do |config|
config.add :authorization_api,
raise_error: true,
url: @url,
headers: {
'Content-Type' => 'application/json',
@access_token_header => @access_token_value
}.select { |k, _v| k }
Eezee.configure do |config|
config.add_service :authorization_api,
raise_error: true,
url: @url,
headers: {
'Content-Type' => 'application/json',
@access_token_header => @access_token_value
}.select { |k, _v| k }
end
end
end
Expand Down
16 changes: 10 additions & 6 deletions lib/pitbull/strategies/authorization_api/authorizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ module AuthorizationApi
class Authorizer
class Unauthorized < StandardError; end

extend Falcon::Client
extend Eezee::Client

falcon_options :authorization_api
eezee_service :authorization_api, lazy: true

class << self
def perform(request)
def perform(controller_req)
post(
merge_in_headers: { params.authorization_token_header => params.authorization_token_value.call(request) }
.select { |k, _v| k },
after: ->(response) { handle(response) }
before: ->(req) { req.headers.merge!(authorization_header(controller_req)) },
after: ->(_req, res) { handle(res) }
)
end

def authorization_header(controller_req)
{ params.authorization_token_header => params.authorization_token_value.call(controller_req) }
.select { |k, _v| k }
end

private

def handle(response)
Expand Down
2 changes: 1 addition & 1 deletion pitbull.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.6'

spec.add_dependency 'activesupport', '>= 5.0'
spec.add_dependency 'falcon'
spec.add_dependency 'eezee', '>=1.0.9'

spec.add_development_dependency 'bundler', '~> 2.0'
spec.add_development_dependency 'dotenv', '~> 2.7.5'
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/pitbull/configuration/authorization_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
before { subject }

it do
expect(Falcon.configuration.options[:authorization_api]).to have_attributes(
expect(Eezee.configuration.services[:authorization_api]).to have_attributes(
raise_error: true,
url: url,
headers: {
Expand Down
1 change: 1 addition & 0 deletions spec/support/shared/strategies_authorization_api.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'spec_helper'
require 'pry'

RSpec.shared_examples_for 'strategies_authorization_api' do
describe '#check', :vcr do
Expand Down

0 comments on commit b3359f4

Please sign in to comment.