omniauth-teamsnap 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +5 -0
- data/LICENSE +22 -0
- data/README.md +20 -0
- data/Rakefile +8 -0
- data/lib/omniauth/strategies/teamsnap.rb +45 -0
- data/lib/omniauth-teamsnap/version.rb +5 -0
- data/lib/omniauth-teamsnap.rb +2 -0
- data/omniauth-teamsnap.gemspec +28 -0
- data/spec/omniauth/strategies/teamsnap_spec.rb +19 -0
- data/spec/spec_helper.rb +18 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83fbc211023278b4432be966d30137e5ee689a85
|
4
|
+
data.tar.gz: ab9dbbe8ef3649b70bfc5ef0b29890215bb8b085
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ad5c18eb61a4ba8c5735546057f34e98ca163ca3ccaa80070b76deac33d9cc6c7461ce4223283606f35d788cbc744a8491df17b0f3a9cfae7e14920453d96e5f
|
7
|
+
data.tar.gz: 88a5f6c24383b86b0d9cf61c9444e65f402f48ed675adb32443e00f77398243405e91e30f6475162a02758da33a1d0060b729cb35abbaec05f618d736065f327
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TeamSnap
|
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,20 @@
|
|
1
|
+
# OmniAuth TeamSnap
|
2
|
+
|
3
|
+
This is the official OmniAuth strategy for authenticating to TeamSnap. To
|
4
|
+
use it, you'll need to sign up for an OAuth2 Application Id and Secret
|
5
|
+
on [Cogsworth](https://auth.teamsnap.com).
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
use OmniAuth::Builder do
|
10
|
+
provider :teamsnap, ENV['TEAMSNAP_KEY'], ENV['TEAMSNAP_SECRET']
|
11
|
+
end
|
12
|
+
|
13
|
+
## Scopes
|
14
|
+
|
15
|
+
TeamSnap API v3 lets you set scopes to provide granular access to different types of data:
|
16
|
+
|
17
|
+
use OmniAuth::Builder do
|
18
|
+
provider :teamsnap, ENV['TEAMSNAP_KEY'], ENV['TEAMSNAP_SECRET'], scope: "read write"
|
19
|
+
end
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "omniauth-oauth2"
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class TeamSnap < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, :teamsnap
|
7
|
+
option :authorize_options, [:scope]
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => "https://auth.teamsnap.com",
|
11
|
+
:authorize_url => "/oauth/authorize",
|
12
|
+
:token_method => :post
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { raw_info.find { |d| d.name == "id"}.value }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
:email => raw_info.find { |d| d.name == "email"}.value,
|
20
|
+
:first_name => raw_info.find { |d| d.name == "first_name"}.value,
|
21
|
+
:last_name => raw_info.find { |d| d.name == "last_name"}.value
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def raw_info
|
26
|
+
return @raw_info if @raw_info
|
27
|
+
|
28
|
+
# TeamSnap /me endpoint is not compatible with standard oauth2
|
29
|
+
# access_token.get(url).parsed calls because oauth2 doesn't parse
|
30
|
+
# responses with Content-Type: application/vnd.collection+json
|
31
|
+
response = client.connection.get do |req|
|
32
|
+
req.url "https://api.teamsnap.com/v3/me"
|
33
|
+
req.headers["Authorization"] = "Bearer #{access_token.token}"
|
34
|
+
end
|
35
|
+
deserializer = Conglomerate::TreeDeserializer.new(JSON.parse(response.body))
|
36
|
+
collection_json = deserializer.deserialize
|
37
|
+
|
38
|
+
@raw_info = collection_json.items.first.data
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
OmniAuth.config.add_camelization 'teamsnap', 'TeamSnap'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-teamsnap/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "omniauth-teamsnap"
|
7
|
+
spec.version = OmniAuth::Teamsnap::VERSION
|
8
|
+
spec.description = %q{Official OmniAuth strategy for TeamSnap}
|
9
|
+
spec.summary = %q{Official OmniAuth strategy for TeamSnap}
|
10
|
+
spec.authors = ["Ryan Williams"]
|
11
|
+
spec.email = ["dev@teamsnap.com"]
|
12
|
+
spec.homepage = "https://github.com/teamsnap/omniauth-teamsnap"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
spec.files = `git ls-files`.split("\n")
|
17
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "omniauth", "~> 1.2"
|
21
|
+
spec.add_dependency "omniauth-oauth2", "~> 1.2"
|
22
|
+
spec.add_dependency "faraday", "~> 0.9"
|
23
|
+
spec.add_dependency "conglomerate", "~> 0.15"
|
24
|
+
spec.add_development_dependency "rspec", "~> 2.7"
|
25
|
+
spec.add_development_dependency "rack-test"
|
26
|
+
spec.add_development_dependency "simplecov"
|
27
|
+
spec.add_development_dependency "webmock"
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "omniauth-teamsnap"
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::TeamSnap do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::TeamSnap.new(nil, @options || {}).tap do |strategy|
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#client" do
|
11
|
+
it "should have the correct TeamSnap site" do
|
12
|
+
expect(subject.client.site).to eq("https://auth.teamsnap.com")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have the correct authorization url" do
|
16
|
+
expect(subject.client.options[:authorize_url]).to eq("/oauth/authorize")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
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-teamsnap'
|
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
|
+
config.expect_with :rspec do |c|
|
16
|
+
c.syntax = :expect
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-teamsnap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-01 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.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: conglomerate
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.15'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.15'
|
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: Official OmniAuth strategy for TeamSnap
|
126
|
+
email:
|
127
|
+
- dev@teamsnap.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- lib/omniauth-teamsnap.rb
|
139
|
+
- lib/omniauth-teamsnap/version.rb
|
140
|
+
- lib/omniauth/strategies/teamsnap.rb
|
141
|
+
- omniauth-teamsnap.gemspec
|
142
|
+
- spec/omniauth/strategies/teamsnap_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
homepage: https://github.com/teamsnap/omniauth-teamsnap
|
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.2.2
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: Official OmniAuth strategy for TeamSnap
|
168
|
+
test_files: []
|