surveymonkey-with-omniauth 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d78ae45bd84abe9be5b5162923171b5b2772edf
4
+ data.tar.gz: d64ab879543cb2acb83d913cda6b8086a4be2c18
5
+ SHA512:
6
+ metadata.gz: 7ba52763d2b2bbe74e98f25b9535b3a7bd3652542bab62f9a3eb641b56142ec53436f1d9cacc311c84eac2f5b12acdf6de99b32ea948db797afeebba84a16307
7
+ data.tar.gz: 756ea155c765780a2cdf614ea85d0a26e5a5ae55d57bc5718027de3df0922067d8c2a191caf47ab28bf9b7f034e1e29a38cf7571d9cd64f29cd570ae4eebf78d
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gem "omniauth-oauth2"
@@ -0,0 +1,23 @@
1
+ GEM
2
+ specs:
3
+ faraday (0.8.0)
4
+ multipart-post (~> 1.1)
5
+ hashie (1.2.0)
6
+ multi_json (1.3.6)
7
+ multipart-post (1.2.0)
8
+ oauth2 (0.5.2)
9
+ faraday (~> 0.7)
10
+ multi_json (~> 1.0)
11
+ omniauth (1.0.0)
12
+ hashie (~> 1.2)
13
+ rack
14
+ omniauth-oauth2 (1.0.0)
15
+ oauth2 (~> 0.5.0)
16
+ omniauth (~> 1.0)
17
+ rack (1.1.6)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ omniauth-oauth2
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2016 Waqas Ali
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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.
@@ -0,0 +1,27 @@
1
+ #Surveymonkey Strategy for OmniAuth
2
+
3
+ SurveyMonkey OAuth2 strategy for OmniAuth 1.0.
4
+ ## Get Started
5
+ ```ruby
6
+ gem 'surveymonkey-with-omniauth'
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 :surveymonkey, api_key: SURVEYMONKEY_API_KEY, client_secret: SURVEYMONKEY_API_SECRET, client_id: SURVEYMONKEY_API_SECRET
15
+ end
16
+
17
+ Note that this differs from normal Omniauth configurations!
18
+
19
+ #License
20
+
21
+ Copyright (c) 2016 Waqas Ali
22
+
23
+ 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:
24
+
25
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
26
+
27
+ 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/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'surveymonkey-with-omniauth'
@@ -0,0 +1,87 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Surveymonkey < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_RESPONSE_TYPE = 'code'
7
+ DEFAULT_GRANT = 'authorization_code'
8
+ option :name, "surveymonkey"
9
+
10
+ option :client_options, {
11
+ :site => "https://api.surveymonkey.net",
12
+ :authorize_url => '/oauth/authorize',
13
+ :token_url => '/oauth/token'
14
+ }
15
+
16
+ option :authorize_options, [:api_key, :client_id]
17
+
18
+ def authorize_params
19
+ super.tap do |params|
20
+ params[:response_type] ||= DEFAULT_RESPONSE_TYPE
21
+ params[:client_id] = options[:client_id]
22
+ params[:api_key] = options[:api_key]
23
+ end
24
+ end
25
+
26
+ def build_access_token
27
+ verifier = request.params['code']
28
+ token = client.auth_code.get_token(verifier, token_params)
29
+ end
30
+
31
+ def callback_phase
32
+ options[:client_options][:token_url] = "/oauth/token?api_key=#{options[:api_key]}"
33
+ self.access_token = build_access_token
34
+ self.env['omniauth.auth'] = auth_hash
35
+ call_app!
36
+ end
37
+
38
+ def token_params
39
+ super.tap do |params|
40
+ params[:grant_type] ||= DEFAULT_GRANT
41
+ params[:client_id] = options[:client_id]
42
+ params[:client_secret] = options[:client_secret]
43
+ params[:redirect_uri] = callback_url
44
+ end
45
+ end
46
+
47
+ def callback_url
48
+ full_host + script_name + callback_path# + query_string
49
+ end
50
+
51
+ def full_host
52
+ case OmniAuth.config.full_host
53
+ when String
54
+ OmniAuth.config.full_host
55
+ when Proc
56
+ OmniAuth.config.full_host.call(env)
57
+ else
58
+ # in Rack 1.3.x, request.url explodes if scheme is nil
59
+ if request.scheme && request.url.match(URI::ABS_URI)
60
+ uri = URI.parse(request.url.gsub(/\?.*$/, ''))
61
+ uri.path = ''
62
+ # sometimes the url is actually showing http inside rails because the
63
+ # other layers (like nginx) have handled the ssl termination.
64
+ uri.scheme = 'https' if ssl? # rubocop:disable BlockNesting
65
+ uri.to_s
66
+ else ''
67
+ end
68
+ end
69
+ end
70
+ def script_name
71
+ @env['SCRIPT_NAME'] || ''
72
+ end
73
+ def callback_path
74
+ @callback_path ||= begin
75
+ path = options[:callback_path] if options[:callback_path].is_a?(String)
76
+ path ||= current_path if options[:callback_path].respond_to?(:call) && options[:callback_path].call(env)
77
+ path ||= custom_path(:request_path)
78
+ path ||= "#{path_prefix}/#{name}/callback"
79
+ path
80
+ end
81
+ end
82
+ def query_string
83
+ request.query_string.empty? ? '' : "?#{request.query_string}"
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/surveymonkey'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Surveymonkey
3
+ VERSION = "1.1.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require "omniauth/surveymonkey"
@@ -0,0 +1,29 @@
1
+ require 'surveymonkey-with-omniauth'
2
+
3
+ describe OmniAuth::Strategies::Surveymonkey do
4
+
5
+ subject do
6
+ OmniAuth::Strategies::Surveymonkey.new(nil, {})
7
+ end
8
+
9
+ describe '#client' do
10
+
11
+ it 'has correct surveymonkey api site' do
12
+ subject.options.client_options.site.should == ('https://api.surveymonkey.net')
13
+ end
14
+
15
+ it 'has correct access token path' do
16
+ subject.options.client_options.token_url.should == ('/oauth/token')
17
+ end
18
+
19
+ it 'has correct authorize url' do
20
+ subject.options.client_options.authorize_url.should == ('/oauth/authorize')
21
+ end
22
+ end
23
+
24
+ describe '#callback_path' do
25
+ it 'should have the correct callback path' do
26
+ subject.callback_path.should == ('/auth/surveymonkey/callback')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../lib/omniauth/surveymonkey/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.add_dependency 'omniauth', '~> 1.0'
5
+
6
+ gem.authors = ["Waqas Ali"]
7
+ gem.email = ["wqsaali@gmail.com"]
8
+ gem.description = %q{Survemonkey OAuth2 strategy for OmniAuth 1.0}
9
+ gem.summary = %q{Survemonkey OAuth2 strategy for OmniAuth 1.0.}
10
+
11
+
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files spec/*`.split("\n")
14
+ gem.name = "surveymonkey-with-omniauth"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Surveymonkey::VERSION
17
+ gem.homepage = "https://github.com/wqsaali/surveymonkey-with-omniauth"
18
+
19
+ gem.add_runtime_dependency 'omniauth-oauth2'
20
+
21
+ gem.add_development_dependency 'rspec', '~> 1.3.1'
22
+ gem.add_development_dependency 'rake'
23
+ gem.license = 'MIT'
24
+ end
@@ -0,0 +1 @@
1
+ require 'surveymonkey-with-omniauth'
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: surveymonkey-with-omniauth
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Waqas Ali
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-06 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: '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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Survemonkey OAuth2 strategy for OmniAuth 1.0
70
+ email:
71
+ - wqsaali@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - LICENSE
79
+ - README.md
80
+ - init.rb
81
+ - lib/omniauth/strategies/surveymonkey.rb
82
+ - lib/omniauth/surveymonkey.rb
83
+ - lib/omniauth/surveymonkey/version.rb
84
+ - lib/surveymonkey-with-omniauth.rb
85
+ - spec/omniauth/strategies/surveymonkey_spec.rb
86
+ - surveymonkey-with-omniauth.gemspec
87
+ - surveymonkey-with-omniauth.rb
88
+ homepage: https://github.com/wqsaali/surveymonkey-with-omniauth
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.6
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Survemonkey OAuth2 strategy for OmniAuth 1.0.
112
+ test_files:
113
+ - spec/omniauth/strategies/surveymonkey_spec.rb