ContentSecurityStrategy
ContentSecurityStrategy 是@abp/ng.core包暴露出的抽象类. 它可以根据内容安全策略帮助你将内联脚本或样式标记为安全.
API
构造函数
constructor(public nonce?: string)
nonce启用将内联脚本或样式列入白名单,避免在script-src和style-src指令中使用unsafe-inline.
applyCSP
applyCSP(element: HTMLScriptElement | HTMLStyleElement): void
该方法将上述属性映射到给定element.
LooseContentSecurityPolicy
LooseContentSecurityPolicy 是扩展了 ContentSecurityStrategy 的类. 它需要 nonce 和带有给定 <script> 或 <style> 标记的标签.
NoContentSecurityPolicy
NoContentSecurityPolicy 是扩展了 ContentSecurityStrategy 的类. 它不会将内联脚本和样式标记为安全. 你可以将其视为空操作的替代方案.
s
预定义内容安全策略
可以通过 CONTENT_SECURITY_STRATEGY 常量访问预定义的内容安全策略.
Loose
CONTENT_SECURITY_STRATEGY.Loose(nonce: string)
nonce 会被设置.
None
CONTENT_SECURITY_STRATEGY.None()
什么都不会做.
抠丁客
