omniauth-toshl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/lib/omniauth-toshl.rb +2 -0
- data/lib/omniauth-toshl/version.rb +5 -0
- data/lib/omniauth/strategies/toshl.rb +30 -0
- data/omniauth-toshl.gemspec +26 -0
- data/spec/omniauth/strategies/toshl_spec.rb +29 -0
- data/spec/spec_helper.rb +15 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b487b2b78ac52bd5a524e74dd62d405dcfb88ed4
|
4
|
+
data.tar.gz: 0ce828d3d61046881856dbae85c823f646f26906
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b458b497157cbefca204472ae454f28db1033ec85879d845d5fbff6ea41a1a291cde99600b183fcd8bd8cc955c9e5aae0aa26018b4b3844bc8640792b2da2c6
|
7
|
+
data.tar.gz: d8568de888730b6f4f9b0c47aa990f8153f9738b177fb8a3f05bc51492e53cb7e4b6d18071c1c89a1868a74fe451b24cdd51f4e3f17793deb8aaa65288eb710e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 H2ocube.com
|
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,42 @@
|
|
1
|
+
# OmniAuth::Toshl
|
2
|
+
|
3
|
+
An OmniAuth Strategy for Toshl.
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-toshl.png)](http://badge.fury.io/rb/omniauth-toshl)
|
5
|
+
[![Build Status](https://travis-ci.org/h2ocube/omniauth-toshl.png)](https://travis-ci.org/h2ocube/omniauth-toshl)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'omniauth-toshl'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-toshl
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Sinatra
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'omniauth'
|
27
|
+
require 'omniauth-toshl'
|
28
|
+
|
29
|
+
use Rack::Session::Cookie
|
30
|
+
use OmniAuth::Builder do
|
31
|
+
provider :toshl, 'YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET'
|
32
|
+
end
|
33
|
+
|
34
|
+
get '/auth/:provider/callback' do
|
35
|
+
# Do something with auth_hash
|
36
|
+
redirect to('/')
|
37
|
+
end
|
38
|
+
|
39
|
+
def auth_hash
|
40
|
+
request.env['omniauth.auth']
|
41
|
+
end
|
42
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Toshl < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, 'toshl'
|
7
|
+
|
8
|
+
option :client_options, { site: 'https://api.toshl.com', authorize_url: 'https://toshl.com/oauth2/authorize', token_url: 'https://toshl.com/oauth2/token'}
|
9
|
+
|
10
|
+
uid{ raw_info['id'] }
|
11
|
+
|
12
|
+
info do
|
13
|
+
{
|
14
|
+
name: raw_info['name'],
|
15
|
+
email: raw_info['email']
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
extra do
|
20
|
+
{
|
21
|
+
'raw_info' => raw_info
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def raw_info
|
26
|
+
@raw_info ||= access_token.get('/me').parsed
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-toshl/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'omniauth-toshl'
|
6
|
+
gem.platform = Gem::Platform::RUBY
|
7
|
+
gem.authors = ['Ben']
|
8
|
+
gem.email = ['ben@h2ocube.com']
|
9
|
+
gem.homepage = 'https://github.com/h2ocube/omniauth-toshl'
|
10
|
+
gem.summary = %q{Omniauth Strategy for Toshl.com}
|
11
|
+
gem.description = %q{Omniauth Strategy for Toshl.com}
|
12
|
+
gem.license = 'MIT'
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
gem.version = Omniauth::Toshl::VERSION
|
19
|
+
|
20
|
+
gem.add_dependency 'omniauth'
|
21
|
+
gem.add_dependency 'omniauth-oauth2'
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
|
+
gem.add_development_dependency 'rack-test'
|
24
|
+
gem.add_development_dependency 'simplecov'
|
25
|
+
gem.add_development_dependency 'webmock'
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Toshl do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::Toshl.new({})
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'general' do
|
10
|
+
it 'should be called toshl' do
|
11
|
+
subject.options.name.should eq('toshl')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'endpoints' do
|
16
|
+
it 'has correct site' do
|
17
|
+
subject.options.client_options.site.should eq('https://api.toshl.com')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'has correct authorize_url' do
|
21
|
+
subject.options.client_options.authorize_url.should eq('https://toshl.com/oauth2/authorize')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has correct token_url' do
|
25
|
+
subject.options.client_options.token_url.should eq('https://toshl.com/oauth2/token')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
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-toshl'
|
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,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-toshl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-03 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '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: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
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: 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: Omniauth Strategy for Toshl.com
|
98
|
+
email:
|
99
|
+
- ben@h2ocube.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/omniauth-toshl.rb
|
111
|
+
- lib/omniauth-toshl/version.rb
|
112
|
+
- lib/omniauth/strategies/toshl.rb
|
113
|
+
- omniauth-toshl.gemspec
|
114
|
+
- spec/omniauth/strategies/toshl_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
homepage: https://github.com/h2ocube/omniauth-toshl
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.1.11
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Omniauth Strategy for Toshl.com
|
140
|
+
test_files:
|
141
|
+
- spec/omniauth/strategies/toshl_spec.rb
|
142
|
+
- spec/spec_helper.rb
|
143
|
+
has_rdoc:
|