ICP System uses JWT Bearer token authentication. Learn how login works, where the token is stored, and how sessions expire.
ICP System authenticates users with JSON Web Tokens (JWT). You POST your credentials to the login endpoint, receive an access_token, and that token is automatically attached to every subsequent API request as a Bearer header.
The token is persisted in localStorage using the key access_token. A request interceptor reads it before every outgoing request and injects it as an Authorization header:
You do not need to manage headers manually — every call made through the shared http Axios instance includes the token automatically.
The access token is stored in localStorage, not in an httpOnly cookie. This means it is accessible to JavaScript running on the page. Ensure your deployment uses HTTPS and apply appropriate Content Security Policy headers to reduce exposure to XSS attacks.
A response interceptor watches every API response for a 401 Unauthorized status. When a 401 is received — for example because the token has expired or been invalidated — the interceptor:
Removes the token from localStorage (clearAccessToken())
Redirects the browser to /login via window.location.href
Any in-flight navigation or unsaved form data will be lost when this redirect fires. Users are returned to the login page where they can authenticate again.
All routes except /login are wrapped in RequireAuth. This component checks for the presence of access_token in localStorage before rendering any protected content. If no token is found, the user is redirected to /login and the originally requested path is preserved in router state so the app can redirect back after a successful login.
Pass the user’s roles array and one or more allowed role strings. The function returns true if the user holds at least one of the allowed roles.
// Example: restrict a UI element to ADMIN onlyif (hasRole(user.roles, "ADMIN")) { // show admin controls}// Example: allow ADMIN or OPERADORif (hasRole(user.roles, "ADMIN", "OPERADOR")) { // show import button}
Role assignment is managed through the backend. See Users & roles for instructions on creating accounts and assigning roles via the Users page (/usuarios).