Content Security Policy and SPAs
- 主要言語
- TypeScript
- スター
- 27k
- フォーク
- 11.8k
- 平均マージ
- 14時間 23分
- マージ済み PR(30日)
- 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 の出力形式を定義し、バックエンドが CSP ヘッダーで使用できるよう、すべての bootstrap スクリプトのハッシュが一覧に含まれていることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- build-system, security
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100