Skip to content

Commit

Permalink
Merge pull request #12 from DSorlov/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DSorlov authored Dec 8, 2020
2 parents 5eb7adb + 7a7f7a2 commit f047bdc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog][keep-a-changelog]
## [Unreleased]
- Nothing right now

## [0.1.9] (2020-12-08)

### Added
- Implementing getAll (frejaorgid)

### Fixed
- Fix for deferred authentication failing with signature failure (frejaeid)
- Fixed broken creation data return if created by other than SSN (frejaorgid)
- Fixed missing DEFERRED as datatype (frejaorgid,frejaeid)

## [0.1.8] (2020-11-24)

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

[keep-a-changelog]: http://keepachangelog.com/en/1.0.0/
[Unreleased]: https://github.com/DSorlov/eid-provider/compare/master...dev
[0.1.9]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.9
[0.1.8]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.8
[0.1.7]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.7
[0.1.5]: https://github.com/DSorlov/eid-provider/releases/tag/v0.1.5
Expand Down
22 changes: 19 additions & 3 deletions modules/frejaeid.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function unPack(default_type,default_country,data) {
} else {
var value = data.toString();
var country = default_country;
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE') default_type = data.type;
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE' || data.type === 'INFERRED') default_type = data.type;
if (data.country === 'SE' || data.country === 'FI' || data.country === 'DK' || data.country === 'NO') country = data.country;
if (data[default_type.toLowerCase()]) value = data[default_type.toLowerCase()];

Expand Down Expand Up @@ -195,15 +195,31 @@ async function pollStatus(self,endpoint,data) {
//Make sure the data we got is signed and fail if verification fails
var jwtInfo = jwt.decode(result.data.details, { complete: true });
var decoded = jwt.verify(result.data.details, self.settings.jwt_cert[jwtInfo.header.x5t]);
var userInfo = JSON.parse(decoded.userInfo)
var userId = '';
if (decoded.userInfo==="N/A") {
if (decoded.requestedAttributes.ssn) {
userInfo = decoded.requestedAttributes.ssn.ssn;
} else if (decoded.requestedAttributes.emailAddress) {
userInfo = decoded.requestedAttributes.emailAddress;
} else if (decoded.requestedAttributes.relyingPartyUserId) {
userInfo = decoded.requestedAttributes.relyingPartyUserId;
} else {
return {status: 'error', code: 'api_error', description: 'Authentication successfull but no discriminatory identity found'};
}
} else if (decoded.userInfo==="SSN") {
var tempInfo = JSON.parse(decoded.userInfo)
userInfo = tempInfo.ssn;
} else {
userInfo = decoded.userInfo
}
} catch(err) {
return {status: 'error', code: 'api_error', description: 'The signature integrity validation failed'};
}

var result = {
status: 'completed',
user: {
id: userInfo.ssn,
id: userInfo,
firstname: '',
lastname: '',
fullname: ''
Expand Down
17 changes: 14 additions & 3 deletions modules/frejaorgid.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function unPack(default_type,default_country,data) {
} else {
var value = data.toString();
var country = default_country;
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE' || data.type === 'ORG_ID') default_type = data.type;
if (data.type === 'EMAIL' || data.type === 'SSN' || data.type === 'PHONE' || data.type === 'ORG_ID' || data.type === 'INFERRED') default_type = data.type;
if (data.country === 'SE' || data.country === 'FI' || data.country === 'DK' || data.country === 'NO') country = data.country;
if (data[default_type.toLowerCase()]) value = data[default_type.toLowerCase()];

Expand Down Expand Up @@ -237,7 +237,6 @@ async function pollStatus(self,endpoint,data) {
}

if (!result.data.requestedAttributes) {
var userInfo = JSON.parse(decoded.userInfo);
return {
status: 'created',
jwt_token: result.data.details,
Expand Down Expand Up @@ -365,6 +364,17 @@ async function cancelAddOrgIdRequest(id) {
return true;
}

async function getOrgIdList() {
const [error,response] = await to(this.axios.post(`${this.settings.endpoint}/organisation/management/orgId/1.0/users/getAll`, ""));
var result = error ? error.response : response;

if (!result.response && result.isAxiosError) {
return {status: 'error', code: 'system_error', description: error.code, details: error.message}
}

return { status: 'completed', users: result.data.userInfos }
}

async function deleteOrgIdRequest(id) {
const [error,response] = await to(this.axios.post(`${this.settings.endpoint}/organisation/management/orgId/1.0/delete`,
"deleteOrganisationIdRequest="+Buffer.from(JSON.stringify({
Expand Down Expand Up @@ -414,6 +424,7 @@ module.exports = {
pollAddOrgIdStatus: pollAddOrgIdStatus,
initAddOrgIdRequest: initAddOrgIdRequest,
cancelAddOrgIdRequest: cancelAddOrgIdRequest,
deleteOrgIdRequest: deleteOrgIdRequest
deleteOrgIdRequest: deleteOrgIdRequest,
getOrgIdList: getOrgIdList
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eid-provider",
"version": "0.1.8",
"version": "0.1.9",
"description": "Integration module for electronic identification providers",
"bundleDependencies": false,
"deprecated": false,
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](#)
[![version](https://img.shields.io/badge/version-0.1.8-green.svg)](#)
[![version](https://img.shields.io/badge/version-0.1.9-green.svg)](#)
[![maintained](https://img.shields.io/maintenance/yes/2020.svg)](#)
[![maintainer](https://img.shields.io/badge/maintainer-daniel%20sörlöv-blue.svg)](https://github.com/DSorlov)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://img.shields.io/github/license/DSorlov/eid-provider)
Expand Down

0 comments on commit f047bdc

Please sign in to comment.