omniauth-imagerelay 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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
3
+
4
+
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # OmniAuth Image Relay
2
+
3
+ This gem contains the official Image Relay, [http://imagerelay.com](http://imagerelay.com), strategy for OmniAuth.
4
+
5
+ Image Relay API documentation can be found at [https://github.com/imagerelay/API](http://github.com/imagerelay/API).
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider "imagerelay", ENV['IMAGERELAY_CLIENT_ID'], ENV['IMAGERELAY_SECRET']
11
+ end
12
+
13
+ ## Supported Flows
14
+
15
+ Supports the server flow as described in the draft spec at [http://tools.ietf.org/html/draft-ietf-oauth-v2-10](http://tools.ietf.org/html/draft-ietf-oauth-v2-10).
16
+
17
+ ## Ruby
18
+
19
+ Tested with the following Ruby versions:
20
+
21
+ - MRI 1.9.3
22
+
23
+ ## License
24
+
25
+ Copyright (c) 2013 by Image Relay, LLC.
26
+
27
+ 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:
28
+
29
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
30
+
31
+ 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.
32
+
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 do |t|
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-imagerelay/version"
2
+ require "omniauth/strategies/imagerelay"
@@ -0,0 +1,6 @@
1
+ module OmniAuth
2
+ module ImageRelay
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
6
+
@@ -0,0 +1,37 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class ImageRelay < OmniAuth::Strategies::OAuth2
6
+
7
+ option :name, 'imagerelay'
8
+
9
+ option :client_options, {
10
+ :site => 'https://launch.imagerelay.com',
11
+ :authorize_url => '/oauth/authorize',
12
+ :token_url => '/oauth/token'
13
+ }
14
+
15
+ uid { raw_info.parsed['id'] }
16
+
17
+ info do
18
+ {
19
+ 'id' => raw_info.parsed['id'],
20
+ 'email' => raw_info.parsed['email'],
21
+ 'first_name' => raw_info.parsed['first_name'],
22
+ 'last_name' => raw_info.parsed['last_name'],
23
+ 'name' => [raw_info.parsed['first_name'], raw_info.parsed['last_name']].join(' ').strip
24
+ }
25
+ end
26
+
27
+ def raw_info
28
+ return @raw_info if @raw_info
29
+ (access_token.options || {}).merge!({:header_format => 'OAuth %s', :parse => :json})
30
+ @raw_info = access_token.get('/api/v2/users/me.json')
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
37
+ OmniAuth.config.add_camelization 'imagerelay', 'ImageRelay'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-imagerelay/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Buffy Miller"]
6
+ gem.email = ["buffy@imagerelay.com"]
7
+ gem.description = %q{OmniAuth strategy for Image Relay.}
8
+ gem.summary = %q{OmniAuth strategy for Image Relay.}
9
+ gem.homepage = "https://github.com/imagerelay/omniauth-imagerelay"
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-imagerelay"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::ImageRelay::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
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
25
+
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-imagerelay'
3
+
4
+ describe OmniAuth::Strategies::ImageRelay do
5
+ subject do
6
+ strategy = OmniAuth::Strategies::ImageRelay.new(nil, @options || {})
7
+ strategy.stub(:session) { {} }
8
+ strategy
9
+ end
10
+
11
+ it_should_behave_like 'an oauth2 strategy'
12
+
13
+ describe '#client' do
14
+ it 'should have the correct imagerelay site' do
15
+ subject.client.site.should eq('https://launch.imagerelay.com')
16
+ end
17
+
18
+ it 'should have the correct authorization url' do
19
+ subject.client.options[:authorize_url].should eq('/oauth/authorize')
20
+ end
21
+
22
+ it 'should have the correct token url' do
23
+ subject.client.options[:token_url].should eq('/oauth/token')
24
+ end
25
+ end
26
+
27
+ describe '#callback_path' do
28
+ it 'should have the correct callback path' do
29
+ subject.callback_path.should eq('/auth/imagerelay/callback')
30
+ end
31
+ end
32
+ 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 'omniauth'
8
+ require 'omniauth-imagerelay'
9
+
10
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
16
+
@@ -0,0 +1,42 @@
1
+ # Taken from the omniauth-37signals strategy -Buffy
2
+
3
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
4
+ # Thanks to Josh Ellithorpe for this file -Will
5
+
6
+ shared_examples 'an oauth2 strategy' do
7
+ describe '#client' do
8
+ it 'should be initialized with symbolized client_options' do
9
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
10
+ subject.client.options[:authorize_url].should == 'https://example.com'
11
+ end
12
+ end
13
+
14
+ describe '#authorize_params' do
15
+ it 'should include any authorize params passed in the :authorize_params option' do
16
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
17
+ subject.authorize_params['foo'].should eq('bar')
18
+ subject.authorize_params['baz'].should eq('zip')
19
+ end
20
+
21
+ it 'should include top-level options that are marked as :authorize_options' do
22
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
23
+ subject.authorize_params['scope'].should eq('bar')
24
+ subject.authorize_params['foo'].should eq('baz')
25
+ end
26
+ end
27
+
28
+ describe '#token_params' do
29
+ it 'should include any token params passed in the :token_params option' do
30
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
31
+ subject.token_params['foo'].should eq('bar')
32
+ subject.token_params['baz'].should eq('zip')
33
+ end
34
+
35
+ it 'should include top-level options that are marked as :token_options' do
36
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
37
+ subject.token_params['scope'].should eq('bar')
38
+ subject.token_params['foo'].should eq('baz')
39
+ end
40
+ end
41
+ end
42
+
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-imagerelay
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Buffy Miller
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth2
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: OmniAuth strategy for Image Relay.
111
+ email:
112
+ - buffy@imagerelay.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - Gemfile
118
+ - README.md
119
+ - Rakefile
120
+ - lib/omniauth-imagerelay.rb
121
+ - lib/omniauth-imagerelay/version.rb
122
+ - lib/omniauth/strategies/imagerelay.rb
123
+ - omniauth-imagerelay.gemspec
124
+ - spec/omniauth/strategies/imagerelay_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/support/shared_examples.rb
127
+ homepage: https://github.com/imagerelay/omniauth-imagerelay
128
+ licenses: []
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 1.8.24
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: OmniAuth strategy for Image Relay.
151
+ test_files:
152
+ - spec/omniauth/strategies/imagerelay_spec.rb
153
+ - spec/spec_helper.rb
154
+ - spec/support/shared_examples.rb