omniauth-eloqua 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +42 -0
- data/.travis.yml +22 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +32 -0
- data/Rakefile +11 -0
- data/lib/omniauth-eloqua.rb +1 -0
- data/lib/omniauth/eloqua.rb +2 -0
- data/lib/omniauth/eloqua/version.rb +5 -0
- data/lib/omniauth/strategies/eloqua.rb +123 -0
- data/omniauth-eloqua.gemspec +27 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 240119d0dd820c4e62aca6d5e8ce7ee1be134ec07298555505144baa9b2c661a
|
4
|
+
data.tar.gz: 97cc48191e9e9de0d036af6f93032cb5225143e0f9bdebdb721d068b39f1abc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1c04551f340f4ca2c8c0605eb0f89a02182292d3dc2a8a216ca148f9725b3b12c4df5e78c0ab8ad04aecd43eae94e7cd18af2ef91bc478319aa5b519267147b
|
7
|
+
data.tar.gz: 61fd1bad287bb8e4edbcfd8a2751356cd110b816d1ce2fe3c2a987d26386c2962ac69af148e0dfa9ed7e49e79674ebb09bfa286a2fb6fd3f890d3ae36dbe0bae
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Metrics/BlockNesting:
|
2
|
+
Max: 2
|
3
|
+
|
4
|
+
Metrics/LineLength:
|
5
|
+
AllowURI: true
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Metrics/MethodLength:
|
9
|
+
CountComments: false
|
10
|
+
Max: 10
|
11
|
+
|
12
|
+
Metrics/ParameterLists:
|
13
|
+
Max: 4
|
14
|
+
CountKeywordArgs: true
|
15
|
+
|
16
|
+
Style/AccessModifierIndentation:
|
17
|
+
EnforcedStyle: outdent
|
18
|
+
|
19
|
+
Style/CollectionMethods:
|
20
|
+
PreferredMethods:
|
21
|
+
map: 'collect'
|
22
|
+
reduce: 'inject'
|
23
|
+
find: 'detect'
|
24
|
+
find_all: 'select'
|
25
|
+
|
26
|
+
Style/Documentation:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Style/DoubleNegation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/HashSyntax:
|
33
|
+
EnforcedStyle: hash_rockets
|
34
|
+
|
35
|
+
Style/SpaceInsideHashLiteralBraces:
|
36
|
+
EnforcedStyle: no_space
|
37
|
+
|
38
|
+
Style/StringLiterals:
|
39
|
+
EnforcedStyle: double_quotes
|
40
|
+
|
41
|
+
Style/TrailingComma:
|
42
|
+
EnforcedStyleForMultiline: 'comma'
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
before_install: gem install bundler
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
5
|
+
language: ruby
|
6
|
+
rvm:
|
7
|
+
- 1.8.7
|
8
|
+
- 1.9.3
|
9
|
+
- 2.0.0
|
10
|
+
- 2.1
|
11
|
+
- 2.2
|
12
|
+
- jruby-18mode
|
13
|
+
- jruby-19mode
|
14
|
+
- jruby-head
|
15
|
+
- rbx-2
|
16
|
+
- ruby-head
|
17
|
+
matrix:
|
18
|
+
allow_failures:
|
19
|
+
- rvm: jruby-head
|
20
|
+
- rvm: ruby-head
|
21
|
+
fast_finish: true
|
22
|
+
sudo: false
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Waqas Ali
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Eloqua Strategy for OmniAuth
|
2
|
+
|
3
|
+
Eloqua OAuth2 strategy for OmniAuth.
|
4
|
+
## Get Started
|
5
|
+
```ruby
|
6
|
+
gem 'omniauth-eloqua'
|
7
|
+
```
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
In your config/initializers/omniauth.rb:
|
11
|
+
|
12
|
+
OmniAuth.config.logger = Rails.logger
|
13
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
14
|
+
provider :eloqua, CLIENT_APP_ID, CLIENT_APP_SECRET
|
15
|
+
end
|
16
|
+
|
17
|
+
If you want to put custom `redirect_uri`, pass it as params
|
18
|
+
|
19
|
+
OmniAuth.config.logger = Rails.logger
|
20
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
21
|
+
provider :eloqua, CLIENT_APP_ID, CLIENT_APP_SECRET, redirect_uri: 'SOME_URL'
|
22
|
+
end
|
23
|
+
|
24
|
+
# License
|
25
|
+
|
26
|
+
Copyright (c) 2018 Waqas Ali
|
27
|
+
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
29
|
+
|
30
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
31
|
+
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
desc "Build the gem"
|
4
|
+
task :build do
|
5
|
+
system "gem build omniauth-eloqua.gemspec"
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build and release the gem"
|
9
|
+
task :release => :build do
|
10
|
+
system "gem push omniauth-eloqua-#{OmniAuth::Eloqua::VERSION}.gem"
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/eloqua"
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Eloqua < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
args [:client_id, :client_secret]
|
8
|
+
|
9
|
+
option :name, "eloqua"
|
10
|
+
option :provider_ignores_state, false
|
11
|
+
|
12
|
+
option :client_options, {
|
13
|
+
site: 'https://login.eloqua.com',
|
14
|
+
authorize_url: '/auth/oauth2/authorize',
|
15
|
+
token_url: '/auth/oauth2/token'
|
16
|
+
}
|
17
|
+
|
18
|
+
option :authorize_options, [
|
19
|
+
:response_type,
|
20
|
+
:client_id,
|
21
|
+
:redirect_uri,
|
22
|
+
:scope
|
23
|
+
]
|
24
|
+
|
25
|
+
def request_phase
|
26
|
+
redirect client.auth_code.authorize_url(
|
27
|
+
{
|
28
|
+
redirect_uri: "#{callback_url}?response_type=code&state="\
|
29
|
+
"#{request.params['state']}"
|
30
|
+
}.merge(
|
31
|
+
options.authorize_params
|
32
|
+
)
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def callback_phase
|
37
|
+
error = request.params["error_reason"] || request.params["error"]
|
38
|
+
if error
|
39
|
+
fail!(error, CallbackError.new(request.params["error"],
|
40
|
+
request.params["error_description"] ||
|
41
|
+
request.params["error_reason"], request.params["error_uri"]))
|
42
|
+
else
|
43
|
+
conn = Faraday.new(:url => 'https://login.eloqua.com/auth/'\
|
44
|
+
'oauth2/token') do |faraday|
|
45
|
+
faraday.response :logger
|
46
|
+
faraday.adapter Faraday.default_adapter
|
47
|
+
end
|
48
|
+
|
49
|
+
token = Base64.strict_encode64("#{options.client_id.strip}:"\
|
50
|
+
"#{options.client_secret.strip}").strip
|
51
|
+
|
52
|
+
result = conn.post do |req|
|
53
|
+
req.headers['Content-Type'] = 'application/json'
|
54
|
+
req.headers['Authorization'] = "Basic #{token}"
|
55
|
+
req.body = "{ 'grant_type': 'authorization_code', 'code': "\
|
56
|
+
"'#{request.params["code"]}', 'redirect_uri': "\
|
57
|
+
"'#{callback_url}?response_type=code&state="\
|
58
|
+
"#{request.params['state']}' }"
|
59
|
+
end
|
60
|
+
@access_token = result
|
61
|
+
result = JSON.parse(result.body)
|
62
|
+
env['omniauth.auth'] = auth_hash(result)
|
63
|
+
call_app!
|
64
|
+
end
|
65
|
+
rescue ::OAuth2::Error, CallbackError => e
|
66
|
+
fail!(:invalid_credentials, e)
|
67
|
+
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
|
68
|
+
fail!(:timeout, e)
|
69
|
+
rescue ::SocketError => e
|
70
|
+
fail!(:failed_to_connect, e)
|
71
|
+
end
|
72
|
+
|
73
|
+
def auth_hash(result)
|
74
|
+
detail = detail(result)
|
75
|
+
hash = AuthHash.new(:provider => name, :uid => detail.uid)
|
76
|
+
hash.info = detail.info unless skip_info?
|
77
|
+
hash.credentials = AuthHash::InfoHash.new({
|
78
|
+
token: result["access_token"],
|
79
|
+
refresh_token: result["refresh_token"],
|
80
|
+
expires_in: result["expires_in"]
|
81
|
+
})
|
82
|
+
hash.extra = detail.extra
|
83
|
+
hash
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def callback_url
|
89
|
+
options[:redirect_uri] || (full_host + script_name + callback_path)
|
90
|
+
end
|
91
|
+
|
92
|
+
def detail(result)
|
93
|
+
return {} if result.dig('access_token').blank?
|
94
|
+
conn = Faraday.new(:url => 'https://login.eloqua.com/id') do |faraday|
|
95
|
+
faraday.response :logger
|
96
|
+
faraday.adapter Faraday.default_adapter
|
97
|
+
end
|
98
|
+
result = conn.get do |req|
|
99
|
+
req.headers['Content-Type'] = 'application/json'
|
100
|
+
req.headers['Authorization'] = "Bearer #{result['access_token']}"
|
101
|
+
end
|
102
|
+
result = JSON.parse(result.body)
|
103
|
+
AuthHash::InfoHash.new(
|
104
|
+
uid: result.dig('site', 'id'),
|
105
|
+
info: {
|
106
|
+
id: result.dig('user', 'id'),
|
107
|
+
nickname: result.dig('user', 'username'),
|
108
|
+
email: result.dig('user', 'emailAddress'),
|
109
|
+
first_name: result.dig('user', 'firstName'),
|
110
|
+
last_name: result.dig('user', 'lastName'),
|
111
|
+
name: result.dig('user', 'displayName'),
|
112
|
+
urls: result.dig('urls')
|
113
|
+
},
|
114
|
+
extra: {
|
115
|
+
site: result.dig('site')
|
116
|
+
}
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
OmniAuth.config.add_camelization 'eloqua', 'Eloqua'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth/eloqua/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.add_dependency 'omniauth'
|
6
|
+
gem.add_dependency 'oauth2'
|
7
|
+
gem.add_dependency 'omniauth-oauth2'
|
8
|
+
|
9
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
10
|
+
gem.add_development_dependency 'rack-test'
|
11
|
+
gem.add_development_dependency 'webmock'
|
12
|
+
gem.add_development_dependency 'simplecov'
|
13
|
+
|
14
|
+
gem.authors = ["Waqas Ali"]
|
15
|
+
gem.email = ["wqsaali@gmail.com"]
|
16
|
+
gem.description = %q{An OmniAuth strategy for authenticating with the Eloqua REST API.}
|
17
|
+
gem.summary = %q{OmniAuth strategy for authenticating with Eloqua.}
|
18
|
+
gem.homepage = "https://github.com/wqsaali/omniauth-eloqua"
|
19
|
+
gem.license = "GPL v3"
|
20
|
+
|
21
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
gem.files = `git ls-files`.split("\n")
|
23
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
gem.name = "omniauth-eloqua"
|
25
|
+
gem.require_paths = ["lib"]
|
26
|
+
gem.version = OmniAuth::Eloqua::VERSION
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-eloqua
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Waqas Ali
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-01 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: omniauth-oauth2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: An OmniAuth strategy for authenticating with the Eloqua REST API.
|
112
|
+
email:
|
113
|
+
- wqsaali@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- lib/omniauth-eloqua.rb
|
127
|
+
- lib/omniauth/eloqua.rb
|
128
|
+
- lib/omniauth/eloqua/version.rb
|
129
|
+
- lib/omniauth/strategies/eloqua.rb
|
130
|
+
- omniauth-eloqua.gemspec
|
131
|
+
homepage: https://github.com/wqsaali/omniauth-eloqua
|
132
|
+
licenses:
|
133
|
+
- GPL v3
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.7.7
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: OmniAuth strategy for authenticating with Eloqua.
|
155
|
+
test_files: []
|