Content Security Policy and SPAs

Offen
#32,405 1 Kommentar 15 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
angular, typescript

Rechercherichtung

Beginne mit der Angular CLI-Build-Pipeline und untersuche, wie Bootstrap-JavaScript und index.html verarbeitet werden. Definiere das Ausgabeformat für hashes.json und überprüfe, dass darin Hashes für alle Bootstrap-Skripte aufgeführt sind, damit ein Backend sie in seinem CSP-Header verwenden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

angular/build:application area: @angular/build feature feature: votes required
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.
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
16 Std. 35 Min.
Gemergte PRs (30 T.)
176

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.