omniauth-sage_impact 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/CHANGELOG.md +9 -0
- data/LICENSE.md +19 -0
- data/README.md +69 -0
- data/lib/omniauth/sage_impact/version.rb +5 -0
- data/lib/omniauth/sage_impact.rb +2 -0
- data/lib/omniauth/strategies/sage_impact.rb +86 -0
- data/lib/omniauth-sage_impact.rb +1 -0
- data/omniauth-sage_impact.gemspec +21 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ebd845e9290e0033b3325ee7a977ab90cb2443f
|
4
|
+
data.tar.gz: 297c5b0e3154a6e9c95d12cc1abf254c00567cb5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80d71b0fdd86aa5f724e53f369f375c4789941afd75d731ad8d09cae882adfbf4b8c2d2bb146fa015d10d2a65b5d6902de98d9ed76305819a3205be702647d17
|
7
|
+
data.tar.gz: 6f86abc4f0089df8e3b61f2813f955e622f2930b1a82faa538f998b805a52205b919c804936e569edf46e6b0e18346a21a89830d2748ad0f849357790daed933
|
data/CHANGELOG.md
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015 Dave Kimura
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# OmniAuth SageImpact
|
2
|
+
|
3
|
+
This gem contains the SageImpact strategy for OmniAuth 2.0.
|
4
|
+
|
5
|
+
![Sage Impact](sage_impact.png)
|
6
|
+
|
7
|
+
[https://app.sageaccountantscloud.com][SageImpact]
|
8
|
+
|
9
|
+
[SageImpact]: https://app.sageaccountantscloud.com/)
|
10
|
+
|
11
|
+
## Installing
|
12
|
+
|
13
|
+
Add to your `Gemfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'omniauth-sage_impact', '~> 0.0.1'
|
17
|
+
```
|
18
|
+
|
19
|
+
Then `bundle install`.
|
20
|
+
|
21
|
+
## Basic Usage
|
22
|
+
|
23
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
use OmniAuth::Builder do
|
27
|
+
provider :sage_impact, ENV['SAGEIMPACT_CLIENT_ID'], ENV['SAGEIMPACT_CLIENT_SECRET']
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
If you are using Devise, do not add the strategy to the `omniauth.rb` initializer. Instead, add
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
provider :sage_impact, ENV['SAGEIMPACT_CLIENT_ID'], ENV['SAGEIMPACT_CLIENT_SECRET']
|
35
|
+
```
|
36
|
+
|
37
|
+
to your `devise.rb` initializer.
|
38
|
+
|
39
|
+
You can find your client secret on the same page where your application API key is.
|
40
|
+
|
41
|
+
## Versioning
|
42
|
+
|
43
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
44
|
+
of this scheme should be reported as bugs.
|
45
|
+
|
46
|
+
[semver]: http://semver.org/spec/v2.0.0.html
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
Copyright (c) 2015 Dave Kimura
|
51
|
+
|
52
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
53
|
+
copy of this software and associated documentation files (the
|
54
|
+
"Software"), to deal in the Software without restriction, including
|
55
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
56
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
57
|
+
permit persons to whom the Software is furnished to do so, subject to
|
58
|
+
the following conditions:
|
59
|
+
|
60
|
+
The above copyright notice and this permission notice shall be included
|
61
|
+
in all copies or substantial portions of the Software.
|
62
|
+
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
64
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
65
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
66
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
67
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
68
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
69
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class SageImpact < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_RESPONSE_TYPE = 'code'
|
7
|
+
DEFAULT_GRANT = 'authorization_code'
|
8
|
+
INFO_URL = 'https://app.sageaccountantscloud.com/api/v1/me.json'.freeze
|
9
|
+
|
10
|
+
option :name, 'sage_impact'
|
11
|
+
|
12
|
+
# The list of optional values that can be sent with authorize
|
13
|
+
#
|
14
|
+
# @note :ref is a referral code for the Referral Program.
|
15
|
+
option :authorize_options, [:ref]
|
16
|
+
option :client_options, site: 'https://app.sageaccountantscloud.com',
|
17
|
+
authorize_url: '/oauth/authorize',
|
18
|
+
token_url: '/oauth/token'
|
19
|
+
|
20
|
+
uid { raw_info['id'].to_s }
|
21
|
+
|
22
|
+
info do
|
23
|
+
prune!('email' => retrieved_email,
|
24
|
+
'name' => raw_info['name'],
|
25
|
+
'first_name' => raw_info['first_name'],
|
26
|
+
'last_name' => raw_info['last_name'])
|
27
|
+
end
|
28
|
+
|
29
|
+
extra do
|
30
|
+
prune!('raw_info' => raw_info)
|
31
|
+
end
|
32
|
+
|
33
|
+
# The OAuth2 client authorization parameters.
|
34
|
+
#
|
35
|
+
# @return [OmniAuth::Strategy::Options]
|
36
|
+
def authorize_params
|
37
|
+
super.tap do |params|
|
38
|
+
params[:response_type] ||= DEFAULT_RESPONSE_TYPE
|
39
|
+
params[:client_id] = client.id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Unfiltered data about the authenticating user.
|
44
|
+
#
|
45
|
+
# @return [Hash]
|
46
|
+
def raw_info
|
47
|
+
@raw_info ||= access_token.get(INFO_URL).parsed || {}
|
48
|
+
end
|
49
|
+
|
50
|
+
# The OAuth2 client authentication parameters.
|
51
|
+
#
|
52
|
+
# @return [OmniAuth::Strategy::Options]
|
53
|
+
def token_params
|
54
|
+
super.tap do |params|
|
55
|
+
params[:grant_type] ||= DEFAULT_GRANT
|
56
|
+
params[:client_id] = client.id
|
57
|
+
params[:client_secret] = client.secret
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def full_name
|
64
|
+
first_name = raw_info['first_name'] || ''
|
65
|
+
last_name = raw_info['last_name'] || ''
|
66
|
+
|
67
|
+
"#{first_name} #{last_name}".strip || nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def prune!(hash)
|
71
|
+
hash.delete_if do |_, value|
|
72
|
+
prune!(value) if value.is_a?(Hash)
|
73
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def retrieved_email
|
78
|
+
primary = raw_info['emails'].detect { |e| e['primary'] }
|
79
|
+
primary ||= raw_info['emails'].first
|
80
|
+
primary['email']
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
OmniAuth.config.add_camelization 'sage_impact', 'SageImpact'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/sage_impact'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/sage_impact/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'omniauth-sage_impact'
|
8
|
+
spec.version = Omniauth::SageImpact::VERSION
|
9
|
+
spec.authors = ['David Kimura']
|
10
|
+
spec.email = ['dave@k-innovations.net']
|
11
|
+
spec.homepage = 'https://www.github.com/kobaltz/omniauth-sage_impact'
|
12
|
+
spec.summary = 'SageImpact OAuth2 strategy for OmniAuth'
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = %w(CHANGELOG.md LICENSE.md README.md omniauth-sage_impact.gemspec) + Dir['lib/**/*.rb']
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'omniauth-oauth2', '~> 1.0'
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-sage_impact
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Kimura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
description: SageImpact OAuth2 strategy for OmniAuth
|
42
|
+
email:
|
43
|
+
- dave@k-innovations.net
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- LICENSE.md
|
50
|
+
- README.md
|
51
|
+
- lib/omniauth-sage_impact.rb
|
52
|
+
- lib/omniauth/sage_impact.rb
|
53
|
+
- lib/omniauth/sage_impact/version.rb
|
54
|
+
- lib/omniauth/strategies/sage_impact.rb
|
55
|
+
- omniauth-sage_impact.gemspec
|
56
|
+
homepage: https://www.github.com/kobaltz/omniauth-sage_impact
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.8
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: SageImpact OAuth2 strategy for OmniAuth
|
80
|
+
test_files: []
|