omniauth-riskalyze 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 +20 -0
- data/Gemfile +16 -0
- data/README.md +42 -0
- data/Rakefile +17 -0
- data/lib/omniauth/riskalyze/version.rb +5 -0
- data/lib/omniauth/strategies/riskalyze.rb +45 -0
- data/lib/omniauth-riskalyze.rb +2 -0
- data/omniauth-riskalyze.gemspec +25 -0
- data/spec/app.rb +45 -0
- data/spec/omniauth/strategies/riskalyze_spec.rb +33 -0
- data/spec/spec_helper.rb +13 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53bb51618d01e8b1ea53733a228fe97413ca32e0
|
4
|
+
data.tar.gz: c81d1eea1af6e9473bbd9d56ec36d5b3dd75d6f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5aef3a793b265b27a32fa7bf43a63d9087060cf444691b2448fd96f5d4d355a9f36b500523a7b46bf76446d5127195b37bdb9fbfa660aff91290b7aee358d1e
|
7
|
+
data.tar.gz: 1db59e81229a61dc70b5ecd7dd54ff31f81f9fb7c1b6f32bea58245bb9aaae48cac603b64e94212b22970e13bfb086c0725b23f96d069435c237290432f26604
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rake'
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'rubocop', '> 0.25'
|
7
|
+
end
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'coveralls', :require => false
|
11
|
+
gem 'rack-test'
|
12
|
+
gem 'rspec', '~> 3.1.0'
|
13
|
+
gem 'simplecov', :require => false
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
omniauth-riskalyze
|
2
|
+
==============
|
3
|
+
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-riskalyze.png)](http://badge.fury.io/rb/omniauth-riskalyze)
|
5
|
+
|
6
|
+
Riskalyze OAuth2 Strategy for OmniAuth 1.x and supports the OAuth 2.0 server-side flow.
|
7
|
+
|
8
|
+
You may view the Riskalyze API documentation [here](https://developers.riskalyze.com/intro/).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add to your `Gemfile`:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'omniauth-riskalyze'
|
16
|
+
```
|
17
|
+
|
18
|
+
Then `bundle install`.
|
19
|
+
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
`OmniAuth::Strategies::Riskalyze` is simply Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
|
24
|
+
|
25
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
29
|
+
provider :riskalyze, ENV['RISKALYZE_CLIENT_ID'], ENV['RISKALYZE_CLIENT_SECRET']
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
Currently, there is only one configuration option that needs to be set:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
39
|
+
provider :riskalyze, ENV['RISKALYZE_CLIENT_ID'], ENV['RISKALYZE_CLIENT_SECRET']
|
40
|
+
end
|
41
|
+
|
42
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :test => :spec
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rubocop/rake_task'
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
rescue LoadError
|
12
|
+
task :rubocop do
|
13
|
+
$stderr.puts 'Rubocop is disabled'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => [:spec, :rubocop]
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Riskalyze < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = 'profile'
|
7
|
+
|
8
|
+
option :client_options, :site => 'https://api.riskalyze.com',
|
9
|
+
:authorize_url => 'https://pro.riskalyze.com/oauthconnect',
|
10
|
+
:token_url => 'https://api2.riskalyze.com/ap/v1/oauthpro/token'
|
11
|
+
|
12
|
+
uid { raw_info['uuid'] }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{
|
16
|
+
:first_name => raw_info['first_name'],
|
17
|
+
:last_name => raw_info['last_name'],
|
18
|
+
:email => raw_info['email'],
|
19
|
+
:picture => raw_info['picture'],
|
20
|
+
:promo_code => raw_info['promo_code']
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{
|
26
|
+
:raw_info => raw_info
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def raw_info
|
31
|
+
@raw_info ||= access_token.get('/v1/me').parsed || {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def request_phase
|
35
|
+
options[:authorize_params] = {
|
36
|
+
:client_id => options['client_id'],
|
37
|
+
:response_type => 'code',
|
38
|
+
:scopes => (options['scope'] || DEFAULT_SCOPE)
|
39
|
+
}
|
40
|
+
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/riskalyze/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'omniauth-riskalyze'
|
7
|
+
s.version = OmniAuth::Riskalyze::VERSION
|
8
|
+
s.authors = ['Kevin Pheasey']
|
9
|
+
s.email = ['kevin@kpheasey.com']
|
10
|
+
s.summary = 'Riskalyze strategy for OmniAuth'
|
11
|
+
s.description = 'Riskalyze strategy for OmniAuth v1.2'
|
12
|
+
s.homepage = 'https://github.com/TKOFinancialSolutions/omniauth-riskalyze'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'omniauth', '~> 1.2'
|
21
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
|
22
|
+
|
23
|
+
s.add_development_dependency 'dotenv', '~> 0'
|
24
|
+
s.add_development_dependency 'sinatra', '~> 0'
|
25
|
+
end
|
data/spec/app.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'dotenv'
|
5
|
+
require 'sinatra'
|
6
|
+
require 'omniauth'
|
7
|
+
require 'omniauth-riskalyze'
|
8
|
+
|
9
|
+
Dotenv.load
|
10
|
+
|
11
|
+
enable :sessions
|
12
|
+
|
13
|
+
use OmniAuth::Builder do
|
14
|
+
provider :riskalyze, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'] # , :scope => 'profile'
|
15
|
+
end
|
16
|
+
|
17
|
+
get '/' do
|
18
|
+
<<-HTML
|
19
|
+
<a href='/auth/riskalyze'>Sign in with Riskalyze</a>
|
20
|
+
HTML
|
21
|
+
end
|
22
|
+
|
23
|
+
get '/auth/failure' do
|
24
|
+
env['omniauth.error'].to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
get '/auth/:name/callback' do
|
28
|
+
auth = request.env['omniauth.auth']
|
29
|
+
|
30
|
+
puts %(
|
31
|
+
>> UID
|
32
|
+
#{auth.uid.inspect}
|
33
|
+
|
34
|
+
>> CREDENTIALS
|
35
|
+
#{auth.credentials.inspect}
|
36
|
+
|
37
|
+
>> INFO
|
38
|
+
#{auth.info.inspect}
|
39
|
+
#
|
40
|
+
>> EXTRA
|
41
|
+
#{auth.extra.inspect}
|
42
|
+
)
|
43
|
+
|
44
|
+
'Check logs for user information.'
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Riskalyze do
|
4
|
+
subject do
|
5
|
+
@subject ||= begin
|
6
|
+
@options ||= {}
|
7
|
+
args = ['client_id', 'client_secret', @options].compact
|
8
|
+
OmniAuth::Strategies::Riskalyze.new(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'client options' do
|
13
|
+
it 'should have correct name' do
|
14
|
+
expect(subject.options.name).to eq('riskalyze')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have correct site' do
|
18
|
+
expect(subject.options.client_options.site).to eq('https://api.riskalyze.com')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize url' do
|
22
|
+
expect(subject.options.client_options.authorize_url).to eq('https://login.riskalyze.com/oauth/authorize')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have correct access token url' do
|
26
|
+
expect(subject.options.client_options.token_url).to eq('https://login.riskalyze.com/oauth/token')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should indicate that the provider ignores the state parameted' do
|
30
|
+
expect(subject.options.provider_ignores_state).to eq false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start
|
7
|
+
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-riskalyze'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-riskalyze
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Pheasey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-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: '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.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
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: sinatra
|
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
|
+
description: Riskalyze strategy for OmniAuth v1.2
|
70
|
+
email:
|
71
|
+
- kevin@kpheasey.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- lib/omniauth-riskalyze.rb
|
81
|
+
- lib/omniauth/riskalyze/version.rb
|
82
|
+
- lib/omniauth/strategies/riskalyze.rb
|
83
|
+
- omniauth-riskalyze.gemspec
|
84
|
+
- spec/app.rb
|
85
|
+
- spec/omniauth/strategies/riskalyze_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage: https://github.com/TKOFinancialSolutions/omniauth-riskalyze
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Riskalyze strategy for OmniAuth
|
111
|
+
test_files:
|
112
|
+
- spec/app.rb
|
113
|
+
- spec/omniauth/strategies/riskalyze_spec.rb
|
114
|
+
- spec/spec_helper.rb
|