feat: add SSO authentication (Azure / Google / Cloudflare Access) and opt-in TOTP 2FA (#778)
* feat: add SSO authentication and TOTP two-factor authentication SSO Providers: - Azure Entra ID (OAuth2 + OIDC, RS256 JWT validation, JWKS caching) - Google OAuth2/OIDC (RS256 JWT validation, JWKS caching) - Cloudflare Access (JWT assertion validation) Security: - Stateless HMAC-signed OAuth2 state tokens (multi-worker safe) - Email allowlist — only pre-approved addresses can authenticate via SSO - Auto-provisioning of SSO users with configurable role assignment - JWT_SECRET moved to environment variable (was hardcoded) - Dedicated SSO_STATE_SECRET and TOTP_ENCRYPTION_KEY (backward compatible) Two-Factor Authentication (TOTP): - RFC 6238 TOTP with QR code enrollment flow - Fernet-encrypted TOTP secrets at rest - 8 single-use backup codes per user - 2FA is opt-in per user — only enforced for accounts where enrollment has been completed DB migrations (Alembic, non-destructive, additive only): - sso_config + sso_allowed_emails tables - Google SSO fields on existing SSO config - user_totp table All changes are backward compatible — existing deployments require no configuration changes to continue working. * fix: add Alembic merge migration to resolve SSO/upstream head conflict * fix: register SSO and TOTP API endpoints in frontend api/index.ts * feat: add documentation for Single Sign-On (SSO) and Two-Factor Authentication (2FA) * precommit fixes * feat: add Office 365 summary and cloud integration dashboard templates * Add new dashboard templates for Office 365 integrations - Introduced O365_DEFENDER_FOR_IDENTITY.json for Microsoft Defender for Identity alerts and events. - Added O365_DLP.json for Data Loss Prevention policy events and metrics. - Created O365_ENDPOINT.json for Microsoft Defender for Endpoint activity monitoring. - Implemented O365_EXCHANGE.json for Exchange Online activity tracking. - Developed O365_FORMS.json for Microsoft Forms activity insights. - Added O365_MITRE.json for MITRE ATT&CK enrichment across Office 365 workloads. - Created O365_ONEDRIVE.json for OneDrive for Business activity analysis. - Implemented O365_POWERBI.json for Power BI activity monitoring. - Developed O365_SHAREPOINT.json for SharePoint Online activity tracking. - Added O365_TEAMS.json for Microsoft Teams activity insights. - Created O365_THREAT_INTELLIGENCE.json for threat intelligence monitoring in Office 365. * feat: integrate 2FA support into SSO and refactor authentication flow - Centralize 2FA verification logic within the auth store - Extract SSO provider handling to a dedicated helper module - Update API endpoint interfaces to handle 2FA requirements and standard base responses - Unify TOTP and backup code validation paths in the sign-in component * feat: extract SSO logic and UI into a dedicated component - Move SSO provider buttons and authentication handling from `SignIn.vue` to `SsoOptions.vue` - Relocate SSO callback URL parsing and token extraction logic to the new component - Simplify the main sign-in flow by using events to handle 2FA triggers and successful logins - Remove the redundant `sso.ts` helper module as logic is now encapsulated within the component * feat: improve 2FA transition and refine SSO provider UI - Wrap TOTP verification step in a collapse transition to smoothly toggle with backup code input - Simplify SSO provider button rendering by replacing individual transitions with conditional rendering - Update SSO provider labels to "Microsoft Azure" and "Google Cloud" - Ensure SSO section visibility logic consistently returns a boolean value * feat: enhance error handling in SSO callbacks with redirects * feat: extract TOTP verification into a dedicated component - Move 2FA and backup code logic from `SignIn.vue` to the new `TotpForm.vue` component - Replace the standard text input with `n-input-otp` for a specialized 2FA entry experience - Simplify the main sign-in flow by delegating multi-factor authentication states and validation to the sub-component * feat: improve SSO error handling and refine provider UI - Handle and display error messages passed via URL from SSO callbacks - Update Google provider branding by changing the label and icon - Migrate URL parameter processing to the `onBeforeMount` hook for earlier detection and cleaner URL state management * feat: implement user resolution for SSO login and enhance error handling in Cloudflare authentication * feat: enable allowedHosts configuration in Vite server settings * feat: add SentinelOne routes to Stack Provisioning * feat: improve SSO configuration UI and user management layout - Increase Tag RBAC settings modal width for better visibility. - Reformat Azure, Google, and Cloudflare setup instructions using utility classes to improve readability. - Clean up unused component references and remove deprecated custom styles. - Add a TODO for transitioning tag assignments to a modal-based flow. * feat: extract SSO allowlist and configuration into dedicated components - Modularize SSO email allowlisting into a standalone `AllowedEmails.vue` component. - Relocate SSO provider settings from the main user management view to a separate `Config.vue` component. - Refactor `Users.vue` to act as a clean layout container for user listing and access control management. - Improve table styling and UI consistency across user management views. * feat: add dedicated route and navigation for SSO configuration - Register a new `/sso-config` route and create a corresponding view. - Add an "SSO Config" entry to the user avatar toolbar menu for easier access. - Adjust the SSO configuration form layout by removing fixed width constraints. * feat: add navigation link to SSO configuration from allowed emails view - Add an "SSO Configuration" button to the `AllowedEmails` component header to facilitate navigation between SSO settings. - Implement a new `routeSSOConfig` helper in the `useNavigation` composable. * feat: extract TOTP 2FA management into a dedicated component - Relocate 2FA setup, verification, and management logic from the Profile view to a new `TotpToggle` component. - Refactor the Profile page to use a tabbed interface, separating general settings from security options. - Improve the 2FA setup experience with dedicated OTP input handling and better backup code display. * feat: extract 2FA backup codes into a dedicated component - Create `BackupCodesPanel` to centralize the logic for displaying, copying, and downloading backup codes. - Refactor `TotpToggle` to use the new component, reducing boilerplate and improving maintainability. - Ensure consistent styling and behavior for backup code presentation across setup and regeneration flows. * feat: reorganize profile security and refactor change password component - Create a card-based `ChangePassword` wrapper component for the profile security tab. - Move the change password functionality from the profile header to the dedicated security section. - Refactor the base `ChangePassword` component to support dynamic styling and button types, maintaining consistent behavior in the user management list. * feat: restrict SSO configuration menu access to administrators - Conditionally render the "SSO Config" entry in the avatar toolbar based on the user's admin status. - Ensure administrative configuration links are hidden from regular users to prevent unauthorized access attempts and improve UI clarity. * feat: clarify SSO login behavior and allowed emails usage - Update the instructional text in the `AllowedEmails` component to specify that existing users are automatically enabled for SSO. - Clarify that the allowed emails list is primarily for permitting new users to sign in and create accounts. * precommit-fixes --------- Co-authored-by: Maciek <maciek@Mac.lan> Co-authored-by: taylorwalton <taylor.walton@socfortress.co> Co-authored-by: Davide Di Modica <webmaster.ddm@gmail.com>