omniauth-bonnier-oauth2 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5bf7cb54d4c4958d7767badfc50b97f5a8fea08
4
+ data.tar.gz: ca8ffcd6108045ee9a3dbfb441160d8fa6f726f5
5
+ SHA512:
6
+ metadata.gz: d0cce74da31b15794eb431f5478e53e0158134284a125f765fbfa237c363883375b4ac3860c69391ae58ba08b6c3b1f0be34bcf3c85325f64a3708491127e93b
7
+ data.tar.gz: 796b450625006908a24895a617902ea0688aa01e4f1a1132b144512ab9846d0507d408b21ffa900a209f387ef51def72f6b83837daafae458fdf123dbba6c9f4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-bonnier-oauth2 (0.0.1)
5
+ omniauth-oauth2
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.3.6)
11
+ crack (0.4.2)
12
+ safe_yaml (~> 1.0.0)
13
+ diff-lcs (1.2.5)
14
+ docile (1.1.5)
15
+ faraday (0.9.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ hashie (3.3.2)
18
+ jwt (1.2.0)
19
+ multi_json (1.10.1)
20
+ multi_xml (0.5.5)
21
+ multipart-post (2.0.0)
22
+ oauth2 (1.0.0)
23
+ faraday (>= 0.8, < 0.10)
24
+ jwt (~> 1.0)
25
+ multi_json (~> 1.3)
26
+ multi_xml (~> 0.5)
27
+ rack (~> 1.2)
28
+ omniauth (1.2.2)
29
+ hashie (>= 1.2, < 4)
30
+ rack (~> 1.0)
31
+ omniauth-oauth2 (1.2.0)
32
+ faraday (>= 0.8, < 0.10)
33
+ multi_json (~> 1.3)
34
+ oauth2 (~> 1.0)
35
+ omniauth (~> 1.2)
36
+ rack (1.6.0)
37
+ rack-test (0.6.2)
38
+ rack (>= 1.0)
39
+ rake (10.4.2)
40
+ rspec (2.99.0)
41
+ rspec-core (~> 2.99.0)
42
+ rspec-expectations (~> 2.99.0)
43
+ rspec-mocks (~> 2.99.0)
44
+ rspec-core (2.99.2)
45
+ rspec-expectations (2.99.2)
46
+ diff-lcs (>= 1.1.3, < 2.0)
47
+ rspec-mocks (2.99.2)
48
+ safe_yaml (1.0.4)
49
+ simplecov (0.9.1)
50
+ docile (~> 1.1.0)
51
+ multi_json (~> 1.0)
52
+ simplecov-html (~> 0.8.0)
53
+ simplecov-html (0.8.0)
54
+ webmock (1.20.4)
55
+ addressable (>= 2.3.6)
56
+ crack (>= 0.3.2)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ omniauth-bonnier-oauth2!
63
+ rack-test
64
+ rake
65
+ rspec (~> 2.7)
66
+ simplecov
67
+ webmock
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ #OmniAuth Bonnier OAuth2
2
+
3
+ Strategy to authenticate Bonnier in OmniAuth.
4
+
5
+ It's using the OAuth2 from the Bonnier API
6
+
7
+ ##Usage
8
+ Add the strategy to your `Gemfile` alongside OmniAuth:
9
+
10
+ ```ruby
11
+ gem 'omniauth'
12
+ gem 'omniauth-bonnier-oauth2'
13
+ ```
14
+
15
+ Integrate this strategy to your OmniAuth middleware.
16
+
17
+ ```ruby
18
+ use OmniAuth::Builder do
19
+ provider :bonnier_oauth2, ENV['BONNIER_KEY'], ENV['BONNIER_SECRET']
20
+ end
21
+ ```
22
+
23
+ You need to add your key and secret.
24
+
25
+ Also remember to add the full callback path to your Bonnier App Console, for example: http://example.com/auth/bonnier-oauth2/callback
26
+
27
+ For more information check the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module BonnierOauth2
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'strategies', 'bonnier_oauth2')
@@ -0,0 +1,34 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class BonnierOauth2 < OmniAuth::Strategies::OAuth2
6
+ option :name, "bonnier_oauth2"
7
+ option :client_options, {
8
+ :site => 'http://localhost:3000',
9
+ :authorize_url => '/api/oauth/authorize',
10
+ :token_url => '/api/oauth/token'
11
+ }
12
+
13
+ uid { raw_info["id"].to_s }
14
+
15
+ info do
16
+ {
17
+ "email" => raw_info["email"],
18
+ "username" => raw_info["username"],
19
+ "profile_image" => raw_info["profile_image"]
20
+ }
21
+ end
22
+
23
+ extra do
24
+ {
25
+ 'raw_info' => raw_info
26
+ }
27
+ end
28
+
29
+ def raw_info
30
+ @raw_info ||= access_token.get('/api/v2/users/current.json').parsed
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'bonnier_oauth2')
data/lib/tasks/.keep ADDED
File without changes
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.join('..', 'lib', 'omniauth', 'bonnier_oauth2', 'version'), __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'omniauth-bonnier-oauth2'
6
+ s.version = OmniAuth::BonnierOauth2::VERSION
7
+ s.author = ["Bonnier Publications - Interactive"]
8
+ s.homepage = "https://github.com/BenjaminMedia/WhiteAlbum"
9
+
10
+ s.description = 'Bonnier OAuth2 strategy for OmniAuth 1.x'
11
+ s.summary = s.description
12
+
13
+ s.add_dependency "omniauth-oauth2"
14
+
15
+ s.add_development_dependency 'rake'
16
+ s.add_development_dependency 'rspec', '~> 2.7'
17
+ s.add_development_dependency 'rack-test'
18
+ s.add_development_dependency 'simplecov'
19
+ s.add_development_dependency 'webmock'
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+
24
+ s.require_paths = ['lib']
25
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::BonnierOauth2 do
4
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
5
+ let(:parsed_response) { stub('ParsedResponse') }
6
+ let(:response) { stub('Response', :parsed => parsed_response) }
7
+ let(:access_token) { stub('AccessToken', :options => {}) }
8
+
9
+ subject do
10
+ args = ['appid', 'secret', @options || {}].compact
11
+ OmniAuth::Strategies::BonnierOauth2.new(*args).tap do |strategy|
12
+ allow(strategy).to receive(:request) {
13
+ request
14
+ }
15
+ end
16
+ end
17
+
18
+ describe 'client options' do
19
+ it 'should have correct name' do
20
+ expect(subject.options.name).to eq('bonnier_oauth2')
21
+ end
22
+
23
+ it 'should have correct site' do
24
+ expect(subject.options.client_options.site).to eq('http://localhost:3000')
25
+ end
26
+
27
+ it 'should have correct authorize url' do
28
+ expect(subject.options.client_options.authorize_url).to eq('/api/oauth/authorize')
29
+ end
30
+
31
+ it 'should have correct token url' do
32
+ expect(subject.options.client_options.token_url).to eq('/api/oauth/token')
33
+ end
34
+ end
35
+
36
+ describe "#uid" do
37
+ before do
38
+ subject.stub(:raw_info) do
39
+ {'user' => {'id' => '123'}}
40
+ end
41
+ end
42
+
43
+ it 'returns the id from raw_info' do
44
+ expect(subject.uid).to eq('123')
45
+ end
46
+ end
47
+
48
+ describe "#info" do
49
+ before :each do
50
+ subject.stub(:raw_info) do
51
+ {"user" => {'first_name' => "Mike", 'email' => "mike@example.com"}}
52
+ end
53
+ end
54
+
55
+ it 'returns the first_name from raw_info' do
56
+ expect(subject.info['first_name']).to eq('Mike')
57
+ end
58
+
59
+ it 'returns the email from raw_info as email' do
60
+ expect(subject.info['email']).to eq('mike@example.com')
61
+ end
62
+ end
63
+
64
+ describe "#extra" do
65
+ end
66
+
67
+ describe "#raw_info" do
68
+ end
69
+ end
@@ -0,0 +1,17 @@
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-bonnier-oauth2'
10
+ RSpec.configure do |config|
11
+ config.include WebMock::API
12
+ config.include Rack::Test::Methods
13
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = :expect
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bonnier-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bonnier Publications - Interactive
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-21 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: '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: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: '2.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
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: simplecov
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
+ description: Bonnier OAuth2 strategy for OmniAuth 1.x
98
+ email:
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".rspec"
104
+ - Gemfile
105
+ - Gemfile.lock
106
+ - README.md
107
+ - Rakefile
108
+ - lib/omniauth-bonnier-oauth2.rb
109
+ - lib/omniauth/bonnier_oauth2.rb
110
+ - lib/omniauth/bonnier_oauth2/version.rb
111
+ - lib/omniauth/strategies/bonnier_oauth2.rb
112
+ - lib/tasks/.keep
113
+ - omniauth-bonnier-oauth2.gemspec
114
+ - spec/omniauth/strategies/bonnier_oauth2_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/BenjaminMedia/WhiteAlbum
117
+ licenses: []
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.5
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Bonnier OAuth2 strategy for OmniAuth 1.x
139
+ test_files:
140
+ - spec/omniauth/strategies/bonnier_oauth2_spec.rb
141
+ - spec/spec_helper.rb