1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-15 09:50:06 +00:00

feat: CSP_DISABLE env option

This commit is contained in:
Mihajlo Medjedovic
2022-05-05 18:25:33 +00:00
parent 8065727b9b
commit dd3acce393
5 changed files with 1931 additions and 15531 deletions

View File

@@ -70,6 +70,9 @@ PORT=
# for MODE: `server` gets value from api/package.json `configuration.sasPath` # for MODE: `server` gets value from api/package.json `configuration.sasPath`
SAS_PATH=/path/to/sas/executable.exe SAS_PATH=/path/to/sas/executable.exe
# optional
# When `true` it will disable strict Content Security Policy
CSP_DISABLE=true
# optional # optional
# for MODE: `desktop`, prompts user # for MODE: `desktop`, prompts user

View File

@@ -25,7 +25,7 @@ const app = express()
app.use(cookieParser()) app.use(cookieParser())
app.use(morgan('tiny')) app.use(morgan('tiny'))
const { MODE, CORS, WHITELIST, PROTOCOL } = process.env const { MODE, CORS, WHITELIST, PROTOCOL, CSP_DISABLE } = process.env
export const cookieOptions = { export const cookieOptions = {
secure: PROTOCOL === 'https', secure: PROTOCOL === 'https',
@@ -41,16 +41,18 @@ export const csrfProtection = csrf({ cookie: cookieOptions })
/*********************************** /***********************************
* Handle security and origin * * Handle security and origin *
***********************************/ ***********************************/
app.use( if (CSP_DISABLE !== 'true') {
helmet({ app.use(
contentSecurityPolicy: { helmet({
directives: { contentSecurityPolicy: {
...helmet.contentSecurityPolicy.getDefaultDirectives(), directives: {
'script-src': ["'self'", "'unsafe-inline'"] ...helmet.contentSecurityPolicy.getDefaultDirectives(),
'script-src': ["'self'", "'unsafe-inline'"]
}
} }
} })
}) )
) }
/*********************************** /***********************************
* Enabling CORS * * Enabling CORS *

2151
package-lock.json generated

File diff suppressed because it is too large Load Diff

15285
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -20,6 +20,7 @@
"@types/node": "^12.20.28", "@types/node": "^12.20.28",
"@types/react": "^17.0.27", "@types/react": "^17.0.27",
"axios": "^0.24.0", "axios": "^0.24.0",
"monaco-editor": "^0.33.0",
"monaco-editor-webpack-plugin": "^7.0.1", "monaco-editor-webpack-plugin": "^7.0.1",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",