shield.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. 'use strict'
  2. module.exports = {
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Content Security Policy
  6. |--------------------------------------------------------------------------
  7. |
  8. | Content security policy filters out the origins not allowed to execute
  9. | and load resources like scripts, styles and fonts. There are wide
  10. | variety of options to choose from.
  11. */
  12. csp: {
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Directives
  16. |--------------------------------------------------------------------------
  17. |
  18. | All directives are defined in camelCase and here is the list of
  19. | available directives and their possible values.
  20. |
  21. | https://content-security-policy.com
  22. |
  23. | @example
  24. | directives: {
  25. | defaultSrc: ['self', '@nonce', 'cdnjs.cloudflare.com']
  26. | }
  27. |
  28. */
  29. directives: {
  30. },
  31. /*
  32. |--------------------------------------------------------------------------
  33. | Report only
  34. |--------------------------------------------------------------------------
  35. |
  36. | Setting `reportOnly=true` will not block the scripts from running and
  37. | instead report them to a URL.
  38. |
  39. */
  40. reportOnly: false,
  41. /*
  42. |--------------------------------------------------------------------------
  43. | Set all headers
  44. |--------------------------------------------------------------------------
  45. |
  46. | Headers staring with `X` have been depreciated, since all major browsers
  47. | supports the standard CSP header. So its better to disable deperciated
  48. | headers, unless you want them to be set.
  49. |
  50. */
  51. setAllHeaders: false,
  52. /*
  53. |--------------------------------------------------------------------------
  54. | Disable on android
  55. |--------------------------------------------------------------------------
  56. |
  57. | Certain versions of android are buggy with CSP policy. So you can set
  58. | this value to true, to disable it for Android versions with buggy
  59. | behavior.
  60. |
  61. | Here is an issue reported on a different package, but helpful to read
  62. | if you want to know the behavior. https://github.com/helmetjs/helmet/pull/82
  63. |
  64. */
  65. disableAndroid: true
  66. },
  67. /*
  68. |--------------------------------------------------------------------------
  69. | X-XSS-Protection
  70. |--------------------------------------------------------------------------
  71. |
  72. | X-XSS Protection saves applications from XSS attacks. It is adopted
  73. | by IE and later followed by some other browsers.
  74. |
  75. | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
  76. |
  77. */
  78. xss: {
  79. enabled: true,
  80. enableOnOldIE: false
  81. },
  82. /*
  83. |--------------------------------------------------------------------------
  84. | Iframe Options
  85. |--------------------------------------------------------------------------
  86. |
  87. | xframe defines whether or not your website can be embedded inside an
  88. | iframe. Choose from one of the following options.
  89. | @available options
  90. | DENY, SAMEORIGIN, ALLOW-FROM http://example.com
  91. |
  92. | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
  93. */
  94. xframe: 'DENY',
  95. /*
  96. |--------------------------------------------------------------------------
  97. | No Sniff
  98. |--------------------------------------------------------------------------
  99. |
  100. | Browsers have a habit of sniffing content-type of a response. Which means
  101. | files with .txt extension containing Javascript code will be executed as
  102. | Javascript. You can disable this behavior by setting nosniff to false.
  103. |
  104. | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
  105. |
  106. */
  107. nosniff: true,
  108. /*
  109. |--------------------------------------------------------------------------
  110. | No Open
  111. |--------------------------------------------------------------------------
  112. |
  113. | IE users can execute webpages in the context of your website, which is
  114. | a serious security risk. Below option will manage this for you.
  115. |
  116. */
  117. noopen: true,
  118. /*
  119. |--------------------------------------------------------------------------
  120. | CSRF Protection
  121. |--------------------------------------------------------------------------
  122. |
  123. | CSRF Protection adds another layer of security by making sure, actionable
  124. | routes does have a valid token to execute an action.
  125. |
  126. */
  127. csrf: {
  128. enable: true,
  129. methods: ['POST', 'PUT', 'DELETE'],
  130. filterUris: [],
  131. cookieOptions: {
  132. httpOnly: false,
  133. sameSite: true,
  134. path: '/',
  135. maxAge: 7200
  136. }
  137. }
  138. }