Skip to content

Push notification 2fa#167

Merged
cmyers-mieweb merged 13 commits intomainfrom
push-notification-2fa
Jan 23, 2026
Merged

Push notification 2fa#167
cmyers-mieweb merged 13 commits intomainfrom
push-notification-2fa

Conversation

@runleveldev
Copy link
Copy Markdown
Collaborator

@runleveldev runleveldev commented Jan 20, 2026

This pull request introduces several new features and improvements related to authentication, security, and user interface styling. The most significant changes include the addition of API key authentication, support for password reset tokens, a flexible settings system, and a refreshed sidebar and navigation style.

Authentication and Security Enhancements:

  • Added support for API key authentication in the requireAuth middleware, allowing users to authenticate using a Bearer token in the Authorization header. This includes key validation, user association, admin detection, and usage tracking.
  • Introduced the ApiKey Sequelize model with methods for key validation and usage recording, and created the corresponding database migration for the ApiKeys table, including indexes for performance. [1] [2]
  • Implemented password reset functionality with the PasswordResetToken model, including secure token generation, validation, and cleanup logic, and added a migration for the PasswordResetTokens table. [1] [2]
  • Added a setPassword method to the User model to support secure password updates.

Settings Infrastructure:

  • Added a Setting model for application-wide key-value settings, with helper methods to get/set settings and batch retrieval, and created a migration for the Settings table. [1] [2]
  • Added a migration to insert default SMTP-related settings for email functionality.

User Interface Updates:

  • Refreshed sidebar and navigation styles in style.css for improved appearance, mobile responsiveness, and accessibility, including updates to sidebar colors, spacing, and active states. [1] [2] [3]

Other:

  • Minor refactor to the module exports in the middlewares/index.js file for improved readability.

- Add Setting model for key-value configuration storage
- Create migration and seeder for push notification settings
- Add admin-only /settings route for configuring push notifications
- Integrate push notification 2FA into login flow
  - Check if push notifications are enabled
  - Send notification to external service
  - Wait for user approval (case-insensitive)
  - Handle no-device-found errors with registration link
- Update ldap.conf generation to include AUTH_BACKENDS and NOTIFICATION_URL
- Add Settings link to admin sidebar navigation
- Update database schema documentation
- Create new Settings admin documentation page with screenshot
- Document push notification 2FA configuration and workflow
- Update system architecture diagram to include Push Notification Service
- Add detailed authentication flow with 2FA sequence diagram
- Include link to MieWeb Auth App repository
- Update admin index to reference System Settings
- Add ApiKey database model with argon2 hashing and prefix storage
- Create database migration with indexes for performance
- Implement cryptographic key generation (256-bit entropy)
- Add requireApiKey middleware for Bearer token authentication
- Build complete CRUD routes at /apikeys endpoint
- Create responsive UI with mobile card view and desktop table view
- Add one-time key display with copy-to-clipboard functionality
- Refactor layout with fixed top navbar and collapsible sidebar
- Optimize sidebar width (200-250px auto) and eliminate extra scrolling
- Add Bootstrap Icons for improved visual design
- Include usage examples with curl commands

Security features:
- Keys hashed with argon2 (never stored in plain text)
- First 8 characters stored as prefix for efficient lookup
- Keys shown only once at creation
- Last usage timestamp tracking
- Per-user key management (non-admin access)

UI improvements:
- Fixed navbar at top with hamburger menu for mobile
- Sidebar collapses properly on mobile viewports
- Breadcrumbs left-aligned in navbar
- Responsive card/table dual layout pattern
- Proper text wrapping for long strings (keys, UUIDs)
- Clean spacing and no layout overflow issues
- Remove bi-key icon from API Keys sidebar entry for consistency
- Update requireAuth middleware to accept both session and API key auth
- Remove redundant requireApiKey middleware to eliminate duplication
- API key authentication now handled uniformly through requireAuth
@runleveldev runleveldev force-pushed the push-notification-2fa branch from c9eb1d7 to 6db74ac Compare January 22, 2026 15:51
Routes were checking req.session.user and req.session.isAdmin, but API key
authentication only set req.user and req.isAdmin. This caused routes to fail
with 'username undefined' errors when using API keys.

Updated requireAuth middleware to populate req.session properties when
authenticating via API key, ensuring full compatibility with existing routes.
- Add new api-keys.mdx documentation page with complete guide on:
  - Creating and managing API keys
  - Security best practices
  - Usage examples with curl
  - Comparison with session-based authentication
  - Troubleshooting common issues

- Update command-line.mdx to reference API keys as recommended auth method

- Include 5 screenshots showing:
  - Empty API keys list
  - Create API key form
  - Success page with one-time key display
  - API keys list with created key
  - API key details page

- Position API keys doc between web UI and command-line docs (sidebar_position: 3)
- Remove all references to session cookies and cookie-based authentication
- API keys are now the only documented authentication method for API usage
- Update all curl examples to use Authorization: Bearer header
- Simplify authentication section to focus solely on API keys
- Update prerequisites to require API key
- Renumber sections after removing cookie authentication steps
- Update troubleshooting section to remove cookie-related issues
- Remove usage examples and instructions from all API key views
- Keep only essential field descriptions and warnings
- All documentation and examples now live in the documentation site
- Views are now focused on the UI functionality only
- Remove screenshots showing usage examples and instructions
- Capture updated views with only essential information
- Screenshots now match the cleaned-up UI without embedded documentation
@runleveldev runleveldev force-pushed the push-notification-2fa branch from 6db74ac to a9d43bd Compare January 22, 2026 16:32
- Add PasswordResetToken model with token generation, validation, and cleanup
- Create password reset router with full workflow (request → email → reset)
- Add email utility with SMTP URL parsing and sendPasswordResetEmail
- Create password reset views (request form, reset form)
- Add setPassword method to User model for secure password updates
- Update login page with 'Forgot your password?' link
- Add SMTP configuration to settings page (smtp_url, smtp_noreply_address)
- Create migrations for PasswordResetTokens table and SMTP settings
- Implement 1-hour token expiration with crypto.randomBytes for security
- Add Email Configuration section with SMTP setup instructions
- Document password reset flow and requirements
- Update settings page screenshot showing SMTP fields
- Include example SMTP URL formats and security options
- Add warnings about SMTP configuration requirements
Copy link
Copy Markdown
Collaborator

@cmyers-mieweb cmyers-mieweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, currently in use in production

@cmyers-mieweb cmyers-mieweb merged commit c424eee into main Jan 23, 2026
4 checks passed
@cmyers-mieweb cmyers-mieweb deleted the push-notification-2fa branch January 23, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate Push Notification server for LDAP and WebUI authentication

2 participants