You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
<a href="" target="_blank">Robust Defenses for Cross-Site Request Forgery</a> is a rich source of detail.
244
+
245
+
See also Dave Smith's masterful, easy-to-understand
246
+
<a href="https://www.youtube.com/watch?v=9inczw6qtpY" target="_blank" title="Cross Site Request Funkery Securing Your Angular Apps From Evil Doers">talk on XSRF at AngularConnect 2016</a>.
<li> [More fun with observables](#more-observables).</li>
34
34
</ul>
35
+
- [Guarding against Cross-Site Request Forgery](#xsrf)
35
36
- [Appendix: Tour of Heroes in-memory server](#in-mem-web-api).
36
37
37
38
A <live-example>live example</live-example> illustrates these topics.
@@ -46,7 +47,7 @@ block demos-list
46
47
:marked
47
48
- [The Tour of Heroes *HTTP* client demo](#http-client).
48
49
- [Fall back to !{_Promise}s](#promises).
49
-
- [Cross-origin requests: Wikipedia example](#cors).
50
+
- [Cross-Origin Requests: Wikipedia example](#cors).
50
51
- [More fun with observables](#more-observables).
51
52
52
53
:marked
@@ -446,7 +447,7 @@ block hero-list-comp-add-hero
446
447
447
448
To understand the implications and consequences of subscriptions, watch [Ben Lesh's talk on observables](https://www.youtube.com/watch?v=3LKMwkuK0ZE) or his video course on [egghead.io](https://egghead.io/lessons/rxjs-rxjs-observables-vs-promises).
448
449
449
-
h2#cors Cross-origin requests: Wikipedia example
450
+
h2#cors Cross-Origin Requests: Wikipedia example
450
451
:marked
451
452
You just learned how to make `XMLHttpRequests` using the !{_Angular_Http} service.
452
453
This is the most common approach for server communication, but it doesn't work in all scenarios.
@@ -628,6 +629,26 @@ block wikipedia-jsonp+
628
629
You added the `debounceTime`, `distinctUntilChanged`, and `switchMap` operators to the RxJS `Observable` class
629
630
in `rxjs-operators` as [described above](#rxjs).
630
631
632
+
a#xsrf
633
+
.l-main-section
634
+
:marked
635
+
## Guarding against Cross-Site Request Forgery
636
+
637
+
In a cross-site request forgery (CSRF or XSRF), an attacker tricks the user into visiting
638
+
a different web page with malicious code that secretly sends a request to your application's web server.
639
+
If the user is logged into your application, the browser sends the request along with authentication cookies.
640
+
An _unprotected_ server can't tell the difference between a legitimate request and a forged request.
641
+
642
+
In this manner, for example, a knowledgable attacker could transfer money from the user's account to the attacker's account.
643
+
644
+
The server and client application must work together to thwart this attack.
645
+
In one common technique, the server sends a randomly
646
+
generated authentication token in a cookie, often named `XSRF-TOKEN`.
647
+
The HTTP client adds that token to the request header, typically named `X-XSRF-TOKEN`, of subsequent requests.
648
+
The server receives both the cookie and the header, compares them, and processes the request only if the cookie and header match.
649
+
650
+
Angular's `Http` client supports this strategy automatically. See the [XSRF topic on the Security page](security.html#xsrf) for more information.
0 commit comments