forked from vadivelan-k/mockpass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·37 lines (32 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
const fs = require('fs')
const express = require('express')
const path = require('path')
const { config } = require('./lib/express')
const PORT = process.env.MOCKPASS_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')
}
const app = config(express(), {
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')),
},
idpConfig: {
singPass: {
id: process.env.SINGPASS_IDP_ID || 'https://saml-internet.singpass.gov.sg/FIM/sps/SingpassIDPFed/saml20',
assertEndpoint: process.env.SINGPASS_ASSERT_ENDPOINT,
},
corpPass: {
id: process.env.CORPPASS_IDP_ID || 'https://saml.corppass.gov.sg/FIM/sps/CorpIDPFed/saml20',
assertEndpoint: process.env.CORPPASS_ASSERT_ENDPOINT,
},
},
showLoginPage: process.env.SHOW_LOGIN_PAGE === 'true',
})
app.listen(
PORT,
err => err
? console.error('Unable to start MockPass', err)
: console.warn(`MockPass listening on ${PORT}`)
)