Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sgID support for pocdex.public_officer_details #666

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Configure your application (or MockPass) with certificates/keys:
MockPass accepts any value for `client_id`, `redirect_uri` and `sp_esvcId`.
The `client_secret` value will be checked if configured, see below.

Only the profiles (NRICs) that have entries in Mockpass' static dataset will
Only the profiles (NRICs) that have entries in Mockpass' personas dataset will
succeed, using other NRICs will result in an error. See the list of personas in
[static/myinfo/v3.json](static/myinfo/v3.json).

Expand Down Expand Up @@ -119,10 +119,19 @@ Configure your application (or MockPass) with certificates/keys:

MockPass accepts any value for `client_id`, `client_secret` and `redirect_uri`.

Only the profiles (NRICs) that have entries in Mockpass' static dataset will
Only the profiles (NRICs) that have entries in Mockpass' personas dataset will
succeed, using other NRICs will result in an error. See the list of personas in
[static/myinfo/v3.json](static/myinfo/v3.json).

If the Public Officer Employment Details data item is requested, the
`pocdex.public_officer_details` scope data is sourced from the
`publicofficerdetails` data key (where present) on personas.
Most personas do not have this data key configured, and will result in a `"NA"`
response instead of an stringified array. As these personas are not identified
in the login page dropdown, please check the personas dataset linked above to
identify them.
The `pocdex.number_of_employments` scope is not supported.

| Configuration item | Explanation |
|---|---|
| Client certificate | **Overview:** When client makes any request, what certificate is used to verify the request signature, and what certificate is used to encrypt the data payload. <br> **Default:** static key `static/certs/key.pub` is used. <br> **How to configure:** Set the env var `SERVICE_PROVIDER_PUB_KEY` to the path to a public key PEM file. (A certificate PEM file can also be provided, despite the env var name.) |
Expand Down
6 changes: 6 additions & 0 deletions lib/express/sgid.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ const formatVehicles = (vehicles) => {
return vehicleObjects
}

const formatJsonStringify = (value) => {
return value == undefined ? 'NA' : JSON.stringify(value)
}

const defaultUndefinedToNA = (value) => {
return value || 'NA'
}
Expand Down Expand Up @@ -320,6 +324,8 @@ const sgIDScopeToMyInfoField = (persona, scope) => {
return defaultUndefinedToNA(persona.marital?.desc)
case 'myinfo.mobile_number_with_country_code':
return formatMobileNumberWithPrefix(persona.mobileno)
case 'pocdex.public_officer_details':
return formatJsonStringify(persona.publicofficerdetails)
default:
return 'NA'
}
Expand Down
11 changes: 10 additions & 1 deletion static/myinfo/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,16 @@
"source": "1",
"classification": "C",
"desc": ""
}
},
"publicofficerdetails": [
{
"work_email": "[email protected]",
"agency_name": "Work Allocation Singapore",
"department_name": "Allocation Central",
"employment_type": "Fixed Term",
"employment_title": "Senior Software Engineer - LLv1 (Individual Contributor) (WAS)"
}
]
},
"S9912370B": {
"edulevel": {
Expand Down