Auth0Context) exists in the codebase but is currently inactive — the active auth hook (UseAuth) resolves to FirebaseContext. Route guards built on top of Firebase control which pages users can access based on their authentication state and role permissions.
Authentication providers
- Firebase (active)
- Firebase
Firebase Authentication is the active identity provider for TMT. It handles user login, session persistence, and password reset.Package:
Context file:
firebase/compat/appContext file:
src/guards/firebase/FirebaseContext.jsThe active auth hook:Route guards
TMT uses three guard components to control access to routes.AuthGuard
File:src/guards/authGuard/AuthGuard.js
AuthGuard wraps all routes that require a logged-in user. On mount, it checks isAuthenticated from the auth context. If the user is not authenticated, they are redirected to /auth/login.
GuestGuard
File:src/guards/authGuard/GuestGaurd.js
GuestGuard wraps authentication pages such as /auth/login and /auth/register. If an already-authenticated user visits one of these pages, they are redirected to the home route (/). This prevents logged-in users from accidentally accessing the login page.
PermissionGuard
File:src/guards/authGuard/PermissionGuard.js
PermissionGuard enforces fine-grained access control using the CASL ability from AbilityContext. It accepts an action and a subject prop. If the current user’s ability does not satisfy the check, they are redirected to /auth/permissions.
Permissions validator page
The route/auth/permissions is the access-denied landing page. Users are redirected here automatically by PermissionGuard when they attempt to access a route their role does not permit. The page informs the user they do not have the necessary permissions and provides a way to return to the dashboard.
Security best practices
- Use environment variables for all credentials. TMT reads them via
import.meta.env.VITE_*at build time. - Restrict Firebase security rules to prevent unauthorized reads and writes. The app-level guards prevent unauthenticated UI access, but Firestore and Storage rules are the authoritative enforcement layer.
- Scope Auth0 tokens to only the APIs and resources your application needs. Avoid requesting broad scopes.
- Validate on the server side. The
validateUserPlatformcloud function checks that a user’s Auth0 identity has a corresponding active account in Firestore before granting back-end access. - Re-authenticate before sensitive changes. The account security tab uses
reauthenticateWithCredentialfrom Firebase Auth before allowing a password change, reducing the risk of session hijacking.