Content Security Policy and SPAs
- Lenguaje dominante
- TypeScript
- Estrellas
- 27k
- Forks
- 11.8k
- Merge medio
- 14 h 23 min
- PR fusionados (30 d)
- 162
Descripción
### 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.
Guía de contribución
Línea de trabajo
Comienza con el pipeline de compilación de Angular CLI e inspecciona cómo se gestionan el JavaScript de bootstrap y index.html. Define el formato de salida de hashes.json y verifica que incluya los hashes de todos los scripts de bootstrap para que un backend pueda usarlos en su encabezado CSP.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- build-system, security
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100