Good Samples
Speech based Search Movie Web Application using Angular2, TypeScript, ASP.NET MVC and WEB API
https://github.com/m-hassan-tariq/SpeechIMDBUsingAngular2
https://voicemoviesearch.azurewebsites.net/
Angular 2 Alert Service
https://github.com/m-hassan-tariq/SpeechIMDBUsingAngular2
http://jasonwatmore.com/post/2017/06/25/angular-2-4-alert-toaster-notifications
https://stackoverflow.com/questions/42440612/alert-service-in-angular-2
How does Angular 2 handle with XSS or CSRF?
Angular2 provides built-in, enabled by default*, anti XSS and CSRF/XSRF protection.
The DomSanitizationService takes care of removing the dangerous bits in order to prevent an XSSattack.
The CookieXSRFStrategy class (within the XHRConnection class) takes care of preventing CSRF/XSRF attacks.
Note that the CSRF/XSRF protection is enabled by default on the client but only works if the backend sets a cookie named XSRF-TOKEN with a random value when the user authenticates. For more information read up about the Cookie-to-Header Token pattern.
UPDATE: Official Angular2 security documentation: https://angular.io/docs/ts/latest/guide/security.html (Thanks to Martin Probst for the edit suggestion!).
Angular 2 with XSS and CSRF?
// Set the detected content type
switch (req.contentType) {
case ContentType.NONE:
break;
case ContentType.JSON:
_xhr.setRequestHeader('Content-Type', 'application/json');
break;
case ContentType.FORM:
_xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
break;
case ContentType.TEXT:
_xhr.setRequestHeader('Content-Type', 'text/plain');
break;
case ContentType.BLOB:
var blob = req.blob();
if (blob.type) {
_xhr.setRequestHeader('Content-Type', blob.type);
}
break;
}
Kind of XSS & CSRF
getTypeName() { return 'HTML'; }
getTypeName() { return 'Style'; }
getTypeName() { return 'Script'; }
getTypeName() { return 'URL'; }
getTypeName() { return 'ResourceURL'; }
Angular2 Sanitize Form Input for XSS attacks
Yes it does! Angular2 provides a built-in, enabled by default, anti XSS protection named DomSanitizationService.
Angular 2 - Get cookie from response
https://stackoverflow.com/questions/42289817/angular-2-get-cookie-from-response
TypeScript in 5 minutes
http://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html
TypeScript Cheat Sheet
Last updated for: TypeScript 2.2
https://www.sitepen.com/blog/2013/12/31/typescript-cheat-sheet/
Last updated for: TypeScript 1.8.10
https://github.com/frontdevops/typescript-cheat-sheet
TypeScript Cheat Sheet by Greg Finzer
https://www.cheatography.com/gregfinzer/cheat-sheets/typescript/pdf_bw/
The Definitive TypeScript Guide
This article describes the features and functionality of TypeScript 2.2
https://www.sitepen.com/blog/2013/12/31/definitive-guide-to-typescript/
Angular 2 Cheat Sheet
https://angular.io/guide/cheatsheet
https://www.cheatography.com/gregfinzer/cheat-sheets/angular-2/pdf_bw/
https://www.cheatography.com/gregfinzer/cheat-sheets/angular-2/
7 Best Practices of Angular2 Security [Security Risk]
In this section, I am going to describes Angular2 security for developing angular applications and the common applications vulnerabilities and cross site scripting XSS attacks and XSS also known as one click attacks.
“How”? “When”? And “Use”?
There are 4 key points to keep in mind when developing Angular's apps i.e.
- The application level securities like authentication and authorization.
- Coding with best Practices.
- Preventing cross site scripting (XSS).
- Reporting vulnerabilities and HTTP Level vulnerabilities.
Try the live example of the code shown in this page.
How to write Best Practices Applications?
As per my understanding be careful when developing apps,
- We can keep watching latest version of Angular’s library releases.
- Don't try to add hacks or modify to Angular’s library file.
- Avoid Angular’s Security Risk.
- Also avoid direct use of the DOM APIs.
- Try to use offline template compiler.
- Try to prevent CSRF or XSRF attacks in your web apps.
- Try to prevent JSON data in your web apps.
How to prevent Cross Site Scripting (XSS)?
This is the most common attacks on the web apps. To prevent XSS attacks, you must prevent malicious code from the DOM entering.
What is the Use the Offline Template Compiler?
The most use of offline template compiler is performance and it does improve the apps performance.
Also an offline template compiler is used to prevent vulnerabilities’ class that is called template injection.
Reference,
https://docs.angularjs.org/guide/security
If you have any doubt to implementing security in the apps, find a professional security reviewer and take help.
I hope you are enjoying with this post! Please share with you friends. Thank you!