Skip to content

Commit f047bdc

Browse files
authored
Merge pull request #12 from DSorlov/dev
Dev
2 parents 5eb7adb + 7a7f7a2 commit f047bdc

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

Diff for: changelog.md

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog][keep-a-changelog]
66
## [Unreleased]
77
- Nothing right now
88

9+
## [0.1.9] (2020-12-08)
10+
11+
### Added
12+
- Implementing getAll (frejaorgid)
13+
14+
### Fixed
15+
- Fix for deferred authentication failing with signature failure (frejaeid)
16+
- Fixed broken creation data return if created by other than SSN (frejaorgid)
17+
- Fixed missing DEFERRED as datatype (frejaorgid,frejaeid)
18+
919
## [0.1.8] (2020-11-24)
1020

1121
### Fixed
@@ -78,6 +88,7 @@ The format is based on [Keep a Changelog][keep-a-changelog]
7888

7989
[keep-a-changelog]: http://keepachangelog.com/en/1.0.0/
8090
[Unreleased]: https://github.com/DSorlov/eid-provider/compare/master...dev
91+
[0.1.9]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.9
8192
[0.1.8]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.8
8293
[0.1.7]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.7
8394
[0.1.5]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.5

Diff for: modules/frejaeid.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function unPack(default_type,default_country,data) {
6464
} else {
6565
var value = data.toString();
6666
var country = default_country;
67-
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE') default_type = data.type;
67+
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE' || data.type === 'INFERRED') default_type = data.type;
6868
if (data.country === 'SE' || data.country === 'FI' || data.country === 'DK' || data.country === 'NO') country = data.country;
6969
if (data[default_type.toLowerCase()]) value = data[default_type.toLowerCase()];
7070

@@ -195,15 +195,31 @@ async function pollStatus(self,endpoint,data) {
195195
//Make sure the data we got is signed and fail if verification fails
196196
var jwtInfo = jwt.decode(result.data.details, { complete: true });
197197
var decoded = jwt.verify(result.data.details, self.settings.jwt_cert[jwtInfo.header.x5t]);
198-
var userInfo = JSON.parse(decoded.userInfo)
198+
var userId = '';
199+
if (decoded.userInfo==="N/A") {
200+
if (decoded.requestedAttributes.ssn) {
201+
userInfo = decoded.requestedAttributes.ssn.ssn;
202+
} else if (decoded.requestedAttributes.emailAddress) {
203+
userInfo = decoded.requestedAttributes.emailAddress;
204+
} else if (decoded.requestedAttributes.relyingPartyUserId) {
205+
userInfo = decoded.requestedAttributes.relyingPartyUserId;
206+
} else {
207+
return {status: 'error', code: 'api_error', description: 'Authentication successfull but no discriminatory identity found'};
208+
}
209+
} else if (decoded.userInfo==="SSN") {
210+
var tempInfo = JSON.parse(decoded.userInfo)
211+
userInfo = tempInfo.ssn;
212+
} else {
213+
userInfo = decoded.userInfo
214+
}
199215
} catch(err) {
200216
return {status: 'error', code: 'api_error', description: 'The signature integrity validation failed'};
201217
}
202218

203219
var result = {
204220
status: 'completed',
205221
user: {
206-
id: userInfo.ssn,
222+
id: userInfo,
207223
firstname: '',
208224
lastname: '',
209225
fullname: ''

Diff for: modules/frejaorgid.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function unPack(default_type,default_country,data) {
6565
} else {
6666
var value = data.toString();
6767
var country = default_country;
68-
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE' || data.type === 'ORG_ID') default_type = data.type;
68+
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE' || data.type === 'ORG_ID' || data.type === 'INFERRED') default_type = data.type;
6969
if (data.country === 'SE' || data.country === 'FI' || data.country === 'DK' || data.country === 'NO') country = data.country;
7070
if (data[default_type.toLowerCase()]) value = data[default_type.toLowerCase()];
7171

@@ -237,7 +237,6 @@ async function pollStatus(self,endpoint,data) {
237237
}
238238

239239
if (!result.data.requestedAttributes) {
240-
var userInfo = JSON.parse(decoded.userInfo);
241240
return {
242241
status: 'created',
243242
jwt_token: result.data.details,
@@ -365,6 +364,17 @@ async function cancelAddOrgIdRequest(id) {
365364
return true;
366365
}
367366

367+
async function getOrgIdList() {
368+
const [error,response] = await to(this.axios.post(`${this.settings.endpoint}/organisation/management/orgId/1.0/users/getAll`, ""));
369+
var result = error ? error.response : response;
370+
371+
if (!result.response && result.isAxiosError) {
372+
return {status: 'error', code: 'system_error', description: error.code, details: error.message}
373+
}
374+
375+
return { status: 'completed', users: result.data.userInfos }
376+
}
377+
368378
async function deleteOrgIdRequest(id) {
369379
const [error,response] = await to(this.axios.post(`${this.settings.endpoint}/organisation/management/orgId/1.0/delete`,
370380
"deleteOrganisationIdRequest="+Buffer.from(JSON.stringify({
@@ -414,6 +424,7 @@ module.exports = {
414424
pollAddOrgIdStatus: pollAddOrgIdStatus,
415425
initAddOrgIdRequest: initAddOrgIdRequest,
416426
cancelAddOrgIdRequest: cancelAddOrgIdRequest,
417-
deleteOrgIdRequest: deleteOrgIdRequest
427+
deleteOrgIdRequest: deleteOrgIdRequest,
428+
getOrgIdList: getOrgIdList
418429
}
419430
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eid-provider",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"description": "Integration module for electronic identification providers",
55
"bundleDependencies": false,
66
"deprecated": false,

Diff for: readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](#)
2-
[![version](https://img.shields.io/badge/version-0.1.8-green.svg)](#)
2+
[![version](https://img.shields.io/badge/version-0.1.9-green.svg)](#)
33
[![maintained](https://img.shields.io/maintenance/yes/2020.svg)](#)
44
[![maintainer](https://img.shields.io/badge/maintainer-daniel%20sörlöv-blue.svg)](https://github.com/DSorlov)
55
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://img.shields.io/github/license/DSorlov/eid-provider)

0 commit comments

Comments
 (0)