omniauth-strava-oauth2 0.0.2
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 +15 -0
- data/.gitignore +17 -0
- data/Gemfile +12 -0
- data/Guardfile +30 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/lib/omniauth-strava-oauth2.rb +2 -0
- data/lib/omniauth-strava-oauth2/version.rb +7 -0
- data/lib/omniauth/strategies/strava.rb +40 -0
- data/omniauth-strava-oauth2.gemspec +24 -0
- data/spec/omniauth/strategies/strava_spec.rb +36 -0
- data/spec/spec_helper.rb +15 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Y2Q3YTlkNGVmYTY5ZDU0NGIxYTk3NzMwMDE3MjgxOTAyYTY2YTNmMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTVjNTYxNWE5ZjE2ODhhZjM0MGIwZDJjMDRmNWEzNmFiYmQ1ZWI5OA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDE5NGQyZjczYWQ1MDc5YTU0Zjc4NWExM2ViYTdkZTcxMTc3NDg3MDI5NDA5
|
10
|
+
M2MwMDRmNDE0MzQ1MGVkOGVmYjJkMzU4OGVlOWY3ZGJmZWRkNjg5ZWNiNjhi
|
11
|
+
M2IzNjUwYjUzZTgxNGFkZjM0YjM3YzgxYzU0M2I0NDFkZWFkNWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDFhNDk3M2I0NDk0ZTJlNDNjMDVkZGQyNjRjNmIwZDU0YTFhYzM1ZjdmODg4
|
14
|
+
Zjg5ZjZlYTI5MWM0OGIzMjE2OGRhNWFjZWMxZDY5NzU4NmI1YmMyY2EzNDE5
|
15
|
+
MjMyMDcxMDNlMjAxYTY3ODllYjVjZGY4ZmUwMTNiODU3OWQwY2U=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :bundler do
|
5
|
+
watch('Gemfile')
|
6
|
+
# Uncomment next line if your Gemfile contains the `gemspec' command.
|
7
|
+
# watch(/^.+\.gemspec/)
|
8
|
+
end
|
9
|
+
|
10
|
+
guard :rspec do
|
11
|
+
watch(%r{^spec/.+_spec\.rb$})
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
+
watch('spec/spec_helper.rb') { "spec" }
|
14
|
+
|
15
|
+
# Rails example
|
16
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
17
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
18
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
19
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
20
|
+
watch('config/routes.rb') { "spec/routing" }
|
21
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
22
|
+
|
23
|
+
# Capybara features specs
|
24
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
25
|
+
|
26
|
+
# Turnip features and steps
|
27
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
28
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
29
|
+
end
|
30
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Leo Romanovsky
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# OmniAuth Strava
|
2
|
+
|
3
|
+
This is the official OmniAuth strategy for authenticating to GitHub. To
|
4
|
+
use it, you'll need to sign up for an OAuth2 Application ID and Secret
|
5
|
+
on the [Strava Applications Page](https://strava.com/developers).
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
use OmniAuth::Builder do
|
10
|
+
provider :strava, ENV['STRAVA_KEY'], ENV['STRAVA_SECRET']
|
11
|
+
end
|
12
|
+
|
13
|
+
## Scopes
|
14
|
+
|
15
|
+
Strava API v3 lets you set scopes to provide granular access to different types of data:
|
16
|
+
|
17
|
+
use OmniAuth::Builder do
|
18
|
+
provider :strava, ENV['STRAVA_KEY'], ENV['STRAVA_SECRET'], scope: "public"
|
19
|
+
end
|
20
|
+
|
21
|
+
## Auth Hash
|
22
|
+
|
23
|
+
Here is an example Auth Hash in `request.env['omniauth.auth']`
|
24
|
+
|
25
|
+
{
|
26
|
+
"provider" => "strava",
|
27
|
+
"uid" => 12345678,
|
28
|
+
"info" => {
|
29
|
+
"firstname" => "Strava",
|
30
|
+
},
|
31
|
+
"credentials" => {
|
32
|
+
"token" => "123-321",
|
33
|
+
"expires" => false
|
34
|
+
},
|
35
|
+
"extra" => {
|
36
|
+
"raw_info" => {
|
37
|
+
"id" => 12345678,
|
38
|
+
"firstname" => "Strava Athlete",
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
More info on [Scopes](http://strava.github.io/api/v3/oauth/).
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
Add license here.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Strava < OmniAuth::Strategies::OAuth2
|
6
|
+
option :client_options, {
|
7
|
+
site: 'https://www.strava.com',
|
8
|
+
authorize_url: '/oauth/authorize',
|
9
|
+
token_url: '/oauth/token'
|
10
|
+
}
|
11
|
+
|
12
|
+
option :access_token_options, {
|
13
|
+
header_format: 'Bearer %s',
|
14
|
+
param_name: 'access_token'
|
15
|
+
}
|
16
|
+
|
17
|
+
uid { raw_info['id'].to_s }
|
18
|
+
|
19
|
+
info do
|
20
|
+
{
|
21
|
+
email: raw_info['email'],
|
22
|
+
firstname: raw_info['firstname'],
|
23
|
+
lastname: raw_info['lastname']
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
credentials do
|
28
|
+
{ expires: false }
|
29
|
+
end
|
30
|
+
|
31
|
+
extra do
|
32
|
+
{ raw_info: raw_info }
|
33
|
+
end
|
34
|
+
|
35
|
+
def raw_info
|
36
|
+
@raw_info ||= access_token.get('/api/v3/athlete').parsed
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-strava-oauth2/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Leo Romanovsky']
|
6
|
+
gem.email = ['leo@strava.com']
|
7
|
+
gem.description = %q{Official OmniAuth strategy for Strava.}
|
8
|
+
gem.summary = %q{Official OmniAuth strategy for Strava.}
|
9
|
+
gem.homepage = 'https://github.com/strava/omniauth-strava-oauth2'
|
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 -- {spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'omniauth-strava-oauth2'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = OmniAuth::Strava::Oauth2::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
19
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
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
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Strava 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::Strava.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://www.strava.com")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize url' do
|
22
|
+
subject.options.client_options.authorize_url.should eq('/oauth/authorize')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have correct token url' do
|
26
|
+
subject.options.client_options.token_url.should eq('/oauth/token')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "#raw_info" do
|
31
|
+
it "should use relative paths" do
|
32
|
+
access_token.should_receive(:get).with('/api/v3/athlete').and_return(response)
|
33
|
+
subject.raw_info.should eq(parsed_response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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-strava-oauth2'
|
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,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-strava-oauth2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leo Romanovsky
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-12 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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
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: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
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
|
+
description: Official OmniAuth strategy for Strava.
|
98
|
+
email:
|
99
|
+
- leo@strava.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- Guardfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/omniauth-strava-oauth2.rb
|
111
|
+
- lib/omniauth-strava-oauth2/version.rb
|
112
|
+
- lib/omniauth/strategies/strava.rb
|
113
|
+
- omniauth-strava-oauth2.gemspec
|
114
|
+
- spec/omniauth/strategies/strava_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
homepage: https://github.com/strava/omniauth-strava-oauth2
|
117
|
+
licenses: []
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.0.5
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Official OmniAuth strategy for Strava.
|
139
|
+
test_files:
|
140
|
+
- spec/omniauth/strategies/strava_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
has_rdoc:
|