omniauth-revrise 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: 4bde47804f2525cc0c4f3537f84e72af20ea8963
4
+ data.tar.gz: 7d93a5e4e77042d78ad4ebb65157ec7a33c57e45
5
+ SHA512:
6
+ metadata.gz: a6752ef42ac4b942569bcae16ffcb683bebb12ed4250cbec4f4fb9879bfbe9a3d761371a3647e3203647223fb174eb95511a1ea8bd8e36e0cf8925b4640e9581
7
+ data.tar.gz: 62e570e774caa172079eb2814a0c1f7a394af2e3d40a98adf1402a86377fb8a2c9ee6d5ca99a9d8337adb87ddcb8480ffddc2bf6ec1ec19b0feae1f215a5c7f9
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-revrise.gemspec
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # OmniAuth RevRise
2
+
3
+ This gem contains the RevRise strategy for OmniAuth.
4
+
5
+ ## Using This Strategy
6
+
7
+ First start by adding this gem to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-revrise'
11
+ ```
12
+
13
+ If you need to use the latest HEAD version, you can do so with:
14
+
15
+ ```ruby
16
+ gem 'omniauth-revrise', :github => 'arnklint/omniauth-revrise'
17
+ ```
18
+
19
+ Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
20
+
21
+ ```ruby
22
+ Rails.application.config.middleware.use OmniAuth::Builder do
23
+ provider :revrise, "CONSUMER_KEY", "CONSUMER_SECRET"
24
+ end
25
+ ```
26
+
27
+ ## License
28
+
29
+ Copyright (c) 2014 Jonas Arnklint
30
+
31
+ 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:
32
+
33
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
34
+
35
+ 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
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
File without changes
@@ -0,0 +1,2 @@
1
+ require "omniauth-revrise/version"
2
+ require 'omniauth/strategies/revrise'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Revrise
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ require "omniauth-oauth2"
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Revrise < OmniAuth::Strategies::OAuth2
7
+ option :name, 'revrise'
8
+
9
+ option :client_options, {
10
+ site: "https://www2.revrise.com",
11
+ authorize_url: "/oauth/authorize"
12
+ }
13
+
14
+ uid { raw_info["id"] }
15
+
16
+ info do
17
+ {
18
+ :description => raw_info['email'],
19
+ :name => raw_info['full_name']
20
+ }
21
+ end
22
+
23
+ extra do
24
+ { :raw_info => raw_info }
25
+ end
26
+
27
+ def raw_info
28
+ @raw_info ||= MultiJson.load(access_token.get('https://api2.revrise.com/v1/core/users/me').body)
29
+ rescue ::Errno::ETIMEDOUT
30
+ raise ::Timeout::Error
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "omniauth-revrise/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "omniauth-revrise"
6
+ s.version = OmniAuth::Revrise::VERSION
7
+ s.authors = ["Jonas Arnklint"]
8
+ s.email = ["jonas.arnklint@revrise.com"]
9
+ s.homepage = "https://github.com/arnklint/omniauth-revrise"
10
+ s.summary = %q{OmniAuth strategy for RevRise}
11
+ s.description = %q{Easy peasy authentication for the RevRise hub using Ruby.}
12
+ s.license = "MIT"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency 'multi_json', '~> 1.3'
20
+ s.add_dependency 'omniauth', '~> 1.0'
21
+ s.add_dependency 'omniauth-oauth2', '~> 1.1.2'
22
+
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Revrise do
4
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
5
+
6
+ subject do
7
+ args = ['appid', 'secret', @options || {}].compact
8
+ OmniAuth::Strategies::Revrise.new(*args).tap do |strategy|
9
+ strategy.stub(:request) {
10
+ request
11
+ }
12
+ end
13
+ end
14
+
15
+ describe 'client options' do
16
+ it 'should have correct name' do
17
+ expect(subject.options.name).to eq('revrise')
18
+ end
19
+
20
+ it 'should have correct site' do
21
+ expect(subject.options.client_options.site).to eq('https://api2.revrise.com')
22
+ end
23
+
24
+ it 'should have correct authorize url' do
25
+ expect(subject.options.client_options.authorize_path).to eq('/oauth/authenticate')
26
+ end
27
+ end
28
+
29
+ describe 'request_phase' do
30
+ context 'with no request params set and x_auth_access_type specified' do
31
+ before do
32
+ subject.stub(:request).and_return(
33
+ double('Request', {:params => {'x_auth_access_type' => 'read'}})
34
+ )
35
+ subject.stub(:old_request_phase).and_return(:whatever)
36
+ end
37
+
38
+ it 'should not break' do
39
+ expect { subject.request_phase }.not_to raise_error
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,18 @@
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-revrise'
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
+ config.expect_with :rspec do |c|
16
+ c.syntax = :expect
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-revrise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonas Arnklint
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: multi_json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: omniauth-oauth2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
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: simplecov
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: webmock
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: Easy peasy authentication for the RevRise hub using Ruby.
112
+ email:
113
+ - jonas.arnklint@revrise.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - coverage/.resultset.json
124
+ - lib/omniauth-revrise.rb
125
+ - lib/omniauth-revrise/version.rb
126
+ - lib/omniauth/strategies/revrise.rb
127
+ - omniauth-revrise.gemspec
128
+ - spec/omniauth/strategies/revrise_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/arnklint/omniauth-revrise
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.0.6
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: OmniAuth strategy for RevRise
154
+ test_files:
155
+ - spec/omniauth/strategies/revrise_spec.rb
156
+ - spec/spec_helper.rb