omniauth-realgeeks 0.5.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: ab5b710812a27984b0b42933e5e9fd5c48ee24dc
4
+ data.tar.gz: 5e6008879a829d02ca9dd8197da423d3f53db6e9
5
+ SHA512:
6
+ metadata.gz: a1b01b811bb08edfa902d44f95c79cbbbb77b38e661b414648a303312badcc0a043e2ac1fee98ad67673ce6f8648b659b8958f47f02001a59edf6c46d1a59e1f
7
+ data.tar.gz: 02ba172ca653338490c3a0f7273f048ca47f749777bcd7d15ca500537d6987dce48ad350a301ae8931eb5162c2cbdf2f7f0ae1c560a00d5ac77d56366a93c8cf
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-github.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/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :version => 2 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-github.gemspec')
10
+ end
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # OmniAuth RealGeeks
2
+
3
+ This is the official OmniAuth strategy for authenticating against RealGeeks. To
4
+ use it, you'll need to send us an request for an OAuth2 Application ID and Secret
5
+ on the [RealGeeks Support Page](https://www.realgeeks.com/support/).
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider :github, ENV['RG_OAUTH_KEY'], ENV['RG_OAUTH_SECRET'],
11
+ scope: :default
12
+ end
13
+
14
+ ## License
15
+
16
+ Copyright (c) 2011 Michael Bleigh and Intridea, Inc.
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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,2 @@
1
+ require "omniauth-realgeeks/version"
2
+ require 'omniauth/strategies/realgeeks'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module RealGeeks
3
+ VERSION = "0.5.0"
4
+ end
5
+ end
@@ -0,0 +1,61 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class RealGeeks < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'https://login.realgeeks.com/oauth',
8
+ :authorize_url => 'https://login.realgeeks.com/oauth/authorize',
9
+ :token_url => 'https://login.realgeeks.com/oauth/token'
10
+ }
11
+
12
+ def request_phase
13
+ super
14
+ end
15
+
16
+ def authorize_params
17
+ super.tap do |params|
18
+ %w[scope client_options].each do |v|
19
+ if request.params[v]
20
+ params[v.to_sym] = request.params[v]
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ def callback_phase
27
+ super
28
+ end
29
+
30
+ uid { raw_info['id'].to_s }
31
+
32
+ info do
33
+ {
34
+ 'name' => raw_info['first_name'] + ' ' + raw_info['last_name'],
35
+ 'email' => email,
36
+ 'first_name' => raw_info['first_name'],
37
+ 'last_name' => raw_info['last_name'],
38
+ }
39
+ end
40
+
41
+ extra do
42
+ {
43
+ 'active_status' => raw_info['active_status'],
44
+ 'is_owner' => raw_info['is_owner'],
45
+ 'super_user' => raw_info['super_user'],
46
+ }
47
+ end
48
+
49
+ def raw_info
50
+ access_token.options[:mode] = :header
51
+ @raw_info ||= access_token.get('user').parsed
52
+ end
53
+
54
+ def email
55
+ raw_info['email']
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ OmniAuth.config.add_camelization 'realgeeks', 'RealGeeks'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-realgeeks/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["RealGeeks", "Christopher Sass"]
6
+ gem.email = ["chris@realgeeks.com", "chris@lupinedev.com"]
7
+ gem.description = %q{Official OmniAuth strategy for RealGeeks.}
8
+ gem.summary = %q{Official OmniAuth strategy for RealGeeks.}
9
+ gem.homepage = "https://github.com/RealGeeks/omniauth-realgeeks"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-realgeeks"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::RealGeeks::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency 'rspec', '~> 2.7'
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'simplecov'
23
+ gem.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::RealGeeks do
4
+ let(:access_token) { double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { double('ParsedResponse') }
6
+ let(:response) { double('Response', :parsed => parsed_response) }
7
+
8
+ let(:alternative_site) { 'https://some.other.site.com/oauth' }
9
+ let(:alternative_authorize_url) { 'https://some.other.site.com/oauth/authorize' }
10
+ let(:alternative_token_url) { 'https://some.other.site.com/oauth/token' }
11
+ let(:alternative) do
12
+ OmniAuth::Strategies::RealGeeks.new('realgeeks_KEY', 'realgeeks_SECRET',
13
+ {
14
+ :client_options => {
15
+ :site => alternative_site,
16
+ :authorize_url => alternative_authorize_url,
17
+ :token_url => alternative_token_url
18
+ }
19
+ }
20
+ )
21
+ end
22
+
23
+ subject do
24
+ OmniAuth::Strategies::RealGeeks.new({})
25
+ end
26
+
27
+ before(:each) do
28
+ allow(subject).to receive(: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("https://login.realgeeks.com/oauth")
34
+ end
35
+
36
+ it 'should have correct authorize url' do
37
+ subject.options.client_options.authorize_url.should eq('https://login.realgeeks.com/oauth/authorize')
38
+ end
39
+
40
+ it 'should have correct token url' do
41
+ subject.options.client_options.token_url.should eq('https://login.realgeeks.com/oauth/token')
42
+ end
43
+
44
+ describe "should be overrideable" do
45
+ it "for site" do
46
+ alternative.options.client_options.site.should eq(alternative_site)
47
+ end
48
+
49
+ it "for authorize url" do
50
+ alternative.options.client_options.authorize_url.should eq(alternative_authorize_url)
51
+ end
52
+
53
+ it "for token url" do
54
+ alternative.options.client_options.token_url.should eq(alternative_token_url)
55
+ end
56
+ end
57
+ end
58
+
59
+ context "#email" do
60
+ it "should return email from raw_info if available" do
61
+ allow(subject).to receive(:raw_info).and_return({'email' => 'you@example.com'})
62
+ subject.email.should eq('you@example.com')
63
+ end
64
+
65
+ it "should return nil if there is no raw_info and email access is not allowed" do
66
+ allow(subject).to receive(:raw_info).and_return({})
67
+ subject.email.should be_nil
68
+ end
69
+
70
+ end
71
+
72
+ context "#raw_info" do
73
+ it "should use relative paths" do
74
+ access_token.should_receive(:get).with('user').and_return(response)
75
+ subject.raw_info.should eq(parsed_response)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,16 @@
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-realgeeks'
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
16
+
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-realgeeks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - RealGeeks
8
+ - Christopher Sass
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.1'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rack-test
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: simplecov
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: Official OmniAuth strategy for RealGeeks.
99
+ email:
100
+ - chris@realgeeks.com
101
+ - chris@lupinedev.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - Gemfile
109
+ - Guardfile
110
+ - README.md
111
+ - Rakefile
112
+ - lib/omniauth-realgeeks.rb
113
+ - lib/omniauth-realgeeks/version.rb
114
+ - lib/omniauth/strategies/realgeeks.rb
115
+ - omniauth-realgeeks.gemspec
116
+ - spec/omniauth/strategies/realgeeks_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/RealGeeks/omniauth-realgeeks
119
+ licenses: []
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.2.2
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Official OmniAuth strategy for RealGeeks.
141
+ test_files:
142
+ - spec/omniauth/strategies/realgeeks_spec.rb
143
+ - spec/spec_helper.rb