Commit Graph

20 Commits

Author SHA1 Message Date
a40bfa61b6 Merge pull request 'fix/login-redirect-URL' (#439) from fix/login-redirect-URL into development
Reviewed-on: ADUANASOFT/anexo76#439
2026-05-22 14:24:02 +00:00
74282d446f fix(auth): corregir redirect_uri y KC URL con localhost en producción
- workspace-auth.ts: reemplaza isInternalOnlyHost por isDevOnlyUrl que
  incluye localhost/127.0.0.1 e IPs LAN además de hostnames Docker.
  getWorkspaceBaseUrl() y getPublicKeycloakBaseUrl() ya ignoran valores
  dev-only; no usan VITE_KEYCLOAK_URL=http://localhost:... en prod.

- Nuevo resolveSystemBaseUrl(): cuando url.origin es localhost porque
  ORIGIN env var apunta a localhost en producción, busca SITE_URL/APP_URL
  como fallback para construir redirect_uri seguros.

- buildKeycloakAuthorizationUrl() y buildKeycloakLoginUrl() usan
  resolveSystemBaseUrl() para el redirect_uri (evita localhost:5173).

- auth/callback/+page.server.ts: idem para el redirectUri del token exchange.

- auth.ts (cliente): resolveKeycloakUrl() detecta en runtime si
  VITE_KEYCLOAK_URL bakeado apunta a localhost pero el browser NO está
  en localhost → deriva la URL del hostname real del browser.

- .env.example: documenta vars de producción recomendadas (SITE_URL,
  ORIGIN, VITE_HUB_URL) con advertencias sobre el efecto de ORIGIN.

Root cause: el .env de dev (ORIGIN=http://localhost:5173,
VITE_KEYCLOAK_URL=http://localhost:8085/kcauth) se usaba en producción
sin sobrescribir estas variables, causando que KC generara URLs con
localhost como redirect_uri y KC URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 08:49:39 -05:00
02b3ae8334 Add permissions hydration handling to improve user experience and prevent access flash
- Introduced `permissionsHydrated` writable store to track if RBAC permissions are loaded for the active company.
- Added `markPermissionsHydrated` function to set the hydration state.
- Updated dashboard components to wait for permissions to be hydrated before rendering restricted content, enhancing user experience by avoiding "Access Denied" flashes.
- Refactored permission checks in `pedimento-permissions.ts` to consistently use `userHasPermission` for clarity and maintainability.
2026-05-15 17:32:08 -05:00
0ed350ca11 fix(auth): enhance logout and login flow with Keycloak integration and cookie management 2026-05-14 12:07:10 -05:00
fb89ed0569 Merge pull request 'feat: enhance user avatar handling and synchronization with Workspace' (#381) from feature/profile-photo into development
Reviewed-on: ADUANASOFT/anexo76#381
2026-05-08 22:34:06 +00:00
1dbc75107f feat: enhance user avatar handling and synchronization with Workspace
- Updated sidebar component to merge user data from Keycloak and Workspace, including avatar URLs.
- Refactored nav-user component to utilize new avatar resolution logic and display user information more effectively.
- Introduced a new utility function to resolve user avatar URLs, prioritizing Workspace avatars.
- Implemented backend changes to support synchronization of user profile data, including avatar URLs from Workspace.
- Added database migration to include new fields for Workspace profile synchronization in user_tenants.
- Created a new client for fetching user profiles from Workspace.
- Updated dashboard components to reflect changes in user data structure and avatar handling.
- Removed avatar upload functionality from the profile update process, relying on Workspace for avatar management.
- Added tests for avatar resolution logic to ensure correct prioritization of avatar sources.
2026-05-08 17:03:29 -05:00
97bb5c23b6 feature/permisos-keycloak-correccion 2026-05-04 13:22:18 -06:00
a5b378ccff refactor: centralize access token handling in cookies and improve related functions
- Introduced utility functions for managing access tokens in cookies, including setting, getting, and clearing tokens.
- Updated various components and server routes to utilize the new access token functions for better consistency and maintainability.
- Removed redundant cookie handling code across the application, streamlining the authentication process.
2026-05-01 21:30:52 -05:00
1d1d4b1619 Merge remote-tracking branch 'origin/development' into feature/hub-integration
# Conflicts:
#	backend/.env.example
#	backend/api/v1/modules/core/auth/service.py
#	backend/api/v1/modules/core/users/service.py
#	backend/core/middleware.py
#	docker-compose.yml
#	frontend/src/lib/auth.ts
#	frontend/src/lib/components/help/HelpDrawer.svelte
#	scripts/backend-entrypoint.sh
2026-04-29 13:11:44 -05:00
5c2a84e95d fix: solución de bloqueos y estandarización de permisos 2026-04-27 10:47:30 -05:00
225f020747 feat: Update authentication flow to unify logout process and improve Keycloak integration 2026-04-24 12:09:29 -05:00
b348be5ff3 feat(auth): implement session management and silent refresh for Keycloak
- Added session manager to handle token refresh and user activity tracking.
- Introduced session timeout warning dialog for user inactivity.
- Updated authentication token handling in cookies with security policies.
- Created server-side endpoint for silent refresh of access tokens using HttpOnly cookies.
- Added silent check SSO HTML page for Keycloak integration.
2026-03-05 08:13:19 -06:00
Galindo97
85ca22e574 feat: Implement dynamic backend URL configuration and streamline logout process by centralizing audit logging. 2026-02-11 16:22:03 -06:00
Galindo97
a594676de7 feat: Implement comprehensive audit logging for authentication events, including login, logout, user agent, and IP address, and add a script for audit verification. 2026-02-11 10:56:43 -06:00
52b8fcd434 feat: Implement multi-tenancy support in middleware and security layers
- Enhanced TenantMiddleware to validate tenant information from JWT tokens.
- Added LicenseValidationMiddleware to check tenant licenses before processing requests.
- Updated security utilities to extract tenant information from tokens and validate company access.
- Introduced CompanyStore to manage active company state and handle company switching in the frontend.
- Modified API routes to include company_id in requests for better resource management.
- Improved logging and error handling throughout the middleware and API layers.
- Updated frontend components to reflect changes in company management and selection.
- Added new API route for fetching user's companies with proper authentication handling.
2025-11-11 14:15:31 -06:00
206e81ef05 feat(auth): synchronize access token from cookies to localStorage if not present
refactor(dashboard): create dynamic columns for CodePedimentoRegimen with onSuccess callback

feat(dashboard): implement create, edit, and delete dialogs for CodePedimentoRegimen

feat(dialogs): add reusable dialog components for confirmation and details display

style(alert-dialog): improve styling and structure for alert dialog components

style(dialog): enhance styling and structure for dialog components
2025-11-02 14:20:30 -06:00
19472b840c refactor: Remove console logs and warnings from authentication and API handling 2025-11-02 13:53:29 -06:00
886a3aeab3 feat: Implement token refresh mechanism and infinite scroll for code pedimento regimens 2025-11-02 13:48:42 -06:00
73a535291a feat: implement sidebar components and authentication flow
- Added sidebar menu components including sidebar-menu-item, sidebar-menu-skeleton, sidebar-menu-sub-button, sidebar-menu-sub-item, sidebar-menu-sub, sidebar-menu, sidebar-provider, sidebar-rail, sidebar-separator, sidebar-trigger, and sidebar.
- Introduced skeleton loading states for sidebar items.
- Integrated tooltip components for enhanced user interaction.
- Developed mobile responsiveness using media queries.
- Established authentication flow with Keycloak, including login, logout, and token management.
- Implemented server-side redirection based on authentication status.
- Enhanced error handling and logging for authentication processes.
2025-11-01 20:04:43 -05:00
7adc90ac33 feat: implement authentication service with Keycloak and SSO support 2025-11-01 15:53:25 -05:00