-
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.
Package the express router in MockPass to allow export as npm pkg - Shard initialisation of express router into `./app` - Specify package entrypoint as `./app` - Change `npm start` to explicitly invoke `nodemon index`
- Loading branch information
Showing
3 changed files
with
62 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env node | ||
const fs = require('fs') | ||
const express = require('express') | ||
const morgan = require('morgan') | ||
const path = require('path') | ||
require('dotenv').config() | ||
|
||
const { | ||
configOIDC, | ||
configOIDCv2, | ||
configMyInfo, | ||
configSGID, | ||
} = require('./lib/express') | ||
|
||
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', | ||
), | ||
), | ||
} | ||
|
||
const cryptoConfig = { | ||
signAssertion: process.env.SIGN_ASSERTION !== 'false', // default to true to be backward compatable | ||
signResponse: process.env.SIGN_RESPONSE !== 'false', | ||
encryptAssertion: process.env.ENCRYPT_ASSERTION !== 'false', | ||
resolveArtifactRequestSigned: | ||
process.env.RESOLVE_ARTIFACT_REQUEST_SIGNED !== 'false', | ||
} | ||
|
||
const options = { | ||
serviceProvider, | ||
showLoginPage: (req) => | ||
(req.header('X-Show-Login-Page') || process.env.SHOW_LOGIN_PAGE) === 'true', | ||
encryptMyInfo: process.env.ENCRYPT_MYINFO === 'true', | ||
cryptoConfig, | ||
} | ||
|
||
const app = express() | ||
app.use(morgan('combined')) | ||
|
||
configOIDC(app, options) | ||
configOIDCv2(app, options) | ||
configSGID(app, options) | ||
|
||
configMyInfo.consent(app) | ||
configMyInfo.v3(app, options) | ||
|
||
app.enable('trust proxy') | ||
app.use(express.static(path.join(__dirname, 'public'))) | ||
|
||
exports.app = app |
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