omniauth-bitcasa 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: 8a7a42de0436077534c7776dc02e86a74a2c5d55
4
+ data.tar.gz: 75bce63fb6bf129d7f1ea2d064f4f43b0b0f526f
5
+ SHA512:
6
+ metadata.gz: 76878670927d8e878ce93d652f6825c9cc2a74ebee9b34eca67b9ae3e2c74c54657edb4a5ffb6c4d86f2754956b1d4fe3dc2b5852635ab5ca61029c188506751
7
+ data.tar.gz: d6f9c96ae6e46b0c536e6aaa350ab54209fc518f1cab4b75ef155be6114ab782e77afa083c95618e93e1ebccf286fbe94a3b050ebc22ddb977a2e0e0a9215602
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
+ --color
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-bitcasa.gemspec')
10
+ end
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Omniauth::Bitcasa
2
+
3
+ Unofficial OmniAuth Strategy for the Bitcasa OAuth2 API. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Bitcasa Developers Page](https://developer.bitcasa.com).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-bitcasa'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-bitcasa
20
+
21
+ ## Usage
22
+
23
+ ### With Sinatra
24
+
25
+ ```ruby
26
+ use OmniAuth::Builder do
27
+ provider :bitcasa, ENV['BITCASA_KEY'], ENV['BITCASA_SECRET']
28
+ end
29
+ ```
30
+
31
+ ### With Rails
32
+
33
+ ```ruby
34
+ Rails.application.config.middleware.use OmniAuth::Builder do
35
+ provider :bitcasa, ENV['BITCASA_KEY'], ENV['BITCASA_SECRET']
36
+ end
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
46
+
47
+ ## License
48
+
49
+ The MIT License (MIT)
50
+
51
+ Copyright (c) 2013 Guilherme Vinicius Moreira
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining a copy
54
+ of this software and associated documentation files (the "Software"), to deal
55
+ in the Software without restriction, including without limitation the rights
56
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57
+ copies of the Software, and to permit persons to whom the Software is
58
+ furnished to do so, subject to the following conditions:
59
+
60
+ The above copyright notice and this permission notice shall be included in all
61
+ copies or substantial portions of the Software.
62
+
63
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
69
+ 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-bitcasa/version"
2
+ require 'omniauth/strategies/bitcasa'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Bitcasa
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Bitcasa < OmniAuth::Strategies::OAuth2
6
+ option :name, "bitcasa"
7
+
8
+ API_VERSION = "v1"
9
+
10
+ option :client_options, {
11
+ :site => 'https://developer.api.bitcasa.com',
12
+ :authorize_url => "/#{API_VERSION}/oauth2/authenticate",
13
+ :token_url => "/#{API_VERSION}/oauth2/access_token",
14
+ :token_method => :get
15
+ }
16
+
17
+ uid { nil }
18
+
19
+ extra do
20
+ {:raw_info => raw_info}
21
+ end
22
+
23
+ def raw_info
24
+ access_token.options[:mode] = :query
25
+ @raw_info ||= access_token.get('result').parsed
26
+ end
27
+
28
+ # Bitcasa uses 'redirect' instead of 'redirect_uri'
29
+ def request_phase
30
+ redirect client.auth_code.authorize_url({:redirect => callback_url}.merge(authorize_params))
31
+ end
32
+
33
+ def callback_phase
34
+ self.access_token = custom_build_access_token
35
+ self.access_token = access_token.refresh! if access_token.expired?
36
+ end
37
+
38
+ # Bitcasa return a parameter called 'authorization_code' insted of 'code'
39
+ def custom_build_access_token
40
+ verifier = request.params['authorization_code']
41
+ client.auth_code.get_token(verifier, { :secret => options.client_secret })
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+
48
+ OmniAuth.config.add_camelization 'bitcasa', 'Bitcasa'
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/omniauth-bitcasa/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Guilherme Vinicius Moreira"]
6
+ gem.email = ["gui.vinicius@gmail.com"]
7
+ gem.description = %q{Unofficial OmniAuth strategy for Bitcasa.}
8
+ gem.summary = %q{Unofficial OmniAuth strategy for Bitcasa.}
9
+ gem.homepage = "https://github.com/guivinicius/omniauth-bitcasa"
10
+ gem.license = "MIT"
11
+
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ gem.require_paths = ["lib"]
16
+ gem.name = "omniauth-bitcasa"
17
+ gem.version = OmniAuth::Bitcasa::VERSION
18
+
19
+ gem.add_dependency 'omniauth', '~> 1.0'
20
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
21
+
22
+ gem.add_development_dependency "bundler", "~> 1.3"
23
+ gem.add_development_dependency "rake"
24
+ gem.add_development_dependency 'rspec', '~> 2.7'
25
+ gem.add_development_dependency 'rack-test'
26
+ gem.add_development_dependency 'simplecov'
27
+ gem.add_development_dependency 'webmock'
28
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Bitcasa do
4
+ let(:access_token) { stub('AccessToken', :options => {}) }
5
+ let(:parsed_response) { stub('ParsedResponse') }
6
+ let(:response) { stub('Response', :parsed => parsed_response) }
7
+
8
+ subject do
9
+ OmniAuth::Strategies::Bitcasa.new({})
10
+ end
11
+
12
+ before(:each) do
13
+ subject.stub!(:access_token).and_return(access_token)
14
+ end
15
+
16
+ context "client options" do
17
+ it 'should have correct site' do
18
+ subject.options.client_options.site.should eq("https://developer.api.bitcasa.com")
19
+ end
20
+
21
+ it 'should have correct authorize url' do
22
+ subject.options.client_options.authorize_url.should eq('/v1/oauth2/authenticate')
23
+ end
24
+
25
+ it 'should have correct token url' do
26
+ subject.options.client_options.token_url.should eq('/v1/oauth2/access_token')
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,15 @@
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-bitcasa'
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
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bitcasa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Guilherme Vinicius Moreira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
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: simplecov
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
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Unofficial OmniAuth strategy for Bitcasa.
126
+ email:
127
+ - gui.vinicius@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - .rspec
134
+ - Gemfile
135
+ - Guardfile
136
+ - README.md
137
+ - Rakefile
138
+ - lib/omniauth-bitcasa.rb
139
+ - lib/omniauth-bitcasa/version.rb
140
+ - lib/omniauth/strategies/bitcasa.rb
141
+ - omniauth-bitcasa.gemspec
142
+ - spec/omniauth/strategies/bitcasa_spec.rb
143
+ - spec/spec_helper.rb
144
+ homepage: https://github.com/guivinicius/omniauth-bitcasa
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.1.11
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Unofficial OmniAuth strategy for Bitcasa.
168
+ test_files:
169
+ - spec/omniauth/strategies/bitcasa_spec.rb
170
+ - spec/spec_helper.rb