-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from justynoh/feat/ndi-oidc
feat: NDI OIDC for Singpass and Corppass OIDC for Corppass authentication
- Loading branch information
Showing
11 changed files
with
485 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
configOIDC: require('./oidc'), | ||
...require('./oidc'), | ||
configMyInfo: require('./myinfo'), | ||
configSGID: require('./sgid'), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
configOIDC: require('./spcp'), | ||
configOIDCv2: require('./v2-ndi'), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const assertions = require('../../assertions') | ||
|
||
const buildAssertURL = (redirectURI, authCode, state) => | ||
`${redirectURI}?code=${encodeURIComponent( | ||
authCode, | ||
)}&state=${encodeURIComponent(state)}` | ||
|
||
const idGenerator = { | ||
singPass: ({ nric }) => | ||
assertions.myinfo.v3.personas[nric] ? `${nric} [MyInfo]` : nric, | ||
corpPass: ({ nric, uen }) => `${nric} / UEN: ${uen}`, | ||
} | ||
|
||
const customProfileFromHeaders = { | ||
singPass: (req) => { | ||
const customNricHeader = req.header('X-Custom-NRIC') | ||
const customUuidHeader = req.header('X-Custom-UUID') | ||
if (!customNricHeader || !customUuidHeader) { | ||
return false | ||
} | ||
return { nric: customNricHeader, uuid: customUuidHeader } | ||
}, | ||
corpPass: (req) => { | ||
const customNricHeader = req.header('X-Custom-NRIC') | ||
const customUuidHeader = req.header('X-Custom-UUID') | ||
const customUenHeader = req.header('X-Custom-UEN') | ||
if (!customNricHeader || !customUuidHeader || !customUenHeader) { | ||
return false | ||
} | ||
return { | ||
nric: customNricHeader, | ||
uuid: customUuidHeader, | ||
uen: customUenHeader, | ||
} | ||
}, | ||
} | ||
|
||
module.exports = { | ||
buildAssertURL, | ||
idGenerator, | ||
customProfileFromHeaders, | ||
} |
Oops, something went wrong.