omniauth-parallelmarkets 0.4.0 → 0.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a09a136f927f294185559a7dfab444e5fb74998f1de4eeccea20380a4f16de31
4
- data.tar.gz: d9dba23f966d094ca5ea5998e9750d4aefba87b8a34069b5372f9ac524aa270c
3
+ metadata.gz: 9d9f955824566ba7be54bb6041e602513ac5c4cf0a6c41abbcd84b700eabe9ca
4
+ data.tar.gz: 8a0a0ac60040da68d27a2dcf0061c9d3fc714742cc4cf24e43efcf7de10729b6
5
5
  SHA512:
6
- metadata.gz: c874ad3849bf22c15ffd1a8388ccbcf0120ad36e24222e7250c4434432ceda003df5628a4f4be2a7be6caac8a6b9dd453aba361909f183f6fb6f95f506b2c5fe
7
- data.tar.gz: df94ef490b155c9e7cf1117c3fb925d606e1e6a1faef01a390de63bd9f28d0d9c169069959e106f867268d4851eb481ce5aeaaf730cf71b349c67139abc57f09
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
- [![Build Status](https://travis-ci.org/parallel-markets/omniauth-parallelmarkets.svg?branch=master)](https://travis-ci.org/parallel-markets/omniauth-parallelmarkets)
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module ParallelMarkets
5
- VERSION = '0.4.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -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 do
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
- accreditations: accreditations,
28
- indicated_unaccredited: indicated_unaccredited,
20
+ authorize_scopes: authorize_scopes,
21
+ # from /api/v1/me
29
22
  business_type: profile['business_type'],
30
- primary_contact: profile['primary_contact'].nil? ? nil : {
31
- name: "#{profile['primary_contact']['first_name']} #{profile['primary_contact']['last_name']}",
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
- raw_info: raw_info
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 raw_accreditations
64
- @raw_accreditations ||= access_token.get('/v1/accreditations').parsed
67
+ def user_profile
68
+ @user_profile ||= raw_info.fetch('user_profile', {})
65
69
  end
66
70
 
67
- def indicated_unaccredited
68
- raw_accreditations['indicated_unaccredited']
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['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
@@ -20,5 +20,4 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
21
21
  s.add_development_dependency 'rake', '~> 12.0'
22
22
  s.add_development_dependency 'rspec', '~> 3.5'
23
- s.add_development_dependency 'rubocop'
24
23
  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.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: 2020-07-28 00:00:00.000000000 Z
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.0.8
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
@@ -1,11 +0,0 @@
1
- Metrics/LineLength:
2
- Enabled: false
3
-
4
- Metrics/BlockLength:
5
- Enabled: false
6
-
7
- Style/Documentation:
8
- Enabled: false
9
-
10
- Naming/FileName:
11
- Enabled: false
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- cache: bundler
2
- language: ruby
3
- rvm:
4
- - 2.3
5
- - 2.4
6
- - 2.5