omniauth-bonnier-admin-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: d96c1a01ef877d27d3fffbd749ed2056f92443ef
4
+ data.tar.gz: f969e748de9f60538dc8754d792284872ac589dd
5
+ SHA512:
6
+ metadata.gz: eb2a40c0d6ba9e9144f341c3675fb48684ce475f3c7e68e9569997f18b3bd765c69b029af5b756344322c16836da223c75fa47819708ae84c204463c6bddeb65
7
+ data.tar.gz: 40ca34b78fd07c1e7bb013da9402f4bd6c5de5d9a49caf42a031ddd00ffc66af2dfba9f70225e2ef76855d8a55fbdec037e5965616bd059317a0cb5a6b96a30e
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /pkg
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ omniauth-bonnier-oauth2
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-bonnier-oauth2 (1.2.2)
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.1)
16
+ multipart-post (>= 1.2, < 3)
17
+ hashie (3.4.1)
18
+ jwt (1.4.1)
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
+ bundler
63
+ omniauth-bonnier-oauth2!
64
+ rack-test
65
+ rake
66
+ rspec (~> 2.7)
67
+ simplecov
68
+ webmock
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ #OmniAuth Bonnier OAuth2
2
+
3
+ Strategy to authenticate Bonnier Admin in OmniAuth.
4
+
5
+ It's using the OAuth2 from the Bonnier Admin API
6
+
7
+ ##Usage
8
+ Add the strategy to your `Gemfile` alongside OmniAuth:
9
+
10
+ ```ruby
11
+ gem 'omniauth'
12
+ gem 'omniauth-bonnier-admin-oauth2'
13
+ ```
14
+
15
+ Integrate this strategy to your OmniAuth middleware.
16
+
17
+ ```ruby
18
+ use OmniAuth::Builder do
19
+ provider :bonnier_admin_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 @@
1
+ require 'omniauth/bonnier_admin_oauth2'
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/bonnier_admin_oauth2'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module BonnierAdminOauth2
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,44 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class BonnierAdminOauth2 < OmniAuth::Strategies::OAuth2
6
+ args [:client_id, :client_secret, :site]
7
+
8
+ option :site
9
+ option :name, "bonnier_admin_oauth2"
10
+ option :client_options, {
11
+ authorize_url: '/oauth/authorize',
12
+ token_url: '/oauth/token'
13
+ }
14
+
15
+ uid { raw_info["id"].to_s }
16
+
17
+ info do
18
+ {
19
+ email: raw_info["email"],
20
+ first_name: raw_info["first_name"],
21
+ last_name: raw_info["last_name"]
22
+ }
23
+ end
24
+
25
+ extra do
26
+ {
27
+ raw_info: raw_info
28
+ }
29
+ end
30
+
31
+ def callback_url
32
+ full_host + script_name + callback_path
33
+ end
34
+
35
+ def raw_info
36
+ @raw_info ||= access_token.get('/api/users/current.json').parsed
37
+ end
38
+
39
+ def client
40
+ ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options).merge(site: options.site))
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.join('..', 'lib', 'omniauth', 'bonnier_admin_oauth2', 'version'), __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'omniauth-bonnier-admin-oauth2'
6
+ s.version = OmniAuth::BonnierAdminOauth2::VERSION
7
+ s.author = ["Bonnier Publications - Interactive"]
8
+ s.homepage = "https://github.com/BenjaminMedia/omniauth-bonnier-admin-oauth2"
9
+
10
+ s.description = 'Bonnier Admin 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.add_development_dependency 'bundler'
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+
25
+ s.require_paths = ['lib']
26
+ end
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ describe OmniAuth::Strategies::BonnierAdminOauth2 do
4
+ let(:request) { double(:request, params: {}, cookies: {}, env: {}) }
5
+ let(:parsed_response) { double(:parsed_response) }
6
+ let(:response) { double(:response, :parsed => parsed_response) }
7
+ let(:access_token) { double(:access_token, options: {}) }
8
+
9
+ subject do
10
+ args = ["appid", "secret", @options || {}]
11
+ described_class.new(*args).tap do |strategy|
12
+ allow(strategy).to receive(:request).and_return(request)
13
+ end
14
+ end
15
+
16
+ describe "client options" do
17
+ let(:site_url) { "http://localhost:3000" }
18
+ let(:authorize_url) { "/oauth/authorize" }
19
+ let(:token_url) { "/oauth/token" }
20
+
21
+ it "has correct name" do
22
+ expect(subject.options.name).to eq("bonnier_admin_oauth2")
23
+ end
24
+
25
+ it "has correct site" do
26
+ expect(subject.options.client_options.site).to eq(site_url)
27
+ end
28
+
29
+ it "has correct authorize url" do
30
+ expect(subject.options.client_options.authorize_url).to eq(authorize_url)
31
+ end
32
+
33
+ it "has correct token url" do
34
+ expect(subject.options.client_options.token_url).to eq(token_url)
35
+ end
36
+ end
37
+
38
+ describe "#uid" do
39
+ let(:uid) { "123" }
40
+ let(:raw_info) { {"id" => uid} }
41
+ before do
42
+ allow(subject).to receive(:raw_info).and_return(raw_info)
43
+ end
44
+
45
+ it "returns the id from raw_info" do
46
+ expect(subject.uid).to eq(uid)
47
+ end
48
+ end
49
+
50
+ describe "#info" do
51
+ let(:first_name) { "Mike" }
52
+ let(:email) { "mike@example.com" }
53
+ let(:raw_info) { {"first_name" => first_name, "email" => email} }
54
+
55
+ before :each do
56
+ allow(subject).to receive(:raw_info).and_return(raw_info)
57
+ end
58
+
59
+ it "returns the first_name from raw_info" do
60
+ expect(subject.info[:first_name]).to eq(first_name)
61
+ end
62
+
63
+ it "returns the email from raw_info as email" do
64
+ expect(subject.info[:email]).to eq(email)
65
+ end
66
+ end
67
+
68
+ describe "#extra" do
69
+ end
70
+
71
+ describe "#raw_info" do
72
+ end
73
+ 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-admin-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,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bonnier-admin-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: 2016-06-22 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
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
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: Bonnier Admin OAuth2 strategy for OmniAuth 1.x
112
+ email:
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".gitignore"
118
+ - ".rspec"
119
+ - ".ruby-gemset"
120
+ - ".ruby-version"
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - README.md
124
+ - Rakefile
125
+ - lib/omniauth-bonnier-admin-oauth2.rb
126
+ - lib/omniauth/bonnier_admin_oauth2.rb
127
+ - lib/omniauth/bonnier_admin_oauth2/version.rb
128
+ - lib/omniauth/strategies/bonnier_admin_oauth2.rb
129
+ - omniauth-bonnier_admin-oauth2.gemspec
130
+ - spec/omniauth/strategies/bonnier_oauth2_spec.rb
131
+ - spec/spec_helper.rb
132
+ homepage: https://github.com/BenjaminMedia/omniauth-bonnier-admin-oauth2
133
+ licenses: []
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.8
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Bonnier Admin OAuth2 strategy for OmniAuth 1.x
155
+ test_files:
156
+ - spec/omniauth/strategies/bonnier_oauth2_spec.rb
157
+ - spec/spec_helper.rb