omniauth-cortex 0.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: 43b096b78d9d4c4271d3c963f6fa81ea570e691a
4
+ data.tar.gz: d982abfbed44454896fd3ab815b559d4e963067f
5
+ SHA512:
6
+ metadata.gz: 632f55e37724c762466d62946ea96b6c6be62d7548d5dbb039fb864fb648ba7a9e197cd3fa3db3b211acf3d31d75e314f38840a20544805c55895c3192074cdf
7
+ data.tar.gz: 44b007a452c0248f3872f000eeaa97ae67cd03d227ed698b6b36de6b0b8ae42ea88a58355df7935efb901af4d267eac2ffafd9a8755da4bcfba40daf71a8f8ff
data/.editorconfig ADDED
@@ -0,0 +1,8 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
data/.gitignore ADDED
@@ -0,0 +1,47 @@
1
+ # Ignore bundler config.
2
+ /.bundle
3
+ /vendor/bundle
4
+
5
+ /public/assets/
6
+ /public/media/
7
+
8
+ # Ignore the default SQLite database.
9
+ /db/*.sqlite3
10
+ /db/*.sqlite3-journal
11
+
12
+ # Ignore all logfiles and tempfiles.
13
+ /log/*.log
14
+ /tmp
15
+
16
+ # OS Files
17
+ .DS_Store
18
+ ._.DS_Store
19
+
20
+ # Text-editor/IDE generated files
21
+ *.sublime-workspace
22
+ *.sublime-project
23
+ /.idea
24
+ *.iml
25
+
26
+ *.rbc
27
+ *.sassc
28
+ .sass-cache
29
+ capybara-*.html
30
+ .rspec
31
+ /public/system
32
+ /coverage/
33
+ /spec/tmp
34
+ **.orig
35
+ rerun.txt
36
+ pickle-email-*.html
37
+ config/initializers/secret_token.rb
38
+
39
+ # these should all be checked in to normalise the environment:
40
+ # Gemfile.lock, .ruby-version, .ruby-gemset
41
+
42
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
43
+ .rvmrc
44
+
45
+ # Ignore Tddium user-specific config
46
+ .tddium*
47
+ /ui.tddium*
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-cortex.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ gem 'growl'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,114 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-cortex (0.0.1)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2 (~> 1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.6)
12
+ celluloid (0.15.2)
13
+ timers (~> 1.1.0)
14
+ celluloid-io (0.15.0)
15
+ celluloid (>= 0.15.0)
16
+ nio4r (>= 0.5.0)
17
+ coderay (1.1.0)
18
+ crack (0.4.2)
19
+ safe_yaml (~> 1.0.0)
20
+ diff-lcs (1.2.5)
21
+ docile (1.1.3)
22
+ faraday (0.9.0)
23
+ multipart-post (>= 1.2, < 3)
24
+ ffi (1.9.3)
25
+ formatador (0.2.4)
26
+ growl (1.0.3)
27
+ guard (2.6.0)
28
+ formatador (>= 0.2.4)
29
+ listen (~> 2.7)
30
+ lumberjack (~> 1.0)
31
+ pry (>= 0.9.12)
32
+ thor (>= 0.18.1)
33
+ guard-bundler (2.0.0)
34
+ bundler (~> 1.0)
35
+ guard (~> 2.2)
36
+ guard-rspec (4.2.8)
37
+ guard (~> 2.1)
38
+ rspec (>= 2.14, < 4.0)
39
+ hashie (2.1.0)
40
+ jwt (0.1.11)
41
+ multi_json (>= 1.5)
42
+ listen (2.7.1)
43
+ celluloid (>= 0.15.2)
44
+ celluloid-io (>= 0.15.0)
45
+ rb-fsevent (>= 0.9.3)
46
+ rb-inotify (>= 0.9)
47
+ lumberjack (1.0.5)
48
+ method_source (0.8.2)
49
+ multi_json (1.9.2)
50
+ multi_xml (0.5.5)
51
+ multipart-post (2.0.0)
52
+ nio4r (1.0.0)
53
+ oauth2 (0.9.3)
54
+ faraday (>= 0.8, < 0.10)
55
+ jwt (~> 0.1.8)
56
+ multi_json (~> 1.3)
57
+ multi_xml (~> 0.5)
58
+ rack (~> 1.2)
59
+ omniauth (1.2.1)
60
+ hashie (>= 1.2, < 3)
61
+ rack (~> 1.0)
62
+ omniauth-oauth2 (1.1.2)
63
+ faraday (>= 0.8, < 0.10)
64
+ multi_json (~> 1.3)
65
+ oauth2 (~> 0.9.3)
66
+ omniauth (~> 1.2)
67
+ pry (0.9.12.6)
68
+ coderay (~> 1.0)
69
+ method_source (~> 0.8)
70
+ slop (~> 3.4)
71
+ rack (1.5.2)
72
+ rack-test (0.6.2)
73
+ rack (>= 1.0)
74
+ rake (10.2.2)
75
+ rb-fsevent (0.9.4)
76
+ rb-inotify (0.9.3)
77
+ ffi (>= 0.5.0)
78
+ rspec (2.14.1)
79
+ rspec-core (~> 2.14.0)
80
+ rspec-expectations (~> 2.14.0)
81
+ rspec-mocks (~> 2.14.0)
82
+ rspec-core (2.14.8)
83
+ rspec-expectations (2.14.5)
84
+ diff-lcs (>= 1.1.3, < 2.0)
85
+ rspec-mocks (2.14.6)
86
+ safe_yaml (1.0.2)
87
+ simplecov (0.8.2)
88
+ docile (~> 1.1.0)
89
+ multi_json
90
+ simplecov-html (~> 0.8.0)
91
+ simplecov-html (0.8.0)
92
+ slop (3.5.0)
93
+ thor (0.19.1)
94
+ timers (1.1.0)
95
+ webmock (1.17.4)
96
+ addressable (>= 2.2.7)
97
+ crack (>= 0.3.2)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ bundler (~> 1.6)
104
+ growl
105
+ guard
106
+ guard-bundler
107
+ guard-rspec
108
+ omniauth-cortex!
109
+ rack-test
110
+ rake
111
+ rb-fsevent
112
+ rspec (~> 2.14)
113
+ simplecov
114
+ webmock
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-cortex.gemspec')
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alex Tharp
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,40 @@
1
+ # OmniAuth::Cortex
2
+
3
+ OmniAuth strategy for Cortex's OAuth 2.0 implementation
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-cortex'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-cortex
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ use OmniAuth::Builder do
23
+ provider :cortex, ENV['CORTEX_KEY'], ENV['CORTEX_SECRET'], scope: 'scope1, scope2, scope3'
24
+ end
25
+ ```
26
+
27
+ ## Override Environment
28
+
29
+ If you would like to change the URLs used by omniauth-cortex, override :client_options in the provider config step.
30
+
31
+ ```ruby
32
+ provider :cortex, ENV['CORTEX_KEY'], ENV['CORTEX_SECRET'], scope: 'scope1, scope2, scope3',
33
+ {
34
+ :client_options => {
35
+ :site => 'http://localhost:3000/api/v1',
36
+ :authorize_url => 'http://localhost:3000/oauth/authorize',
37
+ :token_url => 'http://localhost:3000/oauth/access_token'
38
+ }
39
+ }
40
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,36 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Cortex < OmniAuth::Strategies::OAuth2
6
+ option :name, 'cortex'
7
+
8
+ option :client_options, {
9
+ :site => 'http://stg.api.cbcortex.com/api/v1',
10
+ :authorize_url => 'http://stg.api.cbcortex.com/oauth/authorize',
11
+ :token_url => 'http://stg.api.cbcortex.com/oauth/access_token'
12
+ }
13
+
14
+ uid{ raw_info['id'] }
15
+
16
+ info do
17
+ {
18
+ :nickname => raw_info['email'],
19
+ :email => raw_info['email'],
20
+ :name => raw_info['fullname'],
21
+ :first_name => raw_info['firstname'],
22
+ :last_name => raw_info['lastname'],
23
+ :image => raw_info['gravatar']
24
+ }
25
+ end
26
+
27
+ extra do
28
+ {:raw_info => raw_info}
29
+ end
30
+
31
+ def raw_info
32
+ @raw_info ||= access_token.get('/users/me').parsed
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Cortex
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-cortex/version'
2
+ require 'omniauth/strategies/cortex'
@@ -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-cortex/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'omniauth-cortex'
8
+ spec.version = OmniAuth::Cortex::VERSION
9
+ spec.authors = ['Alex Tharp']
10
+ spec.email = ['alex.tharp@careerbuilder.com']
11
+ spec.summary = %q{OmniAuth strategy for Cortex's OAuth 2.0 implementation}
12
+ spec.homepage = 'https://github.com/cb-talent-development/omniauth-cortex'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rspec', '~> 2.14'
23
+ spec.add_development_dependency 'rack-test'
24
+ spec.add_development_dependency 'simplecov'
25
+ spec.add_development_dependency 'webmock'
26
+
27
+ spec.add_dependency 'omniauth', '~> 1.0'
28
+ spec.add_dependency 'omniauth-oauth2', '~> 1.1'
29
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Cortex do
4
+ let(:access_token) { stub('AccessToken', :options => {}) }
5
+ let(:parsed_response) { stub('ParsedResponse') }
6
+ let(:response) { stub('Response', :parsed => parsed_response) }
7
+
8
+ let(:local_site) { 'http://localhost:3000/api/v1' }
9
+ let(:local_authorize_url) { 'http://localhost:3000/oauth/authorize' }
10
+ let(:local_token_url) { 'http://localhost:3000/oauth/access_token' }
11
+ let(:local) do
12
+ OmniAuth::Strategies::Cortex.new('CORTEX_KEY', 'CORTEX_SECRET',
13
+ {
14
+ :client_options => {
15
+ :site => local_site,
16
+ :authorize_url => local_authorize_url,
17
+ :token_url => local_token_url
18
+ }
19
+ }
20
+ )
21
+ end
22
+
23
+ subject do
24
+ OmniAuth::Strategies::Cortex.new({})
25
+ end
26
+
27
+ before(:each) do
28
+ subject.stub!(:access_token).and_return(access_token)
29
+ end
30
+
31
+ context "client options" do
32
+ it 'should have correct site' do
33
+ subject.options.client_options.site.should eq('http://stg.api.cbcortex.com/api/v1')
34
+ end
35
+
36
+ it 'should have correct authorize url' do
37
+ subject.options.client_options.authorize_url.should eq('http://stg.api.cbcortex.com/oauth/authorize')
38
+ end
39
+
40
+ it 'should have correct token url' do
41
+ subject.options.client_options.token_url.should eq('http://stg.api.cbcortex.com/oauth/access_token')
42
+ end
43
+
44
+ describe "should be overrideable" do
45
+ it "for site" do
46
+ local.options.client_options.site.should eq(local_site)
47
+ end
48
+
49
+ it "for authorize url" do
50
+ local.options.client_options.authorize_url.should eq(local_authorize_url)
51
+ end
52
+
53
+ it "for token url" do
54
+ local.options.client_options.token_url.should eq(local_token_url)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "#raw_info" do
60
+ it "should use relative paths" do
61
+ access_token.should_receive(:get).with('/users/me').and_return(response)
62
+ subject.raw_info.should eq(parsed_response)
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,15 @@
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-cortex'
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
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-cortex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Tharp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
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.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
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: omniauth
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: omniauth-oauth2
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.1'
125
+ description:
126
+ email:
127
+ - alex.tharp@careerbuilder.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".editorconfig"
133
+ - ".gitignore"
134
+ - Gemfile
135
+ - Gemfile.lock
136
+ - Guardfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - lib/omniauth-cortex.rb
141
+ - lib/omniauth-cortex/version.rb
142
+ - lib/omniauth/strategies/cortex.rb
143
+ - omniauth-cortex.gemspec
144
+ - spec/omniauth/strategies/cortex_spec.rb
145
+ - spec/spec_helper.rb
146
+ homepage: https://github.com/cb-talent-development/omniauth-cortex
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.2.2
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: OmniAuth strategy for Cortex's OAuth 2.0 implementation
170
+ test_files:
171
+ - spec/omniauth/strategies/cortex_spec.rb
172
+ - spec/spec_helper.rb