omniauth-xero-partner 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d59779617829154055ba832ce0369b1633621fc9
4
+ data.tar.gz: c463dd7f940766c1cdd1d153f5a08c58666ccbce
5
+ SHA512:
6
+ metadata.gz: 28222e95f5814e2186634f36dae8fd24ddc43d2b50b124fd4dca0cd1c75dc9114ef4a4edc78381c63d6865e36877b2258d517126aa1e58abd80f833ab53962ea
7
+ data.tar.gz: d1d5bad1a25822def46921d4ada11bfc9cb97eef2c9d9151c5637d1d67f2d0c5015569faf69f0ff2446a0b602deaf90ff8dbf6764e01f5ca4b89c47cad1a8b21
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ rvm:
5
+ - 2.2.3
6
+ script:
7
+ - "bundle exec rake"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-xero.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kale Worsley
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.
@@ -0,0 +1,69 @@
1
+ # WORK IN PROGRESS
2
+
3
+ # Omniauth Xero [![Build Status](https://travis-ci.org/kaleworsley/omniauth-xero.png?branch=master)](https://travis-ci.org/kaleworsley/omniauth-xero) [![Code Climate](https://codeclimate.com/github/kaleworsley/omniauth-xero.png)](https://codeclimate.com/github/kaleworsley/omniauth-xero)
4
+
5
+
6
+ [Omniauth Xero](https://github.com/kaleworsley/omniauth-xero) is an [OmniAuth](https://github.com/intridea/omniauth) authentication strategy for [Xero](http://www.xero.com).
7
+
8
+ ## Installation
9
+
10
+ Add this to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'omniauth', '~> 1.0.0'
14
+ gem 'omniauth-xero'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```bash
20
+ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+
25
+ ```bash
26
+ gem install omniauth-xero
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ Register your public application on the [Xero API site](https://api.xero.com/Application/Add).
32
+
33
+ For a Rack application:
34
+
35
+ ```ruby
36
+ use OmniAuth::Builder do
37
+ provider :xero, CONSUMER_KEY, CONSUMER_SECRET
38
+ end
39
+ ```
40
+
41
+ For a Rails application:
42
+
43
+ ```ruby
44
+ # config/intializers/omniauth.rb
45
+ Rails.application.config.middleware.use OmniAuth::Builder do
46
+ provider :xero, CONSUMER_KEY, CONSUMER_SECRET
47
+ end
48
+ ```
49
+
50
+ Or, if you use [devise](https://github.com/plataformatec/devise) for authentication:
51
+
52
+ ```ruby
53
+ # config/initializers/devise.rb
54
+ Devise.setup do |config|
55
+ config.omniauth :xero, CONSUMER_KEY, CONSUMER_SECRET
56
+ end
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
66
+
67
+ ## Copyright
68
+
69
+ Copyright (c) 2013 Kale Worsley. See [LICENSE.txt](LICENSE.txt) for details.
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ rescue LoadError
7
+ end
8
+
9
+ task default: :spec
@@ -0,0 +1,40 @@
1
+ require "omniauth/strategies/oauth"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class XeroPartner < OmniAuth::Strategies::OAuth
6
+
7
+ args [:consumer_key, :consumer_secret]
8
+
9
+ option :client_options, {
10
+ :access_token_path => "/oauth/AccessToken",
11
+ :authorize_path => "/oauth/Authorize",
12
+ :request_token_path => "/oauth/RequestToken",
13
+ :site => "https://api.xero.com",
14
+ }
15
+
16
+ info do
17
+ {
18
+ :first_name => raw_info["FirstName"],
19
+ :last_name => raw_info["LastName"],
20
+ }
21
+ end
22
+
23
+ uid { raw_info["UserID"] }
24
+
25
+ extra do
26
+ { "raw_info" => raw_info }
27
+ end
28
+
29
+ private
30
+
31
+ def raw_info
32
+ @raw_info ||= users.find { |user| user["IsSubscriber"] }
33
+ end
34
+
35
+ def users
36
+ @users ||= JSON.parse(access_token.get("/api.xro/2.0/Users", {'Accept'=>'application/json'}).body)["Users"]
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/xero_partner/version"
2
+ require "omniauth/strategies/xero_partner"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module XeroPartner
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omniauth/xero_partner/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-xero-partner"
8
+ spec.version = Omniauth::XeroPartner::VERSION
9
+ spec.authors = ["Kale Worsley", "Paul Ovechkin"]
10
+ spec.email = ["kale@worsley.co.nz", "paul.ovechkin@gmail.com"]
11
+ spec.description = "Xero Partner authentication strategy for OmniAuth."
12
+ spec.summary = "Xero Partner authentication strategy for OmniAuth."
13
+ spec.homepage = "http://github.com/blaze182/omniauth-xero-partner"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "omniauth-oauth", "~> 1.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.0"
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OmniAuth::Strategies::XeroPartner" do
4
+ subject do
5
+ OmniAuth::Strategies::XeroPartner.new(nil, {})
6
+ end
7
+
8
+ context 'client options' do
9
+ it 'has correct site' do
10
+ expect(subject.options.client_options.site).to eq('https://api.xero.com')
11
+ end
12
+
13
+ it 'has correct request token path' do
14
+ expect(subject.options.client_options.request_token_path).to eq('/oauth/RequestToken')
15
+ end
16
+
17
+ it 'has correct access token path' do
18
+ expect(subject.options.client_options.access_token_path).to eq('/oauth/AccessToken')
19
+ end
20
+
21
+ it 'has correct authorize path' do
22
+ expect(subject.options.client_options.authorize_path).to eq('/oauth/Authorize')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+ require 'omniauth'
6
+ require 'omniauth/xero_partner'
7
+
8
+ RSpec.configure do |config|
9
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
10
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-xero-partner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kale Worsley
8
+ - Paul Ovechkin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-07-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.3'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.0'
70
+ description: Xero Partner authentication strategy for OmniAuth.
71
+ email:
72
+ - kale@worsley.co.nz
73
+ - paul.ovechkin@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - lib/omniauth/strategies/xero_partner.rb
85
+ - lib/omniauth/xero_partner.rb
86
+ - lib/omniauth/xero_partner/version.rb
87
+ - omniauth-xero-partner.gemspec
88
+ - spec/omniauth/strategies/xero_partner_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: http://github.com/blaze182/omniauth-xero-partner
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.5.1
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Xero Partner authentication strategy for OmniAuth.
114
+ test_files:
115
+ - spec/omniauth/strategies/xero_partner_spec.rb
116
+ - spec/spec_helper.rb
117
+ has_rdoc: