omniauth-amazon-oauth2 1.1.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
+ SHA256:
3
+ metadata.gz: 1500415497dba0143bb8e68ac4479d171b95a4bd0d64910641dab4cf8057d879
4
+ data.tar.gz: d689bf9c6bdf8592986717463cc6b95a4bd511432706e6c65bf5d29a4cd90d27
5
+ SHA512:
6
+ metadata.gz: cd7a14250d849f6a2c2631ede6b9ee9446540748207cd73ca07e4d31a797e54078c9b3121920cdafd0151f472d2d30d9efb175097e9e9ef05825de9e4732941f
7
+ data.tar.gz: 392a6ac5e14e02b58f5c90dd55f2c76b8305044c91c8a77860bf901a12135f72eb61afabd009b65b9e674672d1ab9c2c4325644c2ff9b38b72106474956770de
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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
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 Amazon
3
+ VERSION = "1.1.1"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "omniauth/amazon/version"
2
+ require "omniauth/strategies/amazon"
3
+
@@ -0,0 +1,66 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Amazon < OmniAuth::Strategies::OAuth2
7
+ option :name, 'amazon'
8
+
9
+ option :client_options, {
10
+ :site => 'https://www.amazon.com/',
11
+ :authorize_url => 'https://www.amazon.com/ap/oa',
12
+ :token_url => 'https://api.amazon.com/auth/o2/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 = "/ap/user/profile"
57
+ params = {:params => { :access_token => access_token.token}}
58
+ @raw_info ||= access_token.client.request(:get, url, params).parsed
59
+ end
60
+
61
+ def callback_url
62
+ full_host + script_name + callback_path
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/amazon'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/amazon/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-amazon-oauth2"
8
+ spec.version = OmniAuth::Amazon::VERSION
9
+ spec.authors = ["Kristoffer Ek', 'Josef Ngo', 'Sten Larsson"]
10
+ spec.email = ["kristoffer.ek@burtcorp.com', 'josef.ngo@burtcorp.com', 'sten@burtcorp.com"]
11
+ spec.description = %q{Login with Amazon OAuth2 strategy for OmniAuth 2.0}
12
+ spec.summary = %q{Login with Amazon OAuth2 strategy for OmniAuth 2.0}
13
+ spec.homepage = "https://github.com/burtcorp/omniauth-amazon"
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-oauth2', '~> 1.1'
22
+
23
+ spec.add_development_dependency "bundler", "~> 2"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'rspec', '~> 2.13'
26
+ spec.add_development_dependency 'rack-test'
27
+ spec.add_development_dependency 'simplecov'
28
+ spec.add_development_dependency 'webmock'
29
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Amazon do
4
+ subject do
5
+ strategy = OmniAuth::Strategies::Amazon.new(nil, @options || {})
6
+ strategy.stub(:session) { { } }
7
+ strategy
8
+ end
9
+
10
+ describe '#client' do
11
+ it 'should have the correct Amazon site' do
12
+ expect(subject.client.site).to eq("https://www.amazon.com/")
13
+ end
14
+
15
+ it 'should have the correct authorization url' do
16
+ expect(subject.client.options[:authorize_url]).to eq("https://www.amazon.com/ap/oa")
17
+ end
18
+
19
+ it 'should have the correct token url' do
20
+ expect(subject.client.options[:token_url]).to eq('https://api.amazon.com/auth/o2/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/amazon/callback')
27
+ end
28
+ end
29
+
30
+ describe '#callback_url' do
31
+ it 'does not include query parameters' do
32
+ allow(subject).to receive(:full_host).and_return('https://example.com')
33
+ allow(subject).to receive(:script_name).and_return('/sub_uri')
34
+ allow(subject).to receive(:query_string).and_return('?foo=bar')
35
+
36
+ expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/amazon/callback')
37
+ end
38
+ end
39
+ 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-amazon'
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,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-amazon-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kristoffer Ek', 'Josef Ngo', 'Sten Larsson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.13'
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: simplecov
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: webmock
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: Login with Amazon OAuth2 strategy for OmniAuth 2.0
112
+ email:
113
+ - kristoffer.ek@burtcorp.com', 'josef.ngo@burtcorp.com', 'sten@burtcorp.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/omniauth-amazon-oauth2.rb
125
+ - lib/omniauth/amazon.rb
126
+ - lib/omniauth/amazon/version.rb
127
+ - lib/omniauth/strategies/amazon.rb
128
+ - omniauth-amazon-oauth2.gemspec
129
+ - spec/omniauth/strategies/amazon_spec.rb
130
+ - spec/spec_helper.rb
131
+ - spec/support/shared_examples.rb
132
+ homepage: https://github.com/burtcorp/omniauth-amazon
133
+ licenses:
134
+ - MIT
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubygems_version: 3.0.3.1
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Login with Amazon OAuth2 strategy for OmniAuth 2.0
155
+ test_files:
156
+ - spec/omniauth/strategies/amazon_spec.rb
157
+ - spec/spec_helper.rb
158
+ - spec/support/shared_examples.rb