Content Security Policy and SPAs
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 14 小時 23 分鐘
- 30 天內合併 PR
- 162
描述
### Which @angular/* package(s) are relevant/related to the feature request?
_No response_
### Description
Currently CSP and SPAs don't work well together.
There is however something very simple we could do to make CSP 100% compatible with SPA.
### Proposed solution
When Angular builds the app, also output a file called hashes.json. This file contains a list of hashes of all of the bootstrap js scripts. Then, in your backend, say asp.net core, you read this file and add the hashes to your CSP header.
This would be a very simple change that would make a lot of people's lives much easier.
### Alternatives considered
- AutoCSP is not ideal because it uses the meta tag, not http headers.
- Setting the nonce to CSP_NONCE doesn't work with strict-dynamic.
- Setting the nonce in index.html breaks caching.
貢獻指南
研究方向
從 Angular CLI 建置流程開始,檢查 bootstrap JavaScript 和 index.html 的處理方式。定義 hashes.json 的輸出格式,並驗證其中列出了所有 bootstrap 指令碼的雜湊值,以便後端可以在其 CSP 標頭中使用這些雜湊值。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- angular, typescript
- 領域
- build-system, security
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100