omniauth-dropbox 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sw[a-p]
4
+ *.tmproj
5
+ *.tmproject
6
+ *.un~
7
+ *~
8
+ .DS_Store
9
+ .Spotlight-V100
10
+ .Trashes
11
+ ._*
12
+ .bundle
13
+ .config
14
+ .directory
15
+ .elc
16
+ .emacs.desktop
17
+ .emacs.desktop.lock
18
+ .redcar
19
+ .yardoc
20
+ Desktop.ini
21
+ Gemfile.lock
22
+ Icon?
23
+ InstalledFiles
24
+ Session.vim
25
+ Thumbs.db
26
+ \#*\#
27
+ _yardoc
28
+ auto-save-list
29
+ coverage
30
+ doc
31
+ lib/bundler/man
32
+ pkg
33
+ pkg/*
34
+ rdoc
35
+ spec/reports
36
+ test/tmp
37
+ test/version_tmp
38
+ tmp
39
+ tmtags
40
+ tramp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
@@ -0,0 +1 @@
1
+ SimpleCov.start
@@ -0,0 +1,3 @@
1
+ --markup markdown
2
+ -
3
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Steve Agalloco
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ OmniAuth Dropbox
2
+ ================
3
+
4
+ This gem is an OmniAuth 1.0 Strategy for the [Dropbox API](https://www.dropbox.com/developers)
5
+
6
+ It supports version 1 of the Dropbox API which uses OAuth 1.0a.
7
+
8
+ Usage
9
+ -----
10
+
11
+ Add the strategy to your `Gemfile` alongside omniauth:
12
+
13
+ ```ruby
14
+ gem 'omniauth'
15
+ gem 'omniauth-dropbox'
16
+ ```
17
+
18
+ Then integrate the strategy into your middleware:
19
+
20
+ ```ruby
21
+ use OmniAuth::Builder do
22
+ provider :dropbox, ENV['DROPBOX_KEY'], ENV['DROPBOX_SECRET']
23
+ end
24
+ ```
25
+
26
+ You will have to put in your consumer key and secret (Dropbox refers to them as App Key and App Secret).
27
+
28
+ For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
29
+
30
+ Note on Patches/Pull Requests
31
+ -----------------------------
32
+
33
+ * Fork the project.
34
+ * Make your feature addition or bug fix.
35
+ * Add tests for it. This is important so I don't break it in a
36
+ future version unintentionally.
37
+ * Commit, do not mess with rakefile, version, or history.
38
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
39
+ * Send me a pull request. Bonus points for topic branches.
40
+
41
+ Copyright
42
+ ---------
43
+
44
+ Copyright (c) 2011 Steve Agalloco. See [LICENSE](https://github.com/spagalloco/omniauth-dropbox/blob/master/LICENSE.md) for details.
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
10
+ task :test => :spec
11
+
12
+ require 'yard'
13
+ namespace :doc do
14
+ YARD::Rake::YardocTask.new do |task|
15
+ task.files = ['LICENSE.md', 'lib/**/*.rb']
16
+ task.options = ['--markup', 'markdown']
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'omniauth-dropbox', :path => '../'
@@ -0,0 +1,27 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-dropbox'
4
+
5
+ class App < Sinatra::Base
6
+ get '/' do
7
+ redirect '/auth/dropbox'
8
+ end
9
+
10
+ get '/auth/:provider/callback' do
11
+ content_type 'application/json'
12
+ MultiJson.encode(request.env)
13
+ end
14
+
15
+ get '/auth/failure' do
16
+ content_type 'application/json'
17
+ MultiJson.encode(request.env)
18
+ end
19
+ end
20
+
21
+ use Rack::Session::Cookie
22
+
23
+ use OmniAuth::Builder do
24
+ provider :dropbox, ENV['APP_ID'], ENV['APP_SECRET']
25
+ end
26
+
27
+ run App.new
@@ -0,0 +1 @@
1
+ require 'omniauth/dropbox'
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/dropbox'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Dropbox
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ require 'omniauth-oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Dropbox < OmniAuth::Strategies::OAuth
6
+ option :client_options, {
7
+ :site => 'https://api.dropbox.com',
8
+ :authorize_url => 'https://www.dropbox.com/1/oauth/authorize',
9
+ :request_token_url => 'https://api.dropbox.com/1/oauth/request_token',
10
+ :access_token_url => 'https://api.dropbox.com/1/oauth/access_token'
11
+ }
12
+
13
+ uid { raw_info['uid'] }
14
+
15
+ info do
16
+ {
17
+ 'uid' => raw_info['uid'],
18
+ 'name' => raw_info['display_name'],
19
+ 'email' => raw_info['email']
20
+ }
21
+ end
22
+
23
+ extra do
24
+ { 'raw_info' => raw_info }
25
+ end
26
+
27
+ def raw_info
28
+ @raw_info ||= MultiJson.decode(access_token.get('/1/account/info').body)
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/omniauth/dropbox/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'omniauth-dropbox'
6
+ gem.version = OmniAuth::Dropbox::VERSION
7
+ gem.homepage = 'https://github.com/spagalloco/omniauth-dropbox'
8
+
9
+ gem.author = "Steve Agalloco"
10
+ gem.email = 'steve.agalloco@gmail.com'
11
+ gem.description = 'Dropbox strategy for OmniAuth 1.0'
12
+ gem.summary = gem.description
13
+
14
+ gem.add_dependency "omniauth-oauth", "~> 1.0"
15
+
16
+ gem.add_development_dependency 'rake', '~> 0.9'
17
+ gem.add_development_dependency 'rdiscount', '~> 1.6'
18
+ gem.add_development_dependency 'rspec', '~> 2.7'
19
+ gem.add_development_dependency 'simplecov', '~> 0.5'
20
+ gem.add_development_dependency 'yard', '~> 0.7'
21
+ gem.add_development_dependency 'webmock', '~> 1.7'
22
+
23
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
24
+ gem.files = `git ls-files`.split("\n")
25
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+
27
+ gem.require_paths = ['lib']
28
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'OmniAuth::Strategies::Dropbox Integration' do
4
+ pending 'write some tests yo'
5
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Dropbox do
4
+ before :each do
5
+ @request = double('Request')
6
+ @request.stub(:params) { {} }
7
+ end
8
+
9
+ subject do
10
+ OmniAuth::Strategies::Dropbox.new(nil, @options || {}).tap do |strategy|
11
+ strategy.stub(:request) { @request }
12
+ end
13
+ end
14
+
15
+ describe '#client_options' do
16
+ it 'has correct Dropbox site' do
17
+ subject.options.client_options.site.should eq('https://api.dropbox.com')
18
+ end
19
+
20
+ it 'has correct authorize url' do
21
+ subject.options.client_options.authorize_url.should eq('https://www.dropbox.com/1/oauth/authorize')
22
+ end
23
+
24
+ it 'has correct request token url' do
25
+ subject.options.client_options.request_token_url.should eq('https://api.dropbox.com/1/oauth/request_token')
26
+ end
27
+
28
+ it 'has correct access token url' do
29
+ subject.options.client_options.access_token_url.should eq('https://api.dropbox.com/1/oauth/access_token')
30
+ end
31
+ end
32
+
33
+ describe '#uid' do
34
+ it 'returns the uid from raw_info' do
35
+ subject.stub(:raw_info) { { 'uid' => '123' } }
36
+ subject.uid.should eq('123')
37
+ end
38
+ end
39
+
40
+ describe '#info' do
41
+ before :each do
42
+ @raw_info ||= { 'display_name' => 'Fred Smith' }
43
+ subject.stub(:raw_info) { @raw_info }
44
+ end
45
+
46
+ context 'when data is present in raw info' do
47
+ it 'returns the name' do
48
+ subject.info['name'].should eq('Fred Smith')
49
+ end
50
+
51
+ it 'returns the email' do
52
+ @raw_info['email'] = 'fred@smith.com'
53
+ subject.info['email'].should eq('fred@smith.com')
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#extra' do
59
+ before :each do
60
+ @raw_info_hash = { "referral_link" => "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7" }
61
+ subject.stub(:raw_info) { @raw_info_hash }
62
+ end
63
+
64
+ it 'returns a Hash' do
65
+ subject.extra.should be_a(Hash)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ require 'omniauth-dropbox'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-dropbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steve Agalloco
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &70263476206900 !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: *70263476206900
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70263476206400 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70263476206400
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdiscount
38
+ requirement: &70263476205940 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '1.6'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70263476205940
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70263476205480 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70263476205480
58
+ - !ruby/object:Gem::Dependency
59
+ name: simplecov
60
+ requirement: &70263476205020 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '0.5'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70263476205020
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: &70263476204560 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '0.7'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70263476204560
80
+ - !ruby/object:Gem::Dependency
81
+ name: webmock
82
+ requirement: &70263476204040 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '1.7'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70263476204040
91
+ description: Dropbox strategy for OmniAuth 1.0
92
+ email: steve.agalloco@gmail.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - .gemtest
98
+ - .gitignore
99
+ - .rspec
100
+ - .simplecov
101
+ - .yardopts
102
+ - Gemfile
103
+ - LICENSE.md
104
+ - README.md
105
+ - Rakefile
106
+ - example/Gemfile
107
+ - example/config.ru
108
+ - lib/omniauth-dropbox.rb
109
+ - lib/omniauth/dropbox.rb
110
+ - lib/omniauth/dropbox/version.rb
111
+ - lib/omniauth/strategies/dropbox.rb
112
+ - omniauth-dropbox.gemspec
113
+ - spec/integration_spec.rb
114
+ - spec/omniauth/strategies/dropbox_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/spagalloco/omniauth-dropbox
117
+ licenses: []
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 1.8.10
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: Dropbox strategy for OmniAuth 1.0
140
+ test_files:
141
+ - spec/integration_spec.rb
142
+ - spec/omniauth/strategies/dropbox_spec.rb
143
+ - spec/spec_helper.rb
144
+ has_rdoc: