Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CSPHandler

Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement to distribution of malware.

CSP is designed to be fully backward compatible. Browsers that don't support it still work with servers that implement it, and vice-versa: browsers that don't support CSP simply ignore it, functioning as usual, defaulting to the standard same-origin policy for web content. If the site doesn't offer the CSP header, browsers likewise use the standard same-origin policy.

Hierarchy

  • CSPHandler

Implements

Index

Methods

addDirective

  • addDirective(name: string, value: string): CSPHandler
  • Adds a single directive entry to the handler. All previously set or added directives will be preserved. For more information on directives see: Content-Security-Policy.

    Parameters

    • name: string
    • value: string

    Returns CSPHandler

handle

setDirective

  • setDirective(name: string, value: string): CSPHandler
  • Sets a single directive entry to the handler. All previously set or added directives will be replaced. For more information on directives see: Content-Security-Policy.

    Parameters

    • name: string
    • value: string

    Returns CSPHandler

setReportOnly

  • To ease deployment, CSP can be deployed in report-only mode. The policy is not enforced, but any violations are reported to a provided URI. Additionally, a report-only header can be used to test a future revision to a policy without actually deploying it.

    Parameters

    • reportOnly: boolean

    Returns CSPHandler

Static create

  • Creates a new instance of the handler.

    Returns CSPHandler

Generated using TypeDoc