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

Allow assertion endpoint to be specified using request parameter #22

Merged
merged 4 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Alternatively, provide the paths to your app cert as env vars
$ npm install @opengovsg/mockpass

# Some familiarity with SAML Artifact Binding is assumed
# Configure where MockPass should send SAML artifact to
# Optional: Configure where MockPass should send SAML artifact to, default endpoint will be `PartnerId` in request query parameter.
$ export SINGPASS_ASSERT_ENDPOINT=http://localhost:5000/singpass/assert
$ export CORPPASS_ASSERT_ENDPOINT=http://localhost:5000/corppass/assert

Expand Down
3 changes: 0 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const { configSpcp, configMyInfo } = require('./lib/express')

const PORT = process.env.MOCKPASS_PORT || process.env.PORT || 5156

if (!process.env.SINGPASS_ASSERT_ENDPOINT && !process.env.CORPPASS_ASSERT_ENDPOINT) {
throw new Error('Either SINGPASS_ASSERT_ENDPOINT or CORPPASS_ASSERT_ENDPOINT must be set')
}
LoneRifle marked this conversation as resolved.
Show resolved Hide resolved
const serviceProvider = {
cert: fs.readFileSync(path.resolve(__dirname, process.env.SERVICE_PROVIDER_CERT_PATH || './static/certs/server.crt')),
pubKey: fs.readFileSync(path.resolve(__dirname, process.env.SERVICE_PROVIDER_PUB_KEY || './static/certs/key.pub')),
Expand Down
7 changes: 7 additions & 0 deletions lib/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ const identities = {
],
corpPass: [
{ NRIC: 'S8979373D', UEN: '123456789A' },
{ NRIC: 'S8116474F', UEN: '123456789A' },
{ NRIC: 'S8723211E', UEN: '123456789A' },
{ NRIC: 'S5062854Z', UEN: '123456789B' },
{ NRIC: 'T0066846F', UEN: '123456789B' },
{ NRIC: 'F9477325W', UEN: '123456789B' },
{ NRIC: 'S3000024B', UEN: '123456789C' },
{ NRIC: 'S6005040F', UEN: '123456789C' },
],
}

Expand Down
5 changes: 4 additions & 1 deletion lib/express/spcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function config (app, { showLoginPage, serviceProvider, idpConfig, cryptoConfig
app.get(`/${idp.toLowerCase()}/logininitial`, (req, res) => {
const assertEndpoint = req.query.esrvcID === 'MYINFO-CONSENTPLATFORM' && idp === 'singPass'
? MYINFO_ASSERT_ENDPOINT
: idpConfig[idp].assertEndpoint
: idpConfig[idp].assertEndpoint || req.query.PartnerId
const relayState = encodeURIComponent(req.query.Target)
if (showLoginPage) {
const identities = assertions.identities[idp]
Expand All @@ -38,6 +38,9 @@ function config (app, { showLoginPage, serviceProvider, idpConfig, cryptoConfig
if (assertions.myinfo.personas[id]) {
id += ' [MyInfo]'
}
if (idp === 'corpPass') {
id = `${id.NRIC} / UEN: ${id.UEN}`
}
deskoh marked this conversation as resolved.
Show resolved Hide resolved
return { id, assertURL }
})
const response = render(LOGIN_TEMPLATE, values)
Expand Down