omniauth-active-passport 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +44 -0
- data/README.md +70 -0
- data/Rakefile +12 -0
- data/coverage/.resultset.json +84 -0
- data/coverage/assets/0.5.3/app.js +88 -0
- data/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
- data/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
- data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/coverage/assets/0.5.3/favicon_green.png +0 -0
- data/coverage/assets/0.5.3/favicon_red.png +0 -0
- data/coverage/assets/0.5.3/favicon_yellow.png +0 -0
- data/coverage/assets/0.5.3/highlight.css +129 -0
- data/coverage/assets/0.5.3/highlight.pack.js +1 -0
- data/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
- data/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
- data/coverage/assets/0.5.3/jquery.timeago.js +141 -0
- data/coverage/assets/0.5.3/jquery.url.js +174 -0
- data/coverage/assets/0.5.3/loading.gif +0 -0
- data/coverage/assets/0.5.3/magnify.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
- data/coverage/assets/0.5.3/stylesheet.css +383 -0
- data/coverage/index.html +607 -0
- data/lib/oauth2_patch/client.rb +21 -0
- data/lib/omniauth-active_passport.rb +2 -0
- data/lib/omniauth-active_passport/version.rb +5 -0
- data/lib/omniauth/strategies/active_passport.rb +42 -0
- data/omniauth-active-passport.gemspec +21 -0
- data/spec/omniauth/strategies/active_passport_spec.rb +29 -0
- data/spec/spec_helper.rb +16 -0
- metadata +149 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# Monkeypatching to work with how Active Passport names the access token on a successful response
|
2
|
+
|
3
|
+
module OAuth2
|
4
|
+
# The OAuth2::Client class
|
5
|
+
class Client
|
6
|
+
# Initializes an AccessToken by making a request to the token endpoint
|
7
|
+
def get_token(params, access_token_opts={})
|
8
|
+
params = Authenticator.new(id, secret, options[:auth_scheme]).apply(params)
|
9
|
+
opts = {:raise_errors => true, :parse => params.delete(:parse)}
|
10
|
+
if options[:token_method] == :post
|
11
|
+
opts[:body] = params
|
12
|
+
opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'}
|
13
|
+
else
|
14
|
+
opts[:params] = params
|
15
|
+
end
|
16
|
+
response = request(options[:token_method], token_url, opts)
|
17
|
+
raise Error.new(response) unless response.parsed.is_a?(Hash) && (response.parsed['access_token'] || response.parsed['accessToken'])
|
18
|
+
AccessToken.from_hash(self, response.parsed.merge(access_token_opts))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'oauth2_patch/client'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class ActivePassport < OmniAuth::Strategies::OAuth2
|
7
|
+
# Give your strategy a name.
|
8
|
+
option :name, "active_passport"
|
9
|
+
|
10
|
+
# This is where you pass the options you would pass when
|
11
|
+
# initializing your consumer from the OAuth gem.
|
12
|
+
option :client_options, {
|
13
|
+
:site => 'https://passport.active.com',
|
14
|
+
:authorize_url => '/oauth2/authorize',
|
15
|
+
:token_url => '/oauth2/token'
|
16
|
+
}
|
17
|
+
|
18
|
+
option :token_params, { :parse => :json }
|
19
|
+
|
20
|
+
uid { access_token.params['activeEnterprisePersonId'] }
|
21
|
+
|
22
|
+
info do
|
23
|
+
{
|
24
|
+
:email => access_token.params['userName'],
|
25
|
+
:expires_at => access_token.params['expireDateTime']
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
credentials do
|
30
|
+
{
|
31
|
+
:token => access_token.params['accessToken']
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
extra do
|
36
|
+
{
|
37
|
+
:access_token => access_token
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-active_passport/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "omniauth-active-passport"
|
6
|
+
s.version = Omniauth::ActivePassport::VERSION
|
7
|
+
s.authors = ["Cesar Camacho"]
|
8
|
+
s.email = ["cesar.camacho@activenetwork.com"]
|
9
|
+
s.homepage = "https://github.com/hlcfan/omniauth-active-passport"
|
10
|
+
s.summary = %q{Official OmniAuth strategy for Active Passport.}
|
11
|
+
s.description = %q{Official OmniAuth strategy for Active Passport.}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_dependency 'omniauth', '~> 1.0'
|
19
|
+
s.add_dependency 'omniauth-oauth2', '~> 1.0'
|
20
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::ActivePassport do
|
4
|
+
def app; lambda{|env| [200, {}, ["Hello."]]} end
|
5
|
+
let(:fresh_strategy){ Class.new(OmniAuth::Strategies::ActivePassport) }
|
6
|
+
|
7
|
+
describe '#client' do
|
8
|
+
subject{ fresh_strategy }
|
9
|
+
|
10
|
+
it 'should be initialized with symbolized client_options' do
|
11
|
+
instance = subject.new(app, :client_options => {'authorize_url' => 'https://example.com'})
|
12
|
+
instance.client.options[:authorize_url].should == 'https://example.com'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#token_params' do
|
17
|
+
subject { fresh_strategy }
|
18
|
+
|
19
|
+
it 'should include parse => json as well as any authorize params passed in the :authorize_params option' do
|
20
|
+
instance = subject.new('abc', 'def', :token_params => {:foo => 'bar', :baz => 'zip'})
|
21
|
+
instance.token_params.should == {'foo' => 'bar', 'baz' => 'zip', 'parse' => :json}
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should include parse => json as well as any top-level options that are marked as :authorize_options' do
|
25
|
+
instance = subject.new('abc', 'def', :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz')
|
26
|
+
instance.token_params.should == {'scope' => 'bar', 'foo' => 'baz', 'parse' => :json}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rack/test'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-active_passport'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include WebMock::API
|
13
|
+
config.include Rack::Test::Methods
|
14
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
15
|
+
end
|
16
|
+
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-active-passport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cesar Camacho
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
55
|
+
description: Official OmniAuth strategy for Active Passport.
|
56
|
+
email:
|
57
|
+
- cesar.camacho@activenetwork.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- coverage/.resultset.json
|
67
|
+
- coverage/assets/0.5.3/app.js
|
68
|
+
- coverage/assets/0.5.3/fancybox/blank.gif
|
69
|
+
- coverage/assets/0.5.3/fancybox/fancy_close.png
|
70
|
+
- coverage/assets/0.5.3/fancybox/fancy_loading.png
|
71
|
+
- coverage/assets/0.5.3/fancybox/fancy_nav_left.png
|
72
|
+
- coverage/assets/0.5.3/fancybox/fancy_nav_right.png
|
73
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_e.png
|
74
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_n.png
|
75
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png
|
76
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png
|
77
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_s.png
|
78
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_se.png
|
79
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png
|
80
|
+
- coverage/assets/0.5.3/fancybox/fancy_shadow_w.png
|
81
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_left.png
|
82
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_main.png
|
83
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_over.png
|
84
|
+
- coverage/assets/0.5.3/fancybox/fancy_title_right.png
|
85
|
+
- coverage/assets/0.5.3/fancybox/fancybox-x.png
|
86
|
+
- coverage/assets/0.5.3/fancybox/fancybox-y.png
|
87
|
+
- coverage/assets/0.5.3/fancybox/fancybox.png
|
88
|
+
- coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css
|
89
|
+
- coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js
|
90
|
+
- coverage/assets/0.5.3/favicon_green.png
|
91
|
+
- coverage/assets/0.5.3/favicon_red.png
|
92
|
+
- coverage/assets/0.5.3/favicon_yellow.png
|
93
|
+
- coverage/assets/0.5.3/highlight.css
|
94
|
+
- coverage/assets/0.5.3/highlight.pack.js
|
95
|
+
- coverage/assets/0.5.3/jquery-1.6.2.min.js
|
96
|
+
- coverage/assets/0.5.3/jquery.dataTables.min.js
|
97
|
+
- coverage/assets/0.5.3/jquery.timeago.js
|
98
|
+
- coverage/assets/0.5.3/jquery.url.js
|
99
|
+
- coverage/assets/0.5.3/loading.gif
|
100
|
+
- coverage/assets/0.5.3/magnify.png
|
101
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
102
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
103
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
104
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
105
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
106
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
107
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
108
|
+
- coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
109
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png
|
110
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png
|
111
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png
|
112
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png
|
113
|
+
- coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png
|
114
|
+
- coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css
|
115
|
+
- coverage/assets/0.5.3/stylesheet.css
|
116
|
+
- coverage/index.html
|
117
|
+
- lib/oauth2_patch/client.rb
|
118
|
+
- lib/omniauth-active_passport.rb
|
119
|
+
- lib/omniauth-active_passport/version.rb
|
120
|
+
- lib/omniauth/strategies/active_passport.rb
|
121
|
+
- omniauth-active-passport.gemspec
|
122
|
+
- spec/omniauth/strategies/active_passport_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
homepage: https://github.com/hlcfan/omniauth-active-passport
|
125
|
+
licenses: []
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.5.2
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Official OmniAuth strategy for Active Passport.
|
147
|
+
test_files:
|
148
|
+
- spec/omniauth/strategies/active_passport_spec.rb
|
149
|
+
- spec/spec_helper.rb
|