omniauth-parallelmarkets 0.3.0 → 0.5.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: a546b67917507c45b98686e72e5438d9d353d32714d55f47cf98df2d68e3ad26
4
- data.tar.gz: 5f7c9ac005253ae226d006760d6405332222ed3da874f342806beccbc12423ff
3
+ metadata.gz: 116a4e6f6b528976b72de3ea0fe9b1fbdb49789abf02fe1ec140596554cedbb9
4
+ data.tar.gz: a609f558e13b46498bbe870c94873846a13a33a012700d78c261c76826995aa7
5
5
  SHA512:
6
- metadata.gz: a4a1cbc37e8e3b9f9cc4b5b5c051224d545c8b809ceb87ae4668638fb8ae0792695cbeab5465e15fe284bb5ffdb66d6c5f31f2661f1e9f6e0b3b487182f07bd5
7
- data.tar.gz: 90a28c0e4615bebe6908c0764b7a57e6b2a0fee3d8bfbf07559928b895939c9cd65acf1f93ba90bad5c830c69911fbf6bb62031687a1cc658fd816fd0d1ddd95
6
+ metadata.gz: cd138b8aab041a68b18601f66602b5b5753f5f7b820c1def738a024da32471ab72d81711a18ce53d64e4bc421e52d8d1e2d5e4167d52071551f4463d08aa3bb1
7
+ data.tar.gz: 5487cb23b4ba7b1e4213634ac645b3525f894dfe4e693c7cb9414448d892a6cf400d5f9968db5c48c7b435723635b2691b49ee0347db7110c56694d38094ebba
@@ -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.3.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -9,26 +9,26 @@ 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,
20
+ authorize_scopes: authorize_scopes,
21
+ # from /api/v1/me
28
22
  business_type: profile['business_type'],
23
+ primary_contact: to_contact_details(profile['primary_contact']),
24
+ raw_info: raw_info,
29
25
  type: raw_info['type'],
30
26
  user_id: raw_info['user_id'],
31
- 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
32
  }
33
33
  end
34
34
 
@@ -45,20 +45,42 @@ module OmniAuth
45
45
  options[:redirect_uri] || (full_host + script_name + callback_path)
46
46
  end
47
47
 
48
+ def scope?(single_scope)
49
+ authorize_scopes.include?(single_scope.to_s)
50
+ end
51
+
52
+ # if given ?scope query parameter, use that. otherwise, use server-side provider configuration
53
+ def authorize_scopes
54
+ @authorize_scopes ||= (env['omniauth.params']['scope'] || authorize_params['scope']).split(' ')
55
+ end
56
+
48
57
  def raw_info
49
- @raw_info ||= access_token.get('/v1/me').parsed
58
+ @raw_info ||= scope?(:profile) ? access_token.get('/v1/me').parsed : {}
50
59
  end
51
60
 
52
61
  def profile
53
62
  @profile ||= raw_info.fetch('profile', {})
54
63
  end
55
64
 
65
+ def user_profile
66
+ @user_profile ||= raw_info.fetch('user_profile', {})
67
+ end
68
+
56
69
  def raw_accreditations
57
- @raw_accreditations ||= access_token.get('/v1/accreditations').parsed
70
+ @raw_accreditations ||= scope?(:accreditation_status) ? access_token.get('/v1/accreditations').parsed : {}
58
71
  end
59
72
 
60
73
  def accreditations
61
- raw_accreditations['accreditations']
74
+ @accreditations ||= raw_accreditations.fetch('accreditations', [])
75
+ end
76
+
77
+ def to_contact_details(contact)
78
+ (contact.nil? || contact.empty?) ? {} : {
79
+ name: contact['name'] || "#{contact['first_name']} #{contact['last_name']}",
80
+ first_name: contact['first_name'],
81
+ last_name: contact['last_name'],
82
+ email: contact['email']
83
+ }
62
84
  end
63
85
  end
64
86
  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.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Muller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-23 00:00:00.000000000 Z
11
+ date: 2021-06-22 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
@@ -89,7 +74,7 @@ homepage: https://github.com/parallel-markets/omniauth-parallelmarkets
89
74
  licenses:
90
75
  - MIT
91
76
  metadata: {}
92
- post_install_message:
77
+ post_install_message:
93
78
  rdoc_options: []
94
79
  require_paths:
95
80
  - lib
@@ -104,8 +89,8 @@ 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.6
108
- signing_key:
92
+ rubygems_version: 3.1.2
93
+ signing_key:
109
94
  specification_version: 4
110
95
  summary: Parallel Markets OAuth strategy for OmniAuth
111
96
  test_files: []
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