Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

Commit 5944940

Browse files
authored
SDK-273 v1.2.0 (#3)
* [SDK-273]: Update strategy and bump version * [SDK-273]: Update strategy and bump version * [SDK-273]: Add minor tweaks
1 parent 0f10bca commit 5944940

File tree

8 files changed

+136
-86
lines changed

8 files changed

+136
-86
lines changed

CHANGELOG.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
# Change Log
1+
# Changelog
22
All notable changes to this project will be documented in this file.
33

4-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
5-
and this project adheres to [Semantic Versioning](http://semver.org/).
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7-
## 1.1.3 - 2017-11-01
7+
## [1.2.0] - 2018-03-09
8+
### Added
9+
- `age_verified` returns a boolean value of the age validation
10+
11+
### Changed
12+
- Moved the profile attributes in the response Hash from `extra` to `info`. Please check [README.md](README.md#upgrading-from-version-11) for details.
813

14+
## [1.1.3] - 2017-11-01
915
### Added
1016
- `base64_selfie_uri` value
1117

12-
## 1.1.2 - 2017-10-18
18+
## [1.1.2] - 2017-10-18
1319

14-
## 1.1.1 - 2017-09-13
20+
## [1.1.1] - 2017-09-13
1521
### Changed
1622
- Switched from proprietary to MIT license
1723

@@ -21,8 +27,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2127
- `simplecov` `~> 0.15`
2228
- `webmock` `~> 3.0`
2329

24-
## 1.1.0 - 2017-04-11
25-
Updates dependencies to the latest versions and aligns extra fields naming conventions with the Yoti attributes.
30+
## [1.1.0] - 2017-04-11
31+
Updated dependencies to the latest versions and aligns extra fields naming conventions with the Yoti attributes.
2632

2733
### Added
2834
- `email_address` field
@@ -40,10 +46,10 @@ Updates dependencies to the latest versions and aligns extra fields naming conve
4046
- `simplecov` `~> 0.14`
4147
- `webmock` `~> 2.3`
4248

43-
## 1.0.1 - 2016-11-28
49+
## [1.0.1] - 2016-11-28
4450
### Added
4551
- Yoti proprietary license
4652

47-
## 1.0.0 - 2016-11-25
53+
## [1.0.0] - 2016-11-25
4854
### Added
4955
- This is an initial public release.

README.md

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ gem 'omniauth-yoti'
1919
And then execute:
2020

2121
```shell
22-
$ bundle
22+
bundle
2323
```
2424

2525
Or install it yourself as:
2626

2727
```shell
28-
$ gem install omniauth-yoti
28+
gem install omniauth-yoti
2929
```
3030

3131
## Configuration
@@ -63,21 +63,42 @@ A call to `/auth/yoti/callback` will open the Yoti authentication page, and afte
6363
"provider" => "yoti",
6464
"uid" => "mHvpV4...",
6565
"info" => {
66-
"name" => "mHvpV4Mm+yMb...",
67-
"base64_selfie_uri" => "data:image/jpeg;base64,/9j/2wCEAAMCAg..."
68-
},
66+
"name" => "John Doe",
67+
"selfie" => "jpeg image data file",
68+
"full_name" => "John Doe",
69+
"given_names" => "John",
70+
"family_name" => "Doe",
71+
"phone_number" => "07474747474",
72+
"email_address" => "[email protected]",
73+
"date_of_birth" => "1989-11-09",
74+
"postal_address" => "Fountain House\n130 Fenchurch St\nLONDON\nEC3M 5DJ",
75+
"gender" => "MALE",
76+
"nationality" => "GBR"
77+
"base64_selfie_uri" => "data:image/jpeg;base64,/9j/2wCEAAMCAg..."
78+
"age_verified" => true
79+
},
6980
"credentials" => {},
7081
"extra" => {
71-
"selfie" => "jpeg image file",
72-
"given_names" => "Given Name",
73-
"family_name" => "Family Name",
74-
"phone_number" => "07474747474",
75-
"email_address" => "[email protected]",
76-
"date_of_birth" => nil,
77-
"postal_address" => nil,
78-
"gender" => 'MALE',
79-
"nationality" => nil
80-
}
82+
{ "raw_info" =>
83+
{
84+
"selfie" => "jpeg image data file",
85+
"full_name" => "John Doe",
86+
"given_names" => "Given Name",
87+
"family_name" => "Family Name",
88+
"phone_number" => "07474747474",
89+
"email_address" => "[email protected]",
90+
"date_of_birth" => "1989-11-09",
91+
"postal_address" => "Fountain House\n130 Fenchurch St\nLONDON\nEC3M 5DJ",
92+
"gender" => "MALE",
93+
"nationality" => "GBR",
94+
"age_over:18" => true
95+
}
96+
}
8197
}
82-
8398
```
99+
100+
## Upgrading from version 1.1
101+
102+
Most of the profile attributes that were being stored in the `extra` fields got moved to `info`.
103+
104+
e.g. `request.env['omniauth.auth']['extra']['given_names']` will become `request.env['omniauth.auth']['info']['given_names']`

lib/omniauth/strategies/yoti.rb

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,35 @@ def request_phase
1313
end
1414

1515
uid { yoti_user_id }
16-
info {{
17-
name: yoti_user_id,
18-
base64_selfie_uri: base64_selfie_uri
19-
}}
2016

21-
def extra
22-
@raw_info ||= {
17+
info do
18+
{
19+
name: yoti_user_profile['full_name'],
2320
selfie: yoti_user_profile['selfie'],
21+
full_name: yoti_user_profile['full_name'],
2422
given_names: yoti_user_profile['given_names'],
2523
family_name: yoti_user_profile['family_name'],
2624
phone_number: yoti_user_profile['phone_number'],
2725
email_address: yoti_user_profile['email_address'],
2826
date_of_birth: yoti_user_profile['date_of_birth'],
2927
postal_address: yoti_user_profile['postal_address'],
3028
gender: yoti_user_profile['gender'],
31-
nationality: yoti_user_profile['nationality']
29+
nationality: yoti_user_profile['nationality'],
30+
base64_selfie_uri: base64_selfie_uri,
31+
age_verified: age_verified
3232
}
3333
end
3434

35+
extra do
36+
{
37+
raw_info: raw_info
38+
}
39+
end
40+
41+
def raw_info
42+
@raw_info ||= yoti_user_profile
43+
end
44+
3545
private
3646

3747
def yoti_activity_details
@@ -53,6 +63,10 @@ def base64_selfie_uri
5363
yoti_activity_details.base64_selfie_uri
5464
end
5565

66+
def age_verified
67+
yoti_activity_details.age_verified
68+
end
69+
5670
def configure_yoti_client!
5771
::Yoti.configure do |config|
5872
config.client_sdk_id = options.client_options[:client_sdk_id]

lib/omniauth/yoti/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Omniauth
22
module Yoti
3-
VERSION = '1.1.3'.freeze
3+
VERSION = '1.2.0'.freeze
44
end
55
end

omniauth-yoti.gemspec

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# coding: utf-8
2-
3-
lib = File.expand_path('../lib', __FILE__)
1+
lib = File.expand_path('lib', __dir__)
42
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
53
require 'omniauth/yoti/version'
64

@@ -22,7 +20,7 @@ Gem::Specification.new do |spec|
2220
spec.required_ruby_version = '>= 2.1.9'
2321

2422
spec.add_dependency 'omniauth', '~> 1.6'
25-
spec.add_dependency 'yoti', '~> 1.1.0'
23+
spec.add_dependency 'yoti', '~> 1.2.1'
2624

2725
spec.add_development_dependency 'bundler', '~> 1.13'
2826
spec.add_development_dependency 'rake', '~> 12.1'

rubocop.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
AllCops:
22
DisplayCopNames: true
33
DisplayStyleGuide: true
4-
TargetRubyVersion: 2.3
4+
TargetRubyVersion: 2.1.9
55

66
Metrics/AbcSize:
77
Max: 20
@@ -13,6 +13,9 @@ Metrics/MethodLength:
1313
CountComments: false
1414
Max: 15
1515

16+
Metrics/BlockLength:
17+
Enabled: false
18+
1619
Style/Documentation:
1720
Enabled: false
1821

@@ -22,5 +25,5 @@ Style/FrozenStringLiteralComment:
2225
Style/NumericLiterals:
2326
Enabled: false
2427

25-
Style/FileName:
28+
Naming:
2629
Enabled: false

spec/omniauth/strategies/yoti_spec.rb

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,78 +46,78 @@
4646
end
4747

4848
describe '#info' do
49-
it 'returns the name value' do
50-
expect(subject.info[:name]).to eql('Hig2yAT79cWvseSuXcIuCLa5lNkAPy70rxetUaeHlTJGmiwc/g1MWdYWYrexWvPU')
49+
context 'when using a mock request' do
50+
it 'returns the base64_selfie_uri value' do
51+
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
52+
expect(subject.info[:base64_selfie_uri]).to eql(selfie)
53+
end
5154
end
5255

53-
it 'returns the base64_selfie_uri value' do
54-
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
55-
expect(subject.info[:base64_selfie_uri]).to eql(selfie)
56+
context 'when using a mock object' do
57+
before do
58+
allow(subject).to receive(:yoti_user_profile).and_return(yoti_user_profile_mock)
59+
allow(subject).to receive(:base64_selfie_uri).and_return(base64_selfie_uri_mock)
60+
allow(subject).to receive(:age_verified).and_return(age_verified_mock)
61+
end
62+
63+
it 'returns the correct values' do
64+
expect(subject.info[:name]).to eql('John Doe')
65+
expect(subject.info[:selfie]).to eql('selfie.png')
66+
expect(subject.info[:full_name]).to eql('John Doe')
67+
expect(subject.info[:given_names]).to eql('John')
68+
expect(subject.info[:family_name]).to eql('Doe')
69+
expect(subject.info[:phone_number]).to eql('07474747474')
70+
expect(subject.info[:email_address]).to eql('[email protected]')
71+
expect(subject.info[:date_of_birth]).to eql('2000.12.12')
72+
expect(subject.info[:postal_address]).to eql('WC2N 4JH')
73+
expect(subject.info[:gender]).to eql('male')
74+
expect(subject.info[:nationality]).to eql('British')
75+
expect(subject.info[:base64_selfie_uri]).to eql('data:image/jpeg;base64,/9j/2wCEAAMCAg')
76+
expect(subject.info[:age_verified]).to eql(true)
77+
end
5678
end
5779
end
5880

5981
describe '#extra' do
6082
context 'when using a mock request' do
6183
it 'has the correct selfie' do
6284
selfie = File.read('spec/fixtures/selfie.txt', encoding: 'utf-8')
63-
expect('data:image/jpeg;base64,'.concat(Base64.strict_encode64(subject.extra[:selfie]))).to eql(selfie)
85+
expect('data:image/jpeg;base64,'.concat(Base64.strict_encode64(subject.extra[:raw_info]['selfie']))).to eql(selfie)
6486
end
6587

6688
it 'has the correct phone number' do
67-
expect(subject.extra[:phone_number]).to eql('+447474747474')
89+
expect(subject.extra[:raw_info]['phone_number']).to eql('+447474747474')
6890
end
6991
end
7092

7193
context 'when using a mock object' do
7294
before do
73-
allow(subject).to receive(:yoti_user_profile).and_return(raw_info_hash)
74-
end
75-
76-
it 'has the correct selfie' do
77-
expect(subject.extra[:selfie]).to eql('selfie.png')
78-
end
79-
80-
it 'has the correct given names' do
81-
expect(subject.extra[:given_names]).to eql('Given Names')
82-
end
83-
84-
it 'has the correct family name' do
85-
expect(subject.extra[:family_name]).to eql('Family Name')
95+
allow(subject).to receive(:yoti_user_profile).and_return(yoti_user_profile_mock)
8696
end
8797

88-
it 'has the correct mobile number' do
89-
expect(subject.extra[:phone_number]).to eql('07474747474')
90-
end
91-
92-
it 'has the correct email address' do
93-
expect(subject.extra[:email_address]).to eql('[email protected]')
94-
end
95-
96-
it 'has the correct date of birth' do
97-
expect(subject.extra[:date_of_birth]).to eql('2000.12.12')
98-
end
99-
100-
it 'has the correct postal address' do
101-
expect(subject.extra[:postal_address]).to eql('WC2N 4JH')
102-
end
103-
104-
it 'has the correct gender' do
105-
expect(subject.extra[:gender]).to eql('male')
106-
end
107-
108-
it 'has the correct nationality' do
109-
expect(subject.extra[:nationality]).to eql('British')
98+
it 'returns the correct values' do
99+
expect(subject.extra[:raw_info]['selfie']).to eql('selfie.png')
100+
expect(subject.extra[:raw_info]['full_name']).to eql('John Doe')
101+
expect(subject.extra[:raw_info]['given_names']).to eql('John')
102+
expect(subject.extra[:raw_info]['family_name']).to eql('Doe')
103+
expect(subject.extra[:raw_info]['phone_number']).to eql('07474747474')
104+
expect(subject.extra[:raw_info]['email_address']).to eql('[email protected]')
105+
expect(subject.extra[:raw_info]['date_of_birth']).to eql('2000.12.12')
106+
expect(subject.extra[:raw_info]['postal_address']).to eql('WC2N 4JH')
107+
expect(subject.extra[:raw_info]['gender']).to eql('male')
108+
expect(subject.extra[:raw_info]['nationality']).to eql('British')
110109
end
111110
end
112111
end
113112

114113
private
115114

116-
def raw_info_hash
115+
def yoti_user_profile_mock
117116
{
118117
'selfie' => 'selfie.png',
119-
'given_names' => 'Given Names',
120-
'family_name' => 'Family Name',
118+
'full_name' => 'John Doe',
119+
'given_names' => 'John',
120+
'family_name' => 'Doe',
121121
'phone_number' => '07474747474',
122122
'email_address' => '[email protected]',
123123
'date_of_birth' => '2000.12.12',
@@ -126,4 +126,12 @@ def raw_info_hash
126126
'nationality' => 'British'
127127
}
128128
end
129+
130+
def base64_selfie_uri_mock
131+
'data:image/jpeg;base64,/9j/2wCEAAMCAg'
132+
end
133+
134+
def age_verified_mock
135+
true
136+
end
129137
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'simplecov'
22
SimpleCov.start
3-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
44
require 'omniauth/yoti'
55
require 'webmock/rspec'
66

0 commit comments

Comments
 (0)