omniauth-uber 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: 1918e142b87b2844936c6d834ba3f5b3e1cde00c
4
+ data.tar.gz: 05c551329fd715a1addc2bba9668807e090c9fc5
5
+ SHA512:
6
+ metadata.gz: b6915e7f77da9e27057fdcb356c20eaeaeafedd219dfa4c2ec7638ebbd5003269d81c39835b1fefd39e846bd03ff12c5f8345e98cbf1cab21de2406f4ea03277
7
+ data.tar.gz: 24a339780058b7a29e244d90f540486da4c1c6dbfa00dce87a337a58188bc1a6775186b5d09a055fc953aa722012a95e093ba23a90d2056936a6596e3bfca612
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
18
+ .env
19
+ .rspec
data/.rubocop.yml ADDED
@@ -0,0 +1,80 @@
1
+ AllCops:
2
+ Include:
3
+ - 'Gemfile'
4
+ - 'Rakefile'
5
+ - 'omniauth-venmo.gemspec'
6
+ Exclude:
7
+ - 'lib/omniauth-venmo.rb'
8
+
9
+ # Avoid long parameter lists
10
+ ParameterLists:
11
+ Max: 4
12
+ CountKeywordArgs: true
13
+
14
+ MethodLength:
15
+ CountComments: false
16
+ Max: 14
17
+
18
+ # Avoid more than `Max` levels of nesting.
19
+ BlockNesting:
20
+ Max: 2
21
+
22
+ # Align with the style guide.
23
+ CollectionMethods:
24
+ PreferredMethods:
25
+ map: 'collect'
26
+ reduce: 'inject'
27
+ find: 'detect'
28
+ find_all: 'select'
29
+
30
+ # Limit line length
31
+ LineLength:
32
+ Enabled: false
33
+
34
+ # Disable documentation checking until a class needs to be documented once
35
+ Documentation:
36
+ Enabled: false
37
+
38
+ # Enforce Ruby 1.8-compatible hash syntax
39
+ HashSyntax:
40
+ EnforcedStyle: hash_rockets
41
+
42
+ # No spaces inside hash literals
43
+ SpaceInsideHashLiteralBraces:
44
+ EnforcedStyle: no_space
45
+
46
+ # Allow dots at the end of lines
47
+ DotPosition:
48
+ Enabled: false
49
+
50
+ # Don't require magic comment at the top of every file
51
+ Encoding:
52
+ Enabled: false
53
+
54
+ # Enforce outdenting of access modifiers (i.e. public, private, protected)
55
+ AccessModifierIndentation:
56
+ EnforcedStyle: outdent
57
+
58
+ EmptyLinesAroundAccessModifier:
59
+ Enabled: true
60
+
61
+ # Align ends correctly
62
+ EndAlignment:
63
+ AlignWith: variable
64
+
65
+ # Indentation of when/else
66
+ CaseIndentation:
67
+ IndentWhenRelativeTo: end
68
+ IndentOneStep: false
69
+
70
+ Lambda:
71
+ Enabled: false
72
+
73
+ HandleExceptions:
74
+ Enabled: false
75
+
76
+ RaiseArgs:
77
+ EnforcedStyle: compact
78
+
79
+ TrailingComma:
80
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ bundler_args: --without development
2
+ gemfile:
3
+ - Gemfile
4
+ language: ruby
5
+ rvm:
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - 2.1.0
10
+ - rbx-2
11
+ - ruby-head
12
+ - jruby-19mode
13
+ - jruby-head
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: jruby-head
17
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ group :development do
6
+ gem 'rubocop'
7
+ end
8
+
9
+ group :test do
10
+ gem 'coveralls', :require => false
11
+ gem 'rack-test'
12
+ gem 'rspec', '~> 2.7'
13
+ gem 'simplecov', :require => false
14
+ end
15
+
16
+ gemspec
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ omniauth-uber
2
+ ==============
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/omniauth-uber.png)](http://badge.fury.io/rb/omniauth-uber)
5
+ [![Build Status](https://travis-ci.org/tmilewski/omniauth-uber.png?branch=master)](https://travis-ci.org/tmilewski/omniauth-uber)
6
+
7
+ Uber OAuth2 Strategy for OmniAuth 1.x and supports the OAuth 2.0 server-side flow.
8
+
9
+ You may view the Uber API documentation [here](https://developer.uber.com/v1/auth/#oauth-2-0).
10
+
11
+ ## Installation
12
+
13
+ Add to your `Gemfile`:
14
+
15
+ ```ruby
16
+ gem 'omniauth-uber'
17
+ ```
18
+
19
+ Then `bundle install`.
20
+
21
+
22
+ ## Usage
23
+
24
+ `OmniAuth::Strategies::Uber` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
25
+
26
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
27
+
28
+ ```ruby
29
+ Rails.application.config.middleware.use OmniAuth::Builder do
30
+ provider :uber, ENV['UBER_CLIENT_ID'], ENV['UBER_CLIENT_SECRET']
31
+ end
32
+ ```
33
+
34
+ ## Configuration
35
+
36
+ Currently, there is only one configuration option that needs to be set:
37
+
38
+ * `scope`: A comma-separated list of permissions you want to request from the user. The available permissions are as follows: `access_email`, `access_phone`, `access_balance`, `access_feed`, `access_profile`, `access_friends`, and `make_payments`. Default: `access_profile`
39
+
40
+ ```ruby
41
+ Rails.application.config.middleware.use OmniAuth::Builder do
42
+ provider :uber, ENV['UBER_CLIENT_ID'], ENV['UBER_CLIENT_SECRET'], :scope => 'profile,history'
43
+ end
44
+ ```
45
+
46
+ ## Auth Hash
47
+
48
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
49
+
50
+ ```ruby
51
+ {
52
+ :provider => 'uber',
53
+ :uid => nil,
54
+ :info => {}, # Being worked on
55
+ :credentials => {
56
+ :token => 'ABCDEF...',
57
+ :expires => true
58
+ },
59
+ :extra => {} # Being worked on
60
+ }
61
+ }
62
+ ```
63
+
64
+ ## Supported Ruby Versions
65
+ `omniauth-uber` is tested under 1.8.7, 1.9.2, 1.9.3, 2.0.0, JRuby (1.8 mode), and Rubinius
66
+ (1.8 and 1.9 modes).
67
+
68
+ ## Versioning
69
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
70
+ of this scheme should be reported as bugs. Specifically, if a minor or patch
71
+ version is released that breaks backward compatibility, that version should be
72
+ immediately yanked and/or a new version should be immediately released that
73
+ restores compatibility. Breaking changes to the public API will only be
74
+ introduced with new major versions. As a result of this policy, you can (and
75
+ should) specify a dependency on this gem using the [Pessimistic Version
76
+ Constraint][pvc] with two digits of precision. For example:
77
+
78
+ spec.add_dependency 'omniauth-uber', '~> 1.0'
79
+
80
+ [semver]: http://semver.org/
81
+ [pvc]: http://docs.rubygems.org/read/chapter/16#page74
82
+
83
+
84
+ ## License
85
+
86
+ Copyright (c) 2013 by Tom Milewski
87
+
88
+ 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:
89
+
90
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
91
+
92
+ 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,17 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :test => :spec
7
+
8
+ begin
9
+ require 'rubocop/rake_task'
10
+ RuboCop::RakeTask.new
11
+ rescue LoadError
12
+ task :rubocop do
13
+ $stderr.puts 'Rubocop is disabled'
14
+ end
15
+ end
16
+
17
+ task :default => [:spec, :rubocop]
@@ -0,0 +1,2 @@
1
+ require 'omniauth/uber/version'
2
+ require 'omniauth/strategies/uber'
@@ -0,0 +1,39 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Uber < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = 'profile'
7
+
8
+ option :client_options, :site => 'https://login.uber.com',
9
+ :authorize_url => '/oauth/authorize',
10
+ :token_url => '/oauth/token'
11
+
12
+ uid { nil }
13
+
14
+ info do
15
+ # Not implemented yet
16
+ {}
17
+ end
18
+
19
+ extra do
20
+ # Not implemented yet
21
+ {}
22
+ end
23
+
24
+ def raw_info
25
+ @raw_info ||= access_token.params['user'] || {}
26
+ end
27
+
28
+ def request_phase
29
+ options[:authorize_params] = {
30
+ :client_id => options['client_id'],
31
+ :response_type => 'code',
32
+ :scopes => (options['scope'] || DEFAULT_SCOPE)
33
+ }
34
+
35
+ super
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Uber
3
+ VERSION = '0.5.0'
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/uber/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'omniauth-uber'
7
+ s.version = OmniAuth::Uber::VERSION
8
+ s.authors = ['Tom Milewski']
9
+ s.email = ['tmilewski@gmail.com']
10
+ s.summary = 'Uber strategy for OmniAuth'
11
+ s.description = 'Uber strategy for OmniAuth v1.2'
12
+ s.homepage = 'https://github.com/tmilewski/omniauth-uber'
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_runtime_dependency 'omniauth', '~> 1.2'
21
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
22
+
23
+ s.add_development_dependency 'dotenv', '~> 0'
24
+ s.add_development_dependency 'sinatra', '~> 0'
25
+ end
data/spec/app.rb ADDED
@@ -0,0 +1,45 @@
1
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'dotenv'
5
+ require 'sinatra'
6
+ require 'omniauth'
7
+ require 'omniauth-uber'
8
+
9
+ Dotenv.load
10
+
11
+ enable :sessions
12
+
13
+ use OmniAuth::Builder do
14
+ provider :uber, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'] # , :scope => 'profile'
15
+ end
16
+
17
+ get '/' do
18
+ <<-HTML
19
+ <a href='/auth/uber'>Sign in with Uber</a>
20
+ HTML
21
+ end
22
+
23
+ get '/auth/failure' do
24
+ env['omniauth.error'].to_s
25
+ end
26
+
27
+ get '/auth/:name/callback' do
28
+ auth = request.env['omniauth.auth']
29
+
30
+ puts %Q(
31
+ >> UID
32
+ #{auth.uid.inspect}
33
+
34
+ >> ACCESS TOKEN
35
+ #{auth.credentials.token.inspect}
36
+
37
+ >> INFO
38
+ #{auth.info.inspect}
39
+ #
40
+ >> EXTRA
41
+ #{auth.extra.inspect}
42
+ )
43
+
44
+ 'Check logs for user information.'
45
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Uber do
4
+ subject do
5
+ @subject ||= begin
6
+ args = ['client_id', 'client_secret', @options || {}].compact
7
+ OmniAuth::Strategies::Uber.new(*args)
8
+ end
9
+ end
10
+
11
+ context 'client options' do
12
+ it 'should have correct name' do
13
+ expect(subject.options.name).to eq('uber')
14
+ end
15
+
16
+ it 'should have correct site' do
17
+ expect(subject.options.client_options.site).to eq('https://login.uber.com')
18
+ end
19
+
20
+ it 'should have correct authorize url' do
21
+ expect(subject.options.client_options.authorize_url).to eq('/oauth/authorize')
22
+ end
23
+
24
+ it 'should have correct access token url' do
25
+ expect(subject.options.client_options.token_url).to eq('/oauth/token')
26
+ end
27
+
28
+ it 'should indicate that the provider ignores the state parameted' do
29
+ expect(subject.options.provider_ignores_state).to eq false
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+ require 'simplecov'
6
+ SimpleCov.start
7
+
8
+ require 'omniauth'
9
+ require 'omniauth-uber'
10
+
11
+ RSpec.configure do |config|
12
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
13
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-uber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Milewski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-20 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
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: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra
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
+ description: Uber strategy for OmniAuth v1.2
70
+ email:
71
+ - tmilewski@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rubocop.yml"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - README.md
81
+ - Rakefile
82
+ - lib/omniauth-uber.rb
83
+ - lib/omniauth/strategies/uber.rb
84
+ - lib/omniauth/uber/version.rb
85
+ - omniauth-uber.gemspec
86
+ - spec/app.rb
87
+ - spec/omniauth/strategies/uber_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/tmilewski/omniauth-uber
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Uber strategy for OmniAuth
113
+ test_files:
114
+ - spec/app.rb
115
+ - spec/omniauth/strategies/uber_spec.rb
116
+ - spec/spec_helper.rb
117
+ has_rdoc: