项目

ContentSecurityStrategy

ContentSecurityStrategy是由@abp/ng.core包公开的抽象类。它可以帮助您根据内容安全策略将内联脚本或样式标记为安全。

API

构造函数

constructor(public nonce?: string)
  • nonce参数支持将内联脚本或样式加入白名单,从而避免在script-srcstyle-src指令中使用unsafe-inline

applyCSP

applyCSP(element: HTMLScriptElement | HTMLStyleElement): void

此方法将上述属性映射到给定的element元素上

LooseContentSecurityPolicy

LooseContentSecurityPolicy是继承自ContentSecurityStrategy的类。它需要nonce参数,并使用该参数标记给定的<script><style>标签

NoContentSecurityPolicy

NoContentSecurityPolicy是继承自ContentSecurityStrategy的类。它不会将内联脚本和样式标记为安全。您可以将其视为无操作替代方案

预定义内容安全策略

预定义的内容安全策略可通过CONTENT_SECURITY_STRATEGY常量访问

Loose

CONTENT_SECURITY_STRATEGY.Loose(nonce: string)

将设置nonce参数

None

CONTENT_SECURITY_STRATEGY.None()

不执行任何操作

另请参阅

在本文档中