Commit graph

39 commits

Author SHA1 Message Date
Chris
c2e9a1aa21
feat: Add OIDC/SSO authentication support (#1008)
* feat: add OIDC/SSO database schema and models (Phase 1)

Add database foundation for OpenID Connect authentication:

Database Migrations:
- Create oidc_identities table (links users to OIDC accounts)
- Create oidc_state_nonces table (OAuth state/nonce for CSRF protection)
- Create auth_audit_log table (security event logging)
- Make password_digest nullable in users table (allow OIDC-only users)

Models:
- OIDCIdentity: Links users to external OIDC providers
- OIDCStateNonce: Temporary OAuth state management
- AuthAuditLog: Authentication event audit trail

Changes:
- Updated User model to allow null password_digest
- Added model associations in models/index.js
- All migrations tested and verified

Related to #977

* feat: add OIDC core services (Phase 2)

- Install openid-client@^6.2.0 for OIDC protocol support
- Implement providerConfig.js for loading providers from .env
  - Support single provider or numbered providers (OIDC_PROVIDER_1_*, etc.)
  - Auto-provision and admin email domain configuration
  - Provider caching for performance
- Implement stateManager.js for OAuth state/nonce management
  - CSRF protection with 10-minute TTL
  - One-time use state consumption
  - Automatic cleanup of expired states
- Implement auditService.js for authentication event logging
  - Track login success/failure, logout, OIDC linking/unlinking
  - Store IP address, user agent, and metadata
  - Support for event queries and retention cleanup
- Add comprehensive unit tests (60 tests, all passing)
  - providerConfig: 36 tests for env parsing and validation
  - stateManager: 12 tests for state lifecycle and security
  - auditService: 12 tests for event logging and queries

Phase 2 completes the backend core services needed for OIDC authentication.

* feat: implement OIDC authentication flow (Phase 3)

Core OIDC Flow (service.js):
- Provider discovery with issuer caching
- Authorization URL generation with state/nonce
- OAuth callback handling and token exchange
- ID token validation using openid-client
- Token refresh functionality

JIT User Provisioning (provisioningService.js):
- Auto-create users from OIDC claims
- Link existing email accounts to OIDC identities
- Admin role assignment based on email domain rules
- Automatic username generation from email
- Transaction-safe identity creation

Identity Management (oidcIdentityService.js):
- List user's linked OIDC identities
- Link additional providers to existing accounts
- Unlink identities with safety checks
- Prevent unlinking last auth method
- Update identity claims on login

HTTP Layer (controller.js + routes.js):
- GET /api/oidc/providers - List configured providers
- GET /api/oidc/auth/:slug - Initiate OIDC flow
- GET /api/oidc/callback/:slug - Handle OAuth callback
- POST /api/oidc/link/:slug - Link provider to current user
- DELETE /api/oidc/unlink/:id - Unlink identity
- GET /api/oidc/identities - Get user's identities

Integration:
- Register OIDC routes in Express app (public + authenticated)
- Update auth service to reject password login for OIDC-only users
- Audit logging for all OIDC operations
- Session creation on successful authentication

Security:
- State/nonce CSRF protection
- One-time use state consumption
- Transaction-safe user provisioning
- Foreign key constraints enforced

* feat: implement OIDC frontend login flow (Phase 4)

- Created OIDCProviderButtons component for SSO login options
- Created OIDCCallback component for OAuth callback handling
- Updated Login page to fetch and display OIDC providers
- Added /auth/callback/:provider route to App.tsx
- Added i18n translations for OIDC UI elements
- Downgraded openid-client to v5.7.0 (CommonJS compatibility)
- Fixed linting issues in backend OIDC modules

Phase 4 completes the frontend login flow for OIDC/SSO authentication.
Users can now see configured SSO providers on the login page.

* feat: implement OIDC account linking UI (Phase 5)

Add Connected Accounts section to Profile Security tab allowing users to:
- View linked OIDC provider accounts
- Link new SSO providers to their account
- Unlink OIDC identities with validation
- Prevent unlinking last authentication method

Backend changes:
- Add has_password virtual field to User model
- Include has_password in profile API response
- Track whether user has password set for validation

Frontend changes:
- Create oidcService for OIDC API operations
- Create ConnectedAccounts component with link/unlink flows
- Add confirmation dialog before unlinking accounts
- Validate that users cannot unlink their last auth method
- Show warning if user has no password set
- Integrate Connected Accounts into SecurityTab

User experience:
- View all linked SSO provider accounts with email and link date
- Link additional providers via "Link Provider" buttons
- Unlink with two-step confirmation to prevent accidents
- Clear error messages when unlinking would leave no auth method
- Warning message suggesting password setup for OIDC-only users

Fixes #977

* feat: complete OIDC documentation and UI improvements (Phase 6)

This commit completes Phase 6 of the OIDC/SSO implementation with comprehensive
documentation, bug fixes, and UI reorganization.

Documentation:
- Add comprehensive user guide at docs/10-oidc-sso.md with:
  - Setup guides for 6 major providers (Google, Okta, Keycloak, Authentik, PocketID, Azure AD)
  - Configuration examples for single and multiple providers
  - User features documentation (login, account linking, management)
  - Advanced topics (auto-provisioning, admin role assignment, hybrid auth)
  - Comprehensive troubleshooting section
  - Security considerations and best practices
- Update README.md with OIDC/SSO section and quick setup examples

Internationalization:
- Add i18n support to OIDCProviderButtons component
- Add translation keys for all OIDC UI text
- Update English translations with "sign_in_with" key

Bug Fixes:
- Fix oidcService.ts to correctly unwrap API responses
  - Backend returns {providers: [...]} and {identities: [...]}
  - Frontend was expecting plain arrays, causing "map is not a function" error
- Fix initiateOIDCLink to properly handle POST response

UI Improvements:
- Move OIDC/SSO to dedicated tab in profile settings
  - Create new OIDCTab component with green LinkIcon
  - Remove ConnectedAccounts from SecurityTab
  - Add OIDC tab between Security and API Keys tabs
  - Update ProfileSettings with new tab configuration
- Security tab now focuses solely on password management

Testing:
- All linting passes
- All tests pass (82 suites, 1223 tests)

Related to #977

* feat: add OIDC/SSO translations for all 24 languages

Add i18n support for OIDC/SSO features across all supported languages:
- "Sign in with {{provider}}" button text
- "OIDC/SSO" tab label in profile settings
- OIDC authentication flow messages

Translations added for: Arabic, Bulgarian, Danish, German, Greek, Spanish,
Finnish, French, Indonesian, Italian, Japanese, Korean, Dutch, Norwegian,
Polish, Portuguese, Romanian, Russian, Slovenian, Swedish, Turkish,
Ukrainian, Vietnamese, and Chinese.

* fix: resolve 13 CodeQL security alerts

This commit addresses critical security vulnerabilities identified by CodeQL scanning:

**Security Configuration (2 fixes)**
- Fix insecure Helmet configuration - enable CSP and HSTS in production
- Fix clear text cookie transmission - enable secure cookies in production

**Path Injection (3 fixes)**
- Add path validation in users/controller.js to prevent arbitrary file deletion
- Add path validation in users/service.js for avatar operations
- Add path sanitization in attachment-utils.js deleteFileFromDisk function

**Cross-Site Scripting (1 fix)**
- Fix XSS vulnerability in GeneralTab.tsx avatar URL handling
- Add URL sanitization to prevent javascript: protocol attacks

**URL Security (2 fixes)**
- Fix double escaping in url/service.js HTML entity decoding
- Fix incomplete URL sanitization for YouTube domain validation

**Denial of Service (1 fix)**
- Add loop bound protection in inboxProcessingService.js (10k char limit)

**Rate Limiting (3 fixes)**
- Add rate limiting to auth routes (register, verify-email)
- Add rate limiting to task attachment upload/delete endpoints
- Add rate limiting to user avatar upload/delete endpoints

**GitHub Actions Security (1 fix)**
- Add explicit read-only permissions to CI workflow

Note: CSRF middleware (#10) requires frontend changes and is tracked separately.

Relates to PR #1008

* fix: allow test files in path validation for tests

* fix: format long condition in attachment-utils for Prettier compliance

Break the path validation condition across multiple lines to meet Prettier formatting requirements and fix CI linting failure.

* fix: resolve CodeQL security alerts

- Add rate limiting to OIDC authentication routes using authLimiter and authenticatedApiLimiter
- Implement CSRF protection middleware using csrf-sync (skips for API tokens and test environment)
- Add CSRF token endpoint at /api/csrf-token
- Fix incomplete URL scheme validation in GeneralTab to block all dangerous schemes (javascript:, data:, vbscript:, file:)

This addresses 5 high-severity CodeQL security vulnerabilities:
- Missing rate limiting on OIDC auth routes
- Missing CSRF middleware protection
- Incomplete URL sanitization in avatar handling

All 1223 tests passing.

* fix: implement CSRF protection with lusca for CodeQL compliance

Add CSRF protection using lusca.csrf (CodeQL's recommended library) to
protect session-based authentication while supporting hybrid auth patterns.

Implementation:
- Pre-check middleware marks exempt requests (test env, Bearer tokens)
- Lusca CSRF middleware applied with exemption flag check
- Session-based requests require valid x-csrf-token header
- Bearer token requests exempt (don't use cookies)
- Test environment exempt for test execution

This addresses CodeQL security alert js/missing-token-validation while
maintaining support for both cookie-based and token-based authentication.

Related: #977 (OIDC/SSO authentication feature)
2026-04-13 12:17:35 +03:00
Chris Veleris
31d0714296 Add translations 2026-01-22 18:04:10 +02:00
Chris
eee1bbc013
Fix bug 722 (#737)
* Fix project statuses

* Refactor project states

* Add translations
2025-12-28 07:51:15 +02:00
Chris
de65579afe
Fix long date names (#716) 2025-12-15 17:54:08 +02:00
Chris
269197e3db
Feat: habits (#707)
* Scaffold habits

* Fix today issues

* Fix buttons in taskitem

* Fix mobile layout

* Fix creation process

* Add to sidebar

* fixup! Add to sidebar

* fixup! fixup! Add to sidebar
2025-12-13 08:47:52 +02:00
Chris Veleris
5b5a0df8cf Update translations 2025-12-10 11:43:15 +02:00
Chris
7161504533
Fix profile settings mobile layout (#694)
* Fix profile settings mobile layout

* fixup! Fix profile settings mobile layout
2025-12-10 09:10:23 +02:00
Chris
b0b613f7bd
Reorder elements (#687)
* Reorder elements

* Enhance global search
2025-12-09 10:51:51 +02:00
Chris
bf281b740d
Feat backups (#686)
* Scaffold backups

* Add FFlags

* fixup! Add FFlags

* fixup! fixup! Add FFlags

* fixup! fixup! fixup! Add FFlags
2025-12-09 08:00:46 +02:00
Chris
79170bdac5
Improve Productivity Assistant title pluralization and wording (#683)
* Improve Productivity Assistant title pluralization and wording

Fixes #569

* fixup! Improve Productivity Assistant title pluralization and wording
2025-12-08 17:20:13 +02:00
Chris
1f26b524c1
Fix items to tasks (#681) 2025-12-08 12:39:08 +02:00
Chris
9665ba1f62
Feat refactor task details (#660)
* Move elements to tabs

* Add priority

* Fix priority

* Priority mobile fix

* fixup! Priority mobile fix

* fixup! fixup! Priority mobile fix

* fixup! fixup! fixup! Priority mobile fix

* fixup! fixup! fixup! fixup! Priority mobile fix
2025-12-06 09:41:58 +02:00
Chris
faf47efaca
Fix bump issues (#651)
* Add event for defer

* Fix recurrence form

* fixup! Fix recurrence form

* Refresh projects on banner change
2025-12-04 18:19:40 +02:00
Chris
61cf6aedeb
Fix tasks not updating (#649)
* Fix id usage

* fixup! Fix id usage

* Add overdue part in overview today section
2025-12-04 15:02:06 +02:00
Chris
e75a6e290e
Fix today summary (#645) 2025-12-04 07:58:03 +02:00
Chris
fcaf9a9a4d
Fix bug 613 (#638)
* Fix missing project meta

* fixup! Fix missing project meta

* fixup! fixup! Fix missing project meta

* fixup! fixup! fixup! Fix missing project meta
2025-12-03 12:58:24 +02:00
Chris
3ee20711da
Fix metrics button missing from mobile (#637) 2025-12-03 11:59:14 +02:00
Chris
be9b8915d5
Fix a tooltips issue in Project Details page (#636) 2025-12-03 08:52:28 +02:00
Chris
2d2a989a5f
Fix bug 619 (#629)
* Add tasks today plan fixes

* fixup! Add tasks today plan fixes

* fixup! fixup! Add tasks today plan fixes

* fixup! fixup! fixup! Add tasks today plan fixes
2025-12-02 18:00:36 +02:00
Chris
08c23d2f96
Fix today pagination (#596)
* fixup! Feat notifications (#594)

* Add pagination to today

* Add defer to search

* fixup! Add defer to search

* Add preuploaded banners

* fixup! Add preuploaded banners

* Fix project banner

* fixup! Fix project banner

* fixup! fixup! Fix project banner
2025-11-26 23:00:50 +02:00
Chris
75a1e68730
Tc refactor pt1 (#589)
* Refactor ProfileSettings

* Cleanup comments

* Refactor TaskDetails

* Refactor InboxModal

* fixup! Refactor InboxModal

* Fix project layout

* Add visuals to project details

* Refactor projectdetails

* Remake project metrics

* Complete project details refactor

* Fix note issues and enhance view

* Add filters

* Fix project tasks filters

* Add filters to task lists

* Add filters to task lists

* fixup! Add filters to task lists
2025-11-23 21:48:49 +02:00
Chris
8dc6194c80
Feat improve task details (#585)
* Fix project section

* Add project and tags sections

* Enhance task details page and add translations

* Enhance Task Details page

* Enhance project details page

* Note details page fix

* Enhance Views Tags Search

* Search enhancements

* fixup! Search enhancements
2025-11-21 18:43:10 +02:00
Chris
c3bf5f5522
Feat add profile photo (#580)
* Add profile photo support

* Add translations

* fixup! Add translations
2025-11-19 09:00:58 +02:00
Chris
49d22789e7
Feat add recurring search (#579)
* Add recurring tasks in search

* fixup! Add recurring tasks in search

* fixup! fixup! Add recurring tasks in search
2025-11-18 20:35:50 +02:00
Chris
b8c46e1d0d
Set verification modal on escape (#470) (#473)
* fixup! Fix priority auto (#470)

* Add translations
2025-11-03 16:27:13 +02:00
Chris
02b493d61f
Universal search (#412)
* Global search scaffold

* Add search preview text

* Add generic fallback for preview text in search

* fixup! Add generic fallback for preview text in search

* Add more tweaks

* fixup! Add more tweaks

* Fix an issue with criteria

* fixup! Fix an issue with criteria

* fixup! fixup! Fix an issue with criteria

* fixup! fixup! fixup! Fix an issue with criteria

* Fix an issue with priority filter

* fixup! Fix an issue with priority filter

* Add sortable pins

* fixup! Add sortable pins

* Make options collapsed by default

* Tweak UI

* Add tests

* Add translations

* Add more translations

* fixup! Add more translations

* Add minor tweaks
2025-10-22 22:00:45 +03:00
Chris Veleris
7178f3dccb Add user edit 2025-10-15 16:48:03 +03:00
Chris Veleris
2cd7d9abe4 Add translations 2025-10-15 13:05:57 +03:00
Chris
9d2b1895af
Feat/add project states (#354)
* Scaffold project states

* fixup! Scaffold project states

* Fix blinking project modal

* fixup! Fix blinking project modal

* fixup! fixup! Fix blinking project modal

* Fix an issue with the tag input autosuggest

* fixup! Fix an issue with the tag input autosuggest

* fixup! fixup! Fix an issue with the tag input autosuggest

* Add state to project details

* fixup! Add state to project details

* Add state indicator on project cards

* fixup! Add state indicator on project cards
2025-09-29 16:04:25 +03:00
Chris
c237d71ccb
Add inbox pagination (#340)
* Bump version

* Bump version

* Scaffold inbox pagination

* fixup! Scaffold inbox pagination
2025-09-19 16:07:50 +03:00
Chris
fcbccbc838 Feat add first day of week (#339)
* Add setup for first day of week

* Add full weekdays

* fixup! Add full weekdays
2025-09-18 12:57:28 +03:00
Chris
568613151b Fix delete note refresh (#337)
* Remove note from store when deleting

* fixup! Remove note from store when deleting

* Fix note deletion issues

* fixup! Fix note deletion issues

* Add translations
2025-09-18 12:57:28 +03:00
Chris Veleris
58440d3c10 Add missing translations 2025-08-18 12:25:12 +03:00
Chris Veleris
e081ed622a Update translations 2025-08-04 23:50:53 +03:00
Chris Veleris
e590fec7aa Fix layout view in today 2025-08-04 23:50:53 +03:00
Chris Veleris
6e9dd9e6f0 Add missing translations and fix an issue with duplicate toasters 2025-07-15 10:44:02 +03:00
Chris Veleris
1c21dab55d Add more translations 2025-07-15 10:44:02 +03:00
Chris Veleris
06b9edd566 Add more translations 2025-07-15 10:44:01 +03:00
Chris Veleris
8e7f25b3a6 Add multilanguage support 2025-07-15 10:44:01 +03:00