omniauth-lyft 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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +84 -0
- data/.travis.yml +18 -0
- data/Gemfile +16 -0
- data/README.md +52 -0
- data/Rakefile +17 -0
- data/lib/omniauth-lyft.rb +2 -0
- data/lib/omniauth/lyft/version.rb +5 -0
- data/lib/omniauth/strategies/lyft.rb +45 -0
- data/omniauth-lyft.gemspec +25 -0
- data/spec/app.rb +45 -0
- data/spec/omniauth/strategies/lyft_spec.rb +33 -0
- data/spec/spec_helper.rb +13 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cea8e5a986d40fab33e9279a5aa78d090b283f97
|
4
|
+
data.tar.gz: 0e4938fa1a491912fde8cfeabe1634e93b1065e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56dd1a379253228eee104dfc0dd6f305f5642230a540c4896b5843b91aac95486aca9029c709abfbe68deb95feaa992474a30ac4e8a1ecfca964a19a0333a521
|
7
|
+
data.tar.gz: 7827d53d48959a6a963eda604f9670af7439929166a96fb59764967951a8d2bb54208be1b8df5e9d89620135e02e9f424b4b7bb5388bb1ac41cbf3aa14bb658d
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,84 @@
|
|
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
|
81
|
+
|
82
|
+
Style/FileName:
|
83
|
+
Exclude:
|
84
|
+
- 'lib/omniauth-uber.rb'
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
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
|
9
|
+
- 2.1
|
10
|
+
- 2.2
|
11
|
+
- rbx-2
|
12
|
+
- ruby-head
|
13
|
+
- jruby-19mode
|
14
|
+
- jruby-head
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: jruby-head
|
18
|
+
- 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', '> 0.25'
|
7
|
+
end
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'coveralls', :require => false
|
11
|
+
gem 'rack-test'
|
12
|
+
gem 'rspec', '~> 3.1.0'
|
13
|
+
gem 'simplecov', :require => false
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
omniauth-uber
|
2
|
+
==============
|
3
|
+
|
4
|
+
Uber OAuth2 Strategy for OmniAuth 1.x and supports the OAuth 2.0 server-side flow.
|
5
|
+
|
6
|
+
You may view the Lyft API documentation [here](https://developer.lyft.com/docs/authentication).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add to your `Gemfile`:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'omniauth-lyft'
|
14
|
+
```
|
15
|
+
|
16
|
+
Then `bundle install`.
|
17
|
+
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
`OmniAuth::Strategies::Lyft` is simply Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
|
22
|
+
|
23
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
27
|
+
provider :lyft, ENV['LYFT_CLIENT_ID'], ENV['LYFT_CLIENT_SECRET']
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Configuration
|
32
|
+
|
33
|
+
Currently, there is only one configuration option that needs to be set:
|
34
|
+
|
35
|
+
* `scope`: A comma-separated list of permissions you want to request from the user. The available permissions are as follows: `public`, `rides.read`, `offline`, `rides.request`, `profile`, Default: `profile`
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
39
|
+
provider :lyft, ENV['LYFT_CLIENT_ID'], ENV['LYFT_CLIENT_SECRET'], :scope => 'profile,rides.read'
|
40
|
+
end
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
Copyright (c) 2017 by Chris Vannoy
|
47
|
+
|
48
|
+
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:
|
49
|
+
|
50
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
51
|
+
|
52
|
+
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,45 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Lyft < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = 'profile'
|
7
|
+
|
8
|
+
option :client_options, :site => 'https://api.lyft.com',
|
9
|
+
:authorize_url => 'https://api.lyft.com/oauth/authorize',
|
10
|
+
:token_url => 'https://api.lyft.com/oauth/token'
|
11
|
+
|
12
|
+
uid { raw_info['uuid'] }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{
|
16
|
+
:first_name => raw_info['first_name'],
|
17
|
+
:last_name => raw_info['last_name'],
|
18
|
+
:email => raw_info['email'],
|
19
|
+
:picture => raw_info['picture'],
|
20
|
+
:promo_code => raw_info['promo_code']
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{
|
26
|
+
:raw_info => raw_info
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def raw_info
|
31
|
+
@raw_info ||= access_token.get('/profile').parsed || {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def request_phase
|
35
|
+
options[:authorize_params] = {
|
36
|
+
:client_id => options['client_id'],
|
37
|
+
:response_type => 'code',
|
38
|
+
:scopes => (options['scope'] || DEFAULT_SCOPE)
|
39
|
+
}
|
40
|
+
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/lyft/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'omniauth-lyft'
|
7
|
+
s.version = OmniAuth::Lyft::VERSION
|
8
|
+
s.authors = ['Chris']
|
9
|
+
s.email = ['chris@chrisvannoy.com']
|
10
|
+
s.summary = 'Lyft strategy for OmniAuth'
|
11
|
+
s.description = 'Lyft strategy for OmniAuth v1.2'
|
12
|
+
s.homepage = 'https://github.com/dummied/omniauth-lyft'
|
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-lyft'
|
8
|
+
|
9
|
+
Dotenv.load
|
10
|
+
|
11
|
+
enable :sessions
|
12
|
+
|
13
|
+
use OmniAuth::Builder do
|
14
|
+
provider :lyft, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'] # , :scope => 'profile'
|
15
|
+
end
|
16
|
+
|
17
|
+
get '/' do
|
18
|
+
<<-HTML
|
19
|
+
<a href='/auth/lyft'>Sign in with Lyft</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 %(
|
31
|
+
>> UID
|
32
|
+
#{auth.uid.inspect}
|
33
|
+
|
34
|
+
>> CREDENTIALS
|
35
|
+
#{auth.credentials.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,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Lyft do
|
4
|
+
subject do
|
5
|
+
@subject ||= begin
|
6
|
+
@options ||= {}
|
7
|
+
args = ['client_id', 'client_secret', @options].compact
|
8
|
+
OmniAuth::Strategies::Lyft.new(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'client options' do
|
13
|
+
it 'should have correct name' do
|
14
|
+
expect(subject.options.name).to eq('lyft')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have correct site' do
|
18
|
+
expect(subject.options.client_options.site).to eq('https://api.lyft.com')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize url' do
|
22
|
+
expect(subject.options.client_options.authorize_url).to eq('https://api.lyft.com/oauth/authorize')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have correct access token url' do
|
26
|
+
expect(subject.options.client_options.token_url).to eq('https://api.lyft.com/oauth/token')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should indicate that the provider ignores the state parameted' do
|
30
|
+
expect(subject.options.provider_ignores_state).to eq false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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-lyft'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-lyft
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-13 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: Lyft strategy for OmniAuth v1.2
|
70
|
+
email:
|
71
|
+
- chris@chrisvannoy.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-lyft.rb
|
83
|
+
- lib/omniauth/lyft/version.rb
|
84
|
+
- lib/omniauth/strategies/lyft.rb
|
85
|
+
- omniauth-lyft.gemspec
|
86
|
+
- spec/app.rb
|
87
|
+
- spec/omniauth/strategies/lyft_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://github.com/dummied/omniauth-lyft
|
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.5.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Lyft strategy for OmniAuth
|
113
|
+
test_files:
|
114
|
+
- spec/app.rb
|
115
|
+
- spec/omniauth/strategies/lyft_spec.rb
|
116
|
+
- spec/spec_helper.rb
|