omniauth-parallelmarkets 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +18 -0
- data/README.md +1 -1
- data/lib/omniauth-parallelmarkets/version.rb +1 -1
- data/lib/omniauth/strategies/parallelmarkets.rb +45 -24
- data/omniauth-parallelmarkets.gemspec +0 -1
- metadata +4 -19
- data/.rubocop.yml +0 -11
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9f955824566ba7be54bb6041e602513ac5c4cf0a6c41abbcd84b700eabe9ca
|
4
|
+
data.tar.gz: 8a0a0ac60040da68d27a2dcf0061c9d3fc714742cc4cf24e43efcf7de10729b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6411a99701c9ac720a070699de9b948c570e950ad80c9cde73eca4d001c9461cbe8d6268a493e1e8e863c4f5364f94a0b6e0da9ae651afc6fc2a57b8c0ddc818
|
7
|
+
data.tar.gz: aa9544f7df643fbfd389fb3d8a16725e6a80f7ec7bd2b857d511e97d0b322daf0127817b04bd49a876d52ffffa3b85b97953462778bc90f7fcf3090816ea6bdd
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Run Tests
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
jobs:
|
7
|
+
test:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- name: Checkout
|
11
|
+
uses: actions/checkout@master
|
12
|
+
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: '3.0.1'
|
16
|
+
bundler-cache: true
|
17
|
+
|
18
|
+
- run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/omniauth-parallelmarkets.svg)](https://badge.fury.io/rb/omniauth-parallelmarkets)
|
2
|
-
[![
|
2
|
+
[![Tests](https://github.com/parallel-markets/omniauth-parallelmarkets/actions/workflows/ci.yml/badge.svg)](https://github.com/parallel-markets/omniauth-parallelmarkets/actions/workflows/ci.yml)
|
3
3
|
|
4
4
|
# OmniAuth ParallelMarkets
|
5
5
|
|
@@ -9,33 +9,28 @@ module OmniAuth
|
|
9
9
|
site: 'https://api.parallelmarkets.com',
|
10
10
|
authorize_url: '/v1/oauth/authorize',
|
11
11
|
token_url: '/v1/oauth/token'
|
12
|
-
option :authorize_options, %i[scope force_accreditation_check]
|
12
|
+
option :authorize_options, %i[scope force_accreditation_check force_identity_check identity_claim_override_id]
|
13
13
|
|
14
14
|
uid { raw_info['id'] }
|
15
15
|
|
16
|
-
info
|
17
|
-
{
|
18
|
-
name: profile['name'] || "#{profile['first_name']} #{profile['last_name']}",
|
19
|
-
first_name: profile['first_name'],
|
20
|
-
last_name: profile['last_name'],
|
21
|
-
email: profile['email']
|
22
|
-
}
|
23
|
-
end
|
16
|
+
info { to_contact_details(profile) }
|
24
17
|
|
25
18
|
extra do
|
26
19
|
{
|
27
|
-
|
28
|
-
|
20
|
+
authorize_scopes: authorize_scopes,
|
21
|
+
# from /api/v1/me
|
29
22
|
business_type: profile['business_type'],
|
30
|
-
primary_contact: profile['primary_contact']
|
31
|
-
|
32
|
-
first_name: profile['primary_contact']['first_name'],
|
33
|
-
last_name: profile['primary_contact']['last_name'],
|
34
|
-
email: profile['primary_contact']['email']
|
35
|
-
},
|
23
|
+
primary_contact: to_contact_details(profile['primary_contact']),
|
24
|
+
raw_info: raw_info,
|
36
25
|
type: raw_info['type'],
|
37
26
|
user_id: raw_info['user_id'],
|
38
|
-
|
27
|
+
user_profile: to_contact_details(user_profile),
|
28
|
+
user_providing_for: raw_info['user_providing_for'],
|
29
|
+
# from /api/v1/accreditations
|
30
|
+
accreditations: accreditations,
|
31
|
+
indicated_unaccredited: raw_accreditations['indicated_unaccredited'],
|
32
|
+
# from /api/v1/identity
|
33
|
+
identity_details: identity_details
|
39
34
|
}
|
40
35
|
end
|
41
36
|
|
@@ -52,24 +47,50 @@ module OmniAuth
|
|
52
47
|
options[:redirect_uri] || (full_host + script_name + callback_path)
|
53
48
|
end
|
54
49
|
|
50
|
+
def scope?(single_scope)
|
51
|
+
authorize_scopes.include?(single_scope.to_s)
|
52
|
+
end
|
53
|
+
|
54
|
+
# if given ?scope query parameter, use that. otherwise, use server-side provider configuration
|
55
|
+
def authorize_scopes
|
56
|
+
@authorize_scopes ||= (env['omniauth.params']['scope'] || authorize_params['scope']).split(' ')
|
57
|
+
end
|
58
|
+
|
55
59
|
def raw_info
|
56
|
-
@raw_info ||= access_token.get('/v1/me').parsed
|
60
|
+
@raw_info ||= scope?(:profile) ? access_token.get('/v1/me').parsed : {}
|
57
61
|
end
|
58
62
|
|
59
63
|
def profile
|
60
64
|
@profile ||= raw_info.fetch('profile', {})
|
61
65
|
end
|
62
66
|
|
63
|
-
def
|
64
|
-
@
|
67
|
+
def user_profile
|
68
|
+
@user_profile ||= raw_info.fetch('user_profile', {})
|
65
69
|
end
|
66
70
|
|
67
|
-
def
|
68
|
-
raw_accreditations
|
71
|
+
def raw_accreditations
|
72
|
+
@raw_accreditations ||= scope?(:accreditation_status) ? access_token.get('/v1/accreditations').parsed : {}
|
69
73
|
end
|
70
74
|
|
71
75
|
def accreditations
|
72
|
-
raw_accreditations
|
76
|
+
@accreditations ||= raw_accreditations.fetch('accreditations', [])
|
77
|
+
end
|
78
|
+
|
79
|
+
def raw_identity
|
80
|
+
@raw_identity ||= scope?(:identity) ? access_token.get('/v1/identity').parsed : {}
|
81
|
+
end
|
82
|
+
|
83
|
+
def identity_details
|
84
|
+
@identity_details ||= raw_identity['identity_details']
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_contact_details(contact)
|
88
|
+
(contact.nil? || contact.empty?) ? {} : {
|
89
|
+
name: contact['name'] || "#{contact['first_name']} #{contact['last_name']}",
|
90
|
+
first_name: contact['first_name'],
|
91
|
+
last_name: contact['last_name'],
|
92
|
+
email: contact['email']
|
93
|
+
}
|
73
94
|
end
|
74
95
|
end
|
75
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-parallelmarkets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Muller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
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
55
|
description: Parallel Markets OAuth strategy for OmniAuth.
|
70
56
|
email:
|
71
57
|
- bamuller@gmail.com
|
@@ -73,10 +59,9 @@ executables: []
|
|
73
59
|
extensions: []
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
62
|
+
- ".github/workflows/ci.yml"
|
76
63
|
- ".gitignore"
|
77
64
|
- ".rspec"
|
78
|
-
- ".rubocop.yml"
|
79
|
-
- ".travis.yml"
|
80
65
|
- Gemfile
|
81
66
|
- LICENSE
|
82
67
|
- README.md
|
@@ -104,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
89
|
- !ruby/object:Gem::Version
|
105
90
|
version: '0'
|
106
91
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
92
|
+
rubygems_version: 3.1.2
|
108
93
|
signing_key:
|
109
94
|
specification_version: 4
|
110
95
|
summary: Parallel Markets OAuth strategy for OmniAuth
|
data/.rubocop.yml
DELETED