Skip to content

JWT Authorization

Alpha Fusion provides a simple JWT-based authentication setup. Connect it to your backend API to generate tokens and handle user authentication.


🛠 Core Implementation (app/core/)

  • 🧩 AuthService
    Manages signing in, signing out, and checking the current user's authentication status.

  • 🛡️ Guards
    Protect routes by checking if a user is signed in.

  • ⚡ AuthInterceptor
    Attaches the JWT token to request headers and handles 401 errors.


🚀 Setup Steps

  1. 🔗 Prepare Backend API
    Implement endpoints for login, logout, and optionally token refresh.

  2. ⚙️ Configure AuthService
    Update the API endpoints in AuthService to connect to your backend.

  3. 🔒 Use Guards
    Apply route guards (AuthGuard) to secure routes that require authentication.


🗄️ Token Storage

Tokens are stored in localStorage by default. Protect your app against XSS, CSRF, and other attacks, as the JWT token can be accessed from the browser.


🔄 Refresh Token

If using refresh tokens, store them in HTTP-only cookies in the backend. Alpha Fusion does not handle refresh tokens on the frontend; they are managed entirely by your backend API.