Skip to content

4. Security Layer

This document provides a comprehensive overview of the security measures in the project. It expands on the security section in GEMINI.md.


  • Authentication: Authentication is handled using JSON Web Tokens (JWT). The user logs in with their credentials, and the server returns a JWT. This token is then sent in the Authorization header of all subsequent requests.
  • Authorization: Authorization is handled using route guards. The AuthGuard service checks if the user is authenticated and has the necessary permissions to access a route. Permissions are based on user roles.
  • Token Storage: The JWT is stored in a secure, HTTP-only cookie to prevent Cross-Site Scripting (XSS) attacks.

  • Input Validation: All user input is validated on both the client-side (using Reactive Forms) and the server-side.
  • Output Encoding: All data is properly encoded before being displayed to the user to prevent XSS attacks. Angular’s built-in data binding provides this protection automatically.
  • Sanitization: For content that needs to be rendered as HTML, use Angular’s built-in DomSanitizer to sanitize the content and prevent XSS attacks.

  • All user input is validated on the client and server.
  • All data is properly encoded before being displayed.
  • Sensitive data is not stored in local storage.
  • The application uses HTTPS.
  • All dependencies are regularly updated to patch security vulnerabilities.
  • The application has been tested for common security vulnerabilities (XSS, CSRF, etc.).

  • Cross-Site Scripting (XSS): Prevented by Angular’s built-in data binding and sanitization.
  • Cross-Site Request Forgery (CSRF): Prevented by using a combination of JWTs and SameSite cookies.
  • Insecure Direct Object References (IDOR): Prevented by verifying that the user has permission to access the requested resource on the server-side.