omniauth-splitwise 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 +16 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +36 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/example/Gemfile +6 -0
- data/example/Gemfile.lock +35 -0
- data/example/config.ru +27 -0
- data/lib/omniauth-splitwise.rb +2 -0
- data/lib/omniauth/splitwise/version.rb +5 -0
- data/lib/omniauth/strategies/splitwise.rb +37 -0
- data/omniauth-splitwise.gemspec +22 -0
- data/spec/omniauth/strategies/splitwise_spec.rb +37 -0
- data/spec/spec_helper.rb +4 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c5dd3a989e67c5c6bcd9b6786890681f2e7c24da
|
4
|
+
data.tar.gz: e49d6a8bc3284f0cec23168c164242537fb5a716
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a382edfc303c4421607b55c0f35f2e727132561b7c39de250c5ee4e68e777c91403b3f73f48c316b4f7a40fe9e7a603734bb724a8eeff98ead55f609513b8ab
|
7
|
+
data.tar.gz: 8ec95fd694ca45b677f833eeea3c134c13aeb52678f671916c0201caa993126b83e9f3868915eec80e46c37f146917f66370f43b3c19f4d1ec1312b3d07d048c
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-splitwise (0.0.1)
|
5
|
+
multi_json
|
6
|
+
omniauth-oauth (~> 1.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.1.3)
|
12
|
+
hashie (2.0.5)
|
13
|
+
multi_json (1.8.2)
|
14
|
+
oauth (0.4.7)
|
15
|
+
omniauth (1.1.4)
|
16
|
+
hashie (>= 1.2, < 3)
|
17
|
+
rack
|
18
|
+
omniauth-oauth (1.0.1)
|
19
|
+
oauth
|
20
|
+
omniauth (~> 1.0)
|
21
|
+
rack (1.5.2)
|
22
|
+
rspec (2.7.0)
|
23
|
+
rspec-core (~> 2.7.0)
|
24
|
+
rspec-expectations (~> 2.7.0)
|
25
|
+
rspec-mocks (~> 2.7.0)
|
26
|
+
rspec-core (2.7.1)
|
27
|
+
rspec-expectations (2.7.0)
|
28
|
+
diff-lcs (~> 1.1.2)
|
29
|
+
rspec-mocks (2.7.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
omniauth-splitwise!
|
36
|
+
rspec (~> 2.7.0)
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# OmniAuth Splitwise
|
2
|
+
|
3
|
+
An OmniAuth strategy for authenticating to [Splitwise](http://www.splitwise.com). To use it, you'll need to [sign up for a Consumer Key and Secret](https://secure.splitwise.com/oauth_clients).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-splitwise'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself:
|
16
|
+
|
17
|
+
$ gem install omniauth-splitwise
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
For Rack apps, in your config.ru:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
use OmniAuth::Builder do
|
25
|
+
provider :splitwise, ENV['SPLITWISE_KEY'], ENV['SPLITWISE_SECRET']
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
For Rails apps, in config/initializers/omniauth.rb:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
33
|
+
provider :splitwise, ENV['SPLITWISE_KEY'], ENV['SPLITWISE_SECRET']
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
See also: [Integrating OmniAuth Into Your Application](https://github.com/intridea/omniauth#integrating-omniauth-into-your-application).
|
38
|
+
|
39
|
+
## Example
|
40
|
+
|
41
|
+
In the `example/` directory, run the provided Sinatra application for a demo:
|
42
|
+
|
43
|
+
$ cd example/
|
44
|
+
$ bundle
|
45
|
+
$ SPLITWISE_KEY=abc123 SPLITWISE_SECRET=def456 rackup
|
46
|
+
|
47
|
+
Then visit [localhost:9292](http://localhost:9292) to try it out.
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
56
|
+
|
57
|
+
# License
|
58
|
+
|
59
|
+
Copyright (C) 2014 by Nathan Griffith
|
60
|
+
|
61
|
+
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:
|
62
|
+
|
63
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
64
|
+
|
65
|
+
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 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/example/Gemfile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
omniauth-splitwise (0.0.1)
|
5
|
+
multi_json
|
6
|
+
omniauth-oauth (~> 1.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
hashie (2.0.5)
|
12
|
+
multi_json (1.8.2)
|
13
|
+
oauth (0.4.7)
|
14
|
+
omniauth (1.1.4)
|
15
|
+
hashie (>= 1.2, < 3)
|
16
|
+
rack
|
17
|
+
omniauth-oauth (1.0.1)
|
18
|
+
oauth
|
19
|
+
omniauth (~> 1.0)
|
20
|
+
rack (1.5.2)
|
21
|
+
rack-protection (1.5.0)
|
22
|
+
rack
|
23
|
+
sinatra (1.4.3)
|
24
|
+
rack (~> 1.4)
|
25
|
+
rack-protection (~> 1.4)
|
26
|
+
tilt (~> 1.3, >= 1.3.4)
|
27
|
+
tilt (1.4.1)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
multi_json
|
34
|
+
omniauth-splitwise!
|
35
|
+
sinatra
|
data/example/config.ru
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'omniauth-splitwise'
|
4
|
+
|
5
|
+
class App < Sinatra::Base
|
6
|
+
get '/' do
|
7
|
+
redirect '/auth/splitwise'
|
8
|
+
end
|
9
|
+
|
10
|
+
get '/auth/:provider/callback' do
|
11
|
+
content_type 'application/json'
|
12
|
+
MultiJson.encode(request.env)
|
13
|
+
end
|
14
|
+
|
15
|
+
get '/auth/failure' do
|
16
|
+
content_type 'application/json'
|
17
|
+
MultiJson.encode(request.env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
use Rack::Session::Cookie
|
22
|
+
|
23
|
+
use OmniAuth::Builder do
|
24
|
+
provider :splitwise, ENV['SPLITWISE_KEY'], ENV['SPLITWISE_SECRET']
|
25
|
+
end
|
26
|
+
|
27
|
+
run App.new
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'omniauth/strategies/oauth'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Splitwise < OmniAuth::Strategies::OAuth
|
6
|
+
option :name, "splitwise"
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'https://secure.splitwise.com',
|
10
|
+
:request_token_path => '/api/v3.0/get_request_token',
|
11
|
+
:access_token_path => '/api/v3.0/get_access_token',
|
12
|
+
:authorize_path => '/authorize',
|
13
|
+
:http_method => :post,
|
14
|
+
:scheme => :header
|
15
|
+
}
|
16
|
+
|
17
|
+
uid do
|
18
|
+
user_data['id']
|
19
|
+
end
|
20
|
+
|
21
|
+
info do
|
22
|
+
user_data
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def user_data
|
28
|
+
@info ||= MultiJson.decode(access_token.get('/api/v3.0/get_current_user').body)['user']
|
29
|
+
end
|
30
|
+
|
31
|
+
def callback_phase
|
32
|
+
session['oauth'][name.to_s]['callback_confirmed'] = true
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/splitwise/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'omniauth-splitwise'
|
7
|
+
s.version = OmniAuth::Splitwise::VERSION
|
8
|
+
s.authors = ['Nathan Griffith']
|
9
|
+
s.email = ['nathan@ngriffith.com']
|
10
|
+
s.summary = 'Splitwise strategy for OmniAuth'
|
11
|
+
s.homepage = 'https://github.com/Smudge/omniauth-splitwise'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0'
|
19
|
+
s.add_runtime_dependency 'multi_json'
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec', '~> 2.7.0'
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "OmniAuth::Strategies::Splitwise" do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Splitwise.new(nil, @options || {})
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'client options' do
|
9
|
+
it 'has correct Splitwise site' do
|
10
|
+
subject.options.client_options.site.should eq('https://secure.splitwise.com')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has correct request token path' do
|
14
|
+
subject.options.client_options.request_token_path.should eq('/api/v3.0/get_request_token')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has correct access token path' do
|
18
|
+
subject.options.client_options.access_token_path.should eq('/api/v3.0/get_access_token')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has correct authorize path' do
|
22
|
+
subject.options.client_options.authorize_path.should eq('/authorize')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context '#uid' do
|
27
|
+
before :each do
|
28
|
+
subject.stub(:user_data) { { 'id' => '123', "other_data" => 012345 } }
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns the id from user_data' do
|
32
|
+
subject.uid.should eq('123')
|
33
|
+
subject.info["id"].should eq("123")
|
34
|
+
subject.info["other_data"].should eq(012345)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-splitwise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Griffith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.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.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: multi_json
|
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: 2.7.0
|
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.0
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- nathan@ngriffith.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- example/Gemfile
|
69
|
+
- example/Gemfile.lock
|
70
|
+
- example/config.ru
|
71
|
+
- lib/omniauth-splitwise.rb
|
72
|
+
- lib/omniauth/splitwise/version.rb
|
73
|
+
- lib/omniauth/strategies/splitwise.rb
|
74
|
+
- omniauth-splitwise.gemspec
|
75
|
+
- spec/omniauth/strategies/splitwise_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
homepage: https://github.com/Smudge/omniauth-splitwise
|
78
|
+
licenses: []
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.0.14
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Splitwise strategy for OmniAuth
|
100
|
+
test_files:
|
101
|
+
- spec/omniauth/strategies/splitwise_spec.rb
|
102
|
+
- spec/spec_helper.rb
|