omniauth-g5 0.1.0

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: 11b40e7d7c3dc0c0dfd4d01586f52f0d29ac1b62
4
+ data.tar.gz: fd85bdb45987fe74f697f47a98257e248b28512f
5
+ SHA512:
6
+ metadata.gz: e1101ff8051b3e386ae8bb30da99adc6691fc7558dd8f8c97f2874c6d827566f586faf42784ae422ed7240737af57dd2ad565dcefc4f6ebee23b1dcec59dfe55
7
+ data.tar.gz: 34b9d4c94b0e656ddf3e6aa4a99308e3ad609e33fec5eab63977b188ad1108d832c7cffccda04d1b290699dead53520b4d01ca98afbea380bbd363f5ef66c6a7
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ g5_omniauth
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # v0.1.0 (2014-03-12)
2
+
3
+ * Moved `rake g5:export_users` task to
4
+ [devise_g5_authenticatable](https://github.com/G5/devise_g5_authenticatable)
5
+ * First open source release to [RubyGems](https://rubygems.org)
6
+
7
+ # v0.0.2 (2013-11-06)
8
+
9
+ * Changed `rake g5:export_users` task to read default argument values
10
+ from environment variables:
11
+ * `G5_AUTH_CLIENT_ID` - the G5 OAuth application ID
12
+ * `G5_AUTH_CLIENT_SECRET` - the G5 OAuth application secret
13
+ * `G5_AUTH_REDIRECT_URI` - the redirect URI registered with the auth server
14
+ * `G5_AUTH_ENDPOINT` - the auth server endpoint URL
15
+ * `G5_AUTH_AUTHORIZATION_CODE` - the G5 OAuth authorization code for
16
+ obtaining an access token
17
+ * Changed argument order for `rake g5:export_users` such that
18
+ `authorization_code` now comes first.
19
+ * Renamed any references to the client callback URL to redirect URI, to
20
+ maintain terminology consistent with the OAuth 2.0 specification.
21
+
22
+ # v0.0.1 (2013-07-25)
23
+
24
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-g5.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 G5
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,104 @@
1
+ # G5 OmniAuth
2
+
3
+ This is the [OmniAuth][omniauth] strategy for authenticating to G5 via
4
+ [OAuth 2.0][oauth].
5
+
6
+ [omniauth]: https://github.com/intridea/omniauth
7
+ [oauth]: http://oauth.net/2/
8
+
9
+ ## Current version
10
+
11
+ 0.1.0
12
+
13
+ ## Requirements
14
+
15
+ * G5 Auth client credentials
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'omniauth-g5'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ ```console
28
+ $ bundle
29
+ ```
30
+
31
+ Or install it yourself as:
32
+
33
+ ```console
34
+ $ gem install omniauth-g5
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ The strategy must be initialized with a valid client application ID and secret
40
+ provided by the G5 auth service. For example, to use the G5 strategy with
41
+ [devise][devise]:
42
+
43
+ ```ruby
44
+ Devise.setup do |config|
45
+ config.omniauth :g5, ENV['G5_AUTH_CLIENT_ID'], ENV['G5_AUTH_CLIENT_SECRET']
46
+ end
47
+ ```
48
+
49
+ For more general information about setting up and using OmniAuth, see the
50
+ [official OmniAuth documentation][omniauth-wiki].
51
+
52
+ [devise]: https://github.com/plataformatec/devise
53
+ [omniauth-wiki]: https://github.com/intridea/omniauth/wiki
54
+
55
+ ## Authors
56
+
57
+ * Maeve Revels / [@maeve](https://github.com/maeve)
58
+ * Rob Revels / [@sleverbor](https://github.com/sleverbor)
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it
63
+ 2. Get it running
64
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 4. Write your code and **specs**
66
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 6. Push to the branch (`git push origin my-new-feature`)
68
+ 7. Create new Pull Request
69
+
70
+ If you find bugs, have feature requests or questions, please
71
+ [file an issue](https://github.com/G5/omniauth-g5/issues).
72
+
73
+ ### Specs
74
+
75
+ Just execute:
76
+
77
+ ```console
78
+ $ bundle exec rspec spec
79
+ ```
80
+
81
+ ## License
82
+
83
+ Copyright (c) 2013 G5
84
+
85
+ MIT License
86
+
87
+ Permission is hereby granted, free of charge, to any person obtaining
88
+ a copy of this software and associated documentation files (the
89
+ "Software"), to deal in the Software without restriction, including
90
+ without limitation the rights to use, copy, modify, merge, publish,
91
+ distribute, sublicense, and/or sell copies of the Software, and to
92
+ permit persons to whom the Software is furnished to do so, subject to
93
+ the following conditions:
94
+
95
+ The above copyright notice and this permission notice shall be
96
+ included in all copies or substantial portions of the Software.
97
+
98
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
99
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
100
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
101
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
102
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
103
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
104
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require 'omniauth-g5/version'
2
+ require 'omniauth/strategies/g5'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module G5
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class G5 < OmniAuth::Strategies::OAuth2
6
+ option :name, :g5
7
+
8
+ option :client_options, {
9
+ :site => 'https://auth.g5search.com',
10
+ :authorize_url => '/oauth/authorize',
11
+ :token_url => '/oauth/token'
12
+ }
13
+
14
+ uid { raw_info['id'] }
15
+
16
+ info do
17
+ {:email => raw_info['email']}
18
+ end
19
+
20
+ def raw_info
21
+ @raw_info ||= access_token.get('/v1/me.json').parsed
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-g5/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'omniauth-g5'
8
+ gem.version = OmniAuth::G5::VERSION
9
+ gem.authors = ['Maeve Revels', 'Rob Revels']
10
+ gem.email = ['maeve.revels@getg5.com', 'rob.revels@getg5.com']
11
+ gem.description = 'OmniAuth strategy for G5'
12
+ gem.summary = 'OmniAuth strategy for G5'
13
+ gem.homepage = 'https://github.com/G5/omniauth-g5'
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency('omniauth-oauth2', '~> 1.1')
21
+
22
+ gem.add_development_dependency('rspec', '~> 2.14')
23
+ gem.add_development_dependency('simplecov', '~> 0.7')
24
+ gem.add_development_dependency('codeclimate-test-reporter')
25
+ gem.add_development_dependency('pry')
26
+ gem.add_development_dependency('webmock')
27
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::G5 do
4
+ subject { strategy }
5
+ let(:strategy) { OmniAuth::Strategies::G5.new(rack_app, app_id, app_secret, options) }
6
+
7
+ let(:rack_app) { double(:rack_app) }
8
+ let(:app_id) { 'test_app' }
9
+ let(:app_secret) { '1234567890qwerty' }
10
+ let(:options) { Hash.new }
11
+
12
+ let(:access_token) { double(:access_token, :get => response) }
13
+ let(:response) { double(:response, :parsed => parsed_response) }
14
+ let(:parsed_response) { double(:parsed_response) }
15
+ before { strategy.stub(:access_token => access_token) }
16
+
17
+ its(:name) { should == :g5 }
18
+
19
+ it 'should have the correct client id' do
20
+ expect(strategy.options[:client_id]).to eq(app_id)
21
+ end
22
+
23
+ it 'should have the correct client secret' do
24
+ expect(strategy.options[:client_secret]).to eq(app_secret)
25
+ end
26
+
27
+ describe 'client_options' do
28
+ subject(:client_options) { strategy.options.client_options }
29
+
30
+ context 'with default options' do
31
+ its(:site) { should == 'https://auth.g5search.com' }
32
+ its(:authorize_url) { should == '/oauth/authorize' }
33
+ its(:token_url) { should == '/oauth/token' }
34
+ end
35
+
36
+ context 'with partially overridden options' do
37
+ let(:options) do
38
+ {:client_options => {:site => 'https://custom.app.com'}}
39
+ end
40
+
41
+ its(:site) { should == 'https://custom.app.com' }
42
+ its(:authorize_url) { should == '/oauth/authorize' }
43
+ its(:token_url) { should == '/oauth/token' }
44
+ end
45
+ end
46
+
47
+ describe '#raw_info' do
48
+ subject(:raw_info) { strategy.raw_info }
49
+
50
+ it 'should retrieve the user info from the server' do
51
+ access_token.should_receive(:get).with('/v1/me.json').and_return(response)
52
+ raw_info
53
+ end
54
+
55
+ it { should == parsed_response }
56
+ end
57
+
58
+ describe '#uid' do
59
+ subject(:uid) { strategy.uid }
60
+ let(:parsed_response) do
61
+ {'id' => 123}
62
+ end
63
+
64
+ it { should == 123 }
65
+ end
66
+
67
+ describe '#info' do
68
+ subject(:info) { strategy.info }
69
+ let(:parsed_response) do
70
+ {'email' => 'test@test.com'}
71
+ end
72
+
73
+ its([:email]) { should == 'test@test.com' }
74
+ end
75
+ end
@@ -0,0 +1,30 @@
1
+ require 'simplecov'
2
+ SimpleCov.start 'test_frameworks'
3
+
4
+ require 'codeclimate-test-reporter'
5
+ CodeClimate::TestReporter.start
6
+
7
+ require 'pry'
8
+ require 'omniauth-g5'
9
+
10
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
11
+
12
+ require 'webmock/rspec'
13
+
14
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
15
+ RSpec.configure do |config|
16
+ config.treat_symbols_as_metadata_keys_with_true_values = true
17
+ config.run_all_when_everything_filtered = true
18
+ config.filter_run :focus
19
+
20
+ # Run specs in random order to surface order dependencies. If you find an
21
+ # order dependency and want to debug it, you can fix the order by providing
22
+ # the seed, which is printed after each run.
23
+ # --seed 1234
24
+ config.order = 'random'
25
+
26
+ config.before { OmniAuth.config.test_mode = true }
27
+ config.after { OmniAuth.config.test_mode = false }
28
+
29
+ config.after(:suite) { WebMock.disable! }
30
+ end
File without changes
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-g5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Maeve Revels
8
+ - Rob Revels
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth2
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.1'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.14'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.14'
42
+ - !ruby/object:Gem::Dependency
43
+ name: simplecov
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: codeclimate-test-reporter
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: webmock
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: OmniAuth strategy for G5
99
+ email:
100
+ - maeve.revels@getg5.com
101
+ - rob.revels@getg5.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".ruby-gemset"
109
+ - ".ruby-version"
110
+ - CHANGELOG.md
111
+ - Gemfile
112
+ - LICENSE
113
+ - README.md
114
+ - Rakefile
115
+ - lib/omniauth-g5.rb
116
+ - lib/omniauth-g5/version.rb
117
+ - lib/omniauth/strategies/g5.rb
118
+ - omniauth-g5.gemspec
119
+ - spec/omniauth/strategies/g5_spec.rb
120
+ - spec/spec_helper.rb
121
+ - spec/support/.gitkeep
122
+ homepage: https://github.com/G5/omniauth-g5
123
+ licenses: []
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.2.0
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: OmniAuth strategy for G5
145
+ test_files:
146
+ - spec/omniauth/strategies/g5_spec.rb
147
+ - spec/spec_helper.rb
148
+ - spec/support/.gitkeep
149
+ has_rdoc: