omniauth-jumpseller 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a5d8ababa58fa0d33fcb91083032d0b16b629d0c
4
+ data.tar.gz: 4f43dc645e62ad5d9b7bd5ee2bb3ece3a13117d6
5
+ SHA512:
6
+ metadata.gz: e3500fae089fa0ef35c7c9dbd43b537140efa018327b1b25c4a07e8e59853952660ae5bbdadb8a0d37ad159cc47d3244a4ede697abacec0ed08daa7399a44c3c
7
+ data.tar.gz: dcc92ea8f9033b38bbaa8dc53c23c8526aebaa99ca7fc9bd880e8b555cd4f0c2313f4aa1bc74e40b8818ee426e979e76b9c7f07f2f574139c170a9c5820173fa
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-jumpseller.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Paulo Fabiano Langer
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Omniauth::Jumpseller
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/jumpseller`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-jumpseller'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-jumpseller
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-jumpseller.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,9 @@
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
9
+ task :test => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/jumpseller"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require 'omniauth-jumpseller/version'
2
+ require 'omniauth/strategies/jumpseller'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Jumpseller
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,84 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Jumpseller < OmniAuth::Strategies::OAuth2
6
+ AUTHENTICATION_PARAMETERS = %w(state app)
7
+ BASE_URL = 'http://localhost:3000'
8
+
9
+ option :name, 'jumpseller'
10
+
11
+ unless OmniAuth.config.test_mode
12
+ option :client_options, {
13
+ :authorize_url => "#{BASE_URL}/oauth2/authorize",
14
+ :token_url => "#{BASE_URL}/oauth2/token",
15
+ :site => BASE_URL
16
+ }
17
+ else
18
+ option :client_options, {
19
+ :authorize_url => "http://localhost:3000/oauth2/authorize",
20
+ :token_url => "http://localhost:3000/oauth2/token",
21
+ :site => "http://localhost:3000"
22
+ }
23
+ end
24
+
25
+ option :authorize_options, AUTHENTICATION_PARAMETERS
26
+
27
+ uid do
28
+ me['uid']
29
+ end
30
+
31
+ info do
32
+ {
33
+ :name => me['name'],
34
+ :email => me['email']
35
+ }
36
+ end
37
+
38
+ extra do
39
+ {
40
+ 'raw_info' => me
41
+ }
42
+ end
43
+
44
+ def me
45
+ @response ||= access_token.get('/api/v1/me').parsed
46
+ end
47
+
48
+ # Over-ride callback_url definition to maintain
49
+ # compatability with omniauth-oauth2 >= 1.4.0
50
+ #
51
+ # See: https://github.com/intridea/omniauth-oauth2/issues/81
52
+ def callback_url
53
+ full_host + script_name + callback_path
54
+ end
55
+
56
+ # # Hook useful for appending parameters into the auth url before sending
57
+ # # to provider.
58
+ def request_phase
59
+ super
60
+ end
61
+ #
62
+ # # Hook used after response with code from provider. Used to prep token
63
+ # # request from provider.
64
+ def callback_phase
65
+ super
66
+ end
67
+
68
+ ##
69
+ # You can pass +display+, +state+ or +scope+ params to the auth request, if
70
+ # you need to set them dynamically. You can also set these options
71
+ # in the OmniAuth config :authorize_params option.
72
+ #
73
+ # /v1/auth/digialocean?display=fancy&state=ABC
74
+ #
75
+ def authorize_params
76
+ super.tap do |params|
77
+ AUTHENTICATION_PARAMETERS.each do |v|
78
+ params[v.to_sym] = request.params[v] if request.params[v]
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-jumpseller/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-jumpseller"
8
+ spec.version = Omniauth::Jumpseller::VERSION
9
+ spec.authors = ["Paulo Fabiano Langer"]
10
+ spec.email = ["paulo.langer@jumpseller.com"]
11
+
12
+ spec.summary = %q{Official OmniAuth strategy for Jumpseller}
13
+ spec.description = %q{Official OmniAuth strategy for Jumpseller}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "oauth2", "~> 1.0"
23
+ spec.add_dependency "omniauth", "~> 1.0"
24
+ spec.add_dependency "omniauth-oauth2", "~> 1.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.14"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.2"
29
+ spec.add_development_dependency "rack-test"
30
+ spec.add_development_dependency "simplecov"
31
+ spec.add_development_dependency "webmock"
32
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Jumpseller do
4
+ subject do
5
+ described_class.new({})
6
+ end
7
+
8
+ describe "production client options" do
9
+ it { expect(subject.options.name).to eq("jumpseller") }
10
+
11
+ it { expect(subject.options.client_options.site).to eq("http://localhost:3000") }
12
+ it { expect(subject.options.client_options.authorize_url).to eq("http://localhost:3000/oauth2/authorize") }
13
+ it { expect(subject.options.client_options.token_url).to eq("http://localhost:3000/oauth2/token") }
14
+ end
15
+
16
+ describe "callback phase instance methods" do
17
+ let(:uuid) { 123 }
18
+ let(:response_params) {
19
+ {
20
+ 'info' => {
21
+ 'uuid' => uuid
22
+ }
23
+ }
24
+ }
25
+ let(:access_token) { double('AccessToken', params: response_params) }
26
+
27
+ before do
28
+ allow(subject).to receive(:access_token).and_return(access_token)
29
+ end
30
+
31
+ describe "#uid" do
32
+ it "returns uuid from the info hash" do
33
+ expect(subject.uid).to eq(uuid)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'rack/test'
3
+ require 'webmock/rspec'
4
+ require 'omniauth'
5
+ require 'omniauth-jumpseller'
6
+
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ config.include WebMock::API
14
+ config.include Rack::Test::Methods
15
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
16
+
17
+ # Run specs in random order to surface order dependencies. If you find an
18
+ # order dependency and want to debug it, you can fix the order by providing
19
+ # the seed, which is printed after each run.
20
+ # --seed 1234
21
+ config.order = 'random'
22
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-jumpseller
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Paulo Fabiano Langer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth2
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
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: omniauth-oauth2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rack-test
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: simplecov
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
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Official OmniAuth strategy for Jumpseller
140
+ email:
141
+ - paulo.langer@jumpseller.com
142
+ executables:
143
+ - console
144
+ - setup
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".gitignore"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - lib/omniauth-jumpseller.rb
157
+ - lib/omniauth-jumpseller/version.rb
158
+ - lib/omniauth/strategies/jumpseller.rb
159
+ - omniauth-jumpseller.gemspec
160
+ - spec/omniauth/strategies/jumpseller_spec.rb
161
+ - spec/spec_helper.rb
162
+ homepage: ''
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.6.12
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Official OmniAuth strategy for Jumpseller
186
+ test_files:
187
+ - spec/omniauth/strategies/jumpseller_spec.rb
188
+ - spec/spec_helper.rb