Noo*_*001 4 security identityserver4 google-fonts
要在 IdentityServer3 中使用 Google 字体,以下 Content-Security-Policy 从未奏效:
<meta http-equiv="Content-Security-Policy"
content=" style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
font-src 'self' 'unsafe-inline' https://fonts.gstatic.com data:">
Run Code Online (Sandbox Code Playgroud)
相反,我们在 idsrvApp.UseIdentityServer 构造函数中配置了 CspOptions,它确实有效:
CspOptions = new CspOptions {
FontSrc = "https://fonts.gstatic.com",
StyleSrc = "https://fonts.googleapis.com",
Enabled = true
}
Run Code Online (Sandbox Code Playgroud)
我们如何在 IdentityServer4 中配置 CspOptions?我很难找到它。
对于其他卡住的人,需要修改 IdentityServer4 快速入门文件附带的 SecurityHeadersAttribute.cs 文件。附加以下几行修复了它:
var csp = "default-src 'self'; object-src 'none'; frame-ancestors 'none'; sandbox allow-forms allow-same-origin allow-scripts; base-uri 'self';";
// These two lines enable google fonts
csp += "font-src 'self' https://fonts.gstatic.com;";
csp += "style-src 'self' https://fonts.googleapis.com;";
Run Code Online (Sandbox Code Playgroud)
该文件位于 quickstart/SecurityHeadersAttribute.cs
| 归档时间: |
|
| 查看次数: |
658 次 |
| 最近记录: |