omniauth-paymium 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3bae7bcd5bfaf753b3c962dc3c8284e4cd55cf0a
4
+ data.tar.gz: 621b07e60ea816a7709282982f3d26d315900ca9
5
+ SHA512:
6
+ metadata.gz: 415c74ad011cdc8de054908569e1e4f2e9a0ad5a3e19fc1cf5003436808b2042194aa3d88696186a157c5a9c05f27d7fb37ed533ba3b981fcb1b8e0a55fe0ac5
7
+ data.tar.gz: c05ce11fd3eeeff788f0333314130b8173e710ed991d84c131855f1a558fb9c8b051ed493fef20fa59e93a54c1e190dbef303dcfe5a7217ea9f3df3db1dc2359
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ sudo: false
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.2.4
5
+ - 2.1.8
6
+ - jruby-9.0.5.0
7
+ - rbx-2.5.8
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-amazon.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Stafford Brunk
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # OmniAuth::Amazon
2
+ [![Build Status](https://travis-ci.org/wingrunr21/omniauth-amazon.png)](https://travis-ci.org/wingrunr21/omniauth-amazon) [![Gem Version](https://badge.fury.io/rb/omniauth-amazon.png)](http://badge.fury.io/rb/omniauth-amazon)
3
+
4
+ [Login with Amazon](https://login.amazon.com/) OAuth2 strategy for OmniAuth 1.0
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'omniauth-amazon'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install omniauth-amazon
19
+
20
+ ## Prereqs
21
+
22
+ You must create an application via the [Amazon App Console](https://login.amazon.com/manageApps). Once that is complete, register two URLs under <i>Web Settings -> Allowed Return URLs</i>:
23
+
24
+ http://localhost:3000/auth/amazon/callback
25
+ https://your_website_here/auth/amazon/callback
26
+
27
+ Amazon requires HTTPS for the whitelisted callback URL (except localhost). They don't appear to
28
+ like ```.dev``` domains too much but happily accept localhost.
29
+
30
+ ## Usage
31
+
32
+ Usage is similar to other OAuth2 based OmniAuth strategies:
33
+
34
+ ```ruby
35
+ Rails.application.config.middleware.use OmniAuth::Builder do
36
+ provider :amazon, ENV['AMAZON_CLIENT_ID'], ENV['AMAZON_CLIENT_SECRET'],
37
+ {
38
+ :scope => 'profile postal_code' # default scope
39
+ }
40
+ end
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ Config options can be passed to `provider` via a `Hash`:
46
+
47
+ * `scope`: A space-separated list of permissions. Can be `profile`,
48
+ `postal_code`, `profile:user_id`, or a combination of options.
49
+ Defaults to: `profile postal_code`
50
+ * Requesting the `profile:user_id` scope will not display an additional consent
51
+ screen the first time the user logs in.
52
+
53
+ ## Resources
54
+ * [Login with Amazon button guide](https://login.amazon.com/button-guide)
55
+ * [Login with Amazon style guide](https://login.amazon.com/style-guide)
56
+
57
+ ## Todo
58
+ 1. Fix ```raw_info``` to see why ```client.request``` has to be used in query
59
+ mode
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
68
+
69
+
70
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/wingrunr21/omniauth-amazon/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Paymium
3
+ VERSION = "1.0.1"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "omniauth/paymium/version"
2
+ require "omniauth/strategies/paymium"
3
+
@@ -0,0 +1,62 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Paymium < OmniAuth::Strategies::OAuth2
7
+ option :name, 'paymium'
8
+
9
+ option :client_options, {
10
+ :site => 'https://www.paymium.com/',
11
+ :authorize_url => 'https://www.paymium.com/api/oauth/authorize',
12
+ :token_url => 'https://www.paymium.com/api/oauth/token'
13
+ }
14
+
15
+ option :access_token_options, {
16
+ :mode => :query
17
+ }
18
+
19
+ option :authorize_params, {
20
+ :scope => 'profile postal_code'
21
+ }
22
+
23
+ def build_access_token
24
+ token_params = {
25
+ :redirect_uri => callback_url.split('?').first,
26
+ :client_id => client.id,
27
+ :client_secret => client.secret
28
+ }
29
+ verifier = request.params['code']
30
+ client.auth_code.get_token(verifier, token_params)
31
+ end
32
+
33
+ uid { raw_info['Profile']['CustomerId'] }
34
+
35
+ info do
36
+ {
37
+ 'email' => raw_info['Profile']['PrimaryEmail'],
38
+ 'name' => raw_info['Profile']['Name']
39
+ }
40
+ end
41
+
42
+ extra do
43
+ {
44
+ 'postal_code' => raw_info['Profile']['PostalCode']
45
+ }
46
+ end
47
+
48
+ def raw_info
49
+ access_token.options[:parse] = :json
50
+
51
+ # This way is not working right now, do it the longer way
52
+ # for the time being
53
+ #
54
+ #@raw_info ||= access_token.get('/ap/user/profile').parsed
55
+
56
+ url = "/api/v1/user/profile"
57
+ params = {:params => { :access_token => access_token.token}}
58
+ @raw_info ||= access_token.client.request(:get, url, params).parsed
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/paymium'
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/paymium/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-paymium"
8
+ spec.version = OmniAuth::Paymium::VERSION
9
+ spec.authors = ["Pierre Michard"]
10
+ spec.email = ["pierre.michard@paymium.com"]
11
+ spec.description = %q{Login with Paymium OAuth2 strategy for OmniAuth 1.0}
12
+ spec.summary = %q{Login with Paymium OAuth2 strategy for OmniAuth 1.0}
13
+ spec.homepage = "https://github.com/Pierre-Michard/omniauth-paymium"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'omniauth', '~> 1.0'
22
+ spec.add_dependency 'omniauth-oauth2', '~> 1.1'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency 'rspec', '~> 2.13'
27
+ spec.add_development_dependency 'rack-test'
28
+ spec.add_development_dependency 'simplecov'
29
+ spec.add_development_dependency 'webmock'
30
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Paymium do
4
+ subject do
5
+ strategy = OmniAuth::Strategies::Paymium.new(nil, @options || {})
6
+ strategy.stub(:session) { { } }
7
+ strategy
8
+ end
9
+
10
+ describe '#client' do
11
+ it 'should have the correct Paymium site' do
12
+ expect(subject.client.site).to eq("https://www.paymium.com/")
13
+ end
14
+
15
+ it 'should have the correct authorization url' do
16
+ expect(subject.client.options[:authorize_url]).to eq("https://www.paymium.com/api/oauth/authorize")
17
+ end
18
+
19
+ it 'should have the correct token url' do
20
+ expect(subject.client.options[:token_url]).to eq('https://www.paymium.com/api/oauth/token')
21
+ end
22
+ end
23
+
24
+ describe '#callback_path' do
25
+ it 'should have the correct callback path' do
26
+ expect(subject.callback_path).to eq('/auth/paymium/callback')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
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-paymium'
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
+ config.expect_with :rspec do |c|
16
+ c.syntax = :expect
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ # Courtesy omniauth-37signals:
2
+ # https://github.com/tallgreentree/omniauth-37signals/blob/master/spec/support/shared_examples.rb
3
+
4
+ shared_examples 'an oauth2 strategy' do
5
+ describe '#client' do
6
+ it 'should be initialized with symbolized client_options' do
7
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
8
+ subject.client.options[:authorize_url].should == 'https://example.com'
9
+ end
10
+ end
11
+
12
+ describe '#authorize_params' do
13
+ it 'should include any authorize params passed in the :authorize_params option' do
14
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
15
+ subject.authorize_params['foo'].should eq('bar')
16
+ subject.authorize_params['baz'].should eq('zip')
17
+ end
18
+
19
+ it 'should include top-level options that are marked as :authorize_options' do
20
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
21
+ subject.authorize_params['scope'].should eq('bar')
22
+ subject.authorize_params['foo'].should eq('baz')
23
+ end
24
+ end
25
+
26
+ describe '#token_params' do
27
+ it 'should include any token params passed in the :token_params option' do
28
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
29
+ subject.token_params['foo'].should eq('bar')
30
+ subject.token_params['baz'].should eq('zip')
31
+ end
32
+
33
+ it 'should include top-level options that are marked as :token_options' do
34
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
35
+ subject.token_params['scope'].should eq('bar')
36
+ subject.token_params['foo'].should eq('baz')
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-paymium
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pierre Michard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-29 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.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
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'
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
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
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
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Login with Paymium OAuth2 strategy for OmniAuth 1.0
126
+ email:
127
+ - pierre.michard@paymium.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".idea/vcs.xml"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - lib/omniauth-paymium.rb
141
+ - lib/omniauth/paymium.rb
142
+ - lib/omniauth/paymium/version.rb
143
+ - lib/omniauth/strategies/paymium.rb
144
+ - omniauth-paymium.gemspec
145
+ - spec/omniauth/strategies/paymium_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/support/shared_examples.rb
148
+ homepage: https://github.com/Pierre-Michard/omniauth-paymium
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.4.8
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Login with Paymium OAuth2 strategy for OmniAuth 1.0
172
+ test_files:
173
+ - spec/omniauth/strategies/paymium_spec.rb
174
+ - spec/spec_helper.rb
175
+ - spec/support/shared_examples.rb
176
+ has_rdoc: