Commit graph

44 commits

Author SHA1 Message Date
c7df6a8569
Add CI-triggered mass agent update webhook
POST /api/v1/webhooks/agent-release triggers all connected agents
to self-update via their existing WebSocket channels. Authenticated
with a shared secret (AGENT_WEBHOOK_SECRET env var).

- Add ReleaseChecker.invalidate_cache/0 for fresh GitHub fetch
- Add Agents.list_updatable_agents/0 (enabled + seen < 10min)
- Add Agents.broadcast_mass_update/0 orchestration function
- Add WebhookAuth plug with timing-safe secret comparison
- Add AgentReleaseWebhookController with :webhook pipeline
- Configure AGENT_WEBHOOK_SECRET in dev/test/runtime configs
2026-02-10 13:40:32 -06:00
2911a3c17d
test fixes 2026-02-09 15:30:52 -06:00
3931a9c14a
more tests and fixes 2026-02-07 11:50:18 -06:00
8ee39a2d36
Add comprehensive tests for API authentication and authorization
Implemented tests for critical security modules with significant coverage improvements:
- ApiAuth plug: 0% → 100% (12 tests)
- Permissions module: 0% → 85% (32 tests)
- Devices API controller: 0% → 95% (22 tests)

Enhanced test fixtures to support membership roles and device creation with proper organization scoping.
2026-02-05 16:39:01 -06:00
8382b5df6a
make devices site optional and many test fix 2026-02-04 15:05:42 -06:00
3276a1cd8c
fix user session controller test
Update email input ID assertion to match actual template implementation
2026-02-03 13:42:24 -06:00
bd6dad85e1
purge more passkey and gettext updates 2026-02-02 10:20:59 -06:00
6c8e670dae
docs: add gettext internationalization design
- Add comprehensive i18n design document with domain-based organization
  (default, errors, auth, equipment, admin, emails domains)
- Document helper functions, implementation patterns, and migration workflow
- Fix multiple test suite issues:
  * user_settings_live_test.exs: Update all tests to match current UI structure
    - Fix user.name references (use first_name/last_name)
    - Fix TOTP device creation (use create_totp_device/2)
    - Update tab URLs and form IDs
    - Update tab names (Account, API, Notifications)
    - Remove obsolete tabs (Organizations, Activity)
    - Fix password tests (pattern match redirect without flash token)
    - Update sudo mode behavior
  * account_data_controller_test.exs: Fix user profile assertions
  * rate_limit_test.exs: Fix unused variable warning
  * settings_live_test.exs: Fix organization form validation test
2026-02-02 09:33:01 -06:00
9ff9c4ddc8
fix: address UserSudoController critical issues
Critical fixes:
- Renamed controller actions to follow Phoenix conventions (verify→new, create→verify)
- Added sudo mode check in GET action using last_sudo_at timestamp
- Added TOTP enrollment check in GET action with redirect
- Changed default return path from /orgs to /users/settings
- Updated route paths from /users/sudo/verify to /users/sudo-verify (dash separator)
- Added success flash message "Identity verified."

Implementation details:
- new/2 (GET): Checks recently_verified_sudo?/1 helper that examines last_sudo_at
  instead of authenticated_at to distinguish sudo verification from regular login
- verify/2 (POST): Adds info flash and defaults to /users/settings
- recently_verified_sudo?/1: Private helper checking last_sudo_at within 10 minutes
- Updated all routes, templates, and tests to use new paths and action names

Tests:
- Added tests for already-in-sudo-mode redirect behavior
- Added test for TOTP enrollment requirement
- Updated all test assertions for new route paths and success messages
- All 15 controller tests passing
- Full test suite passing (4076 tests, 0 failures)
2026-02-01 14:45:05 -06:00
264154a3d8
feat: implement sudo mode MFA-only verification controller
- Add UserSudoController with GET and POST /users/sudo/verify routes
- Create verify.html.heex template for TOTP verification form
- Only accept TOTP codes (6 numeric digits), reject recovery codes
- Update grant_sudo_mode to set authenticated_at virtual field
- Exclude /users/sudo paths from return_to overwriting
- Add comprehensive controller tests (12 test cases)
- Verify redirect behavior, error handling, and session management

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 14:34:17 -06:00
feed25080c
add HIBP password check 2026-02-01 08:57:01 -06:00
2fab08f5f8
forgot password flow 2026-01-31 17:03:22 -06:00
dff9c26905
fix TOTP enrollment with recovery codes 2026-01-31 14:54:44 -06:00
3c00dcf37c remove passkeys for now 2026-01-31 09:50:35 -06:00
22ae257b60 refactor 2026-01-31 09:35:07 -06:00
2a36917738 mfa enforced on login 2026-01-29 14:31:13 -06:00
c0736d4c2e gdpr consent tracking 2026-01-29 11:12:35 -06:00
d29fb8cfd7 totp fixes 2026-01-28 16:16:59 -06:00
1f6151b5a8 filter snmp communities from log 2026-01-28 14:51:47 -06:00
a0ba9285dd
bring in snmpkit 2026-01-23 12:52:17 -06:00
3abd70e133
use password for user regi 2026-01-21 09:13:08 -06:00
eb91798729
agent improvements and agent config 2026-01-16 17:26:51 -06:00
7068ab2466
Convert User Settings from controller to LiveView
- Create UserSettingsLive to replace UserSettingsController
- Convert email/password forms to LiveView with proper form handling
- Add mobile session management (toggle alerts, revoke devices)
- Add require_sudo_mode on_mount hook to UserAuth
- Create dedicated live_session for sudo mode routes in router
- Keep UserSettingsController for email confirmation via token only
- Add MobileSessions.get_session/1 function for test support
- Update tests to match LiveView behavior (password update redirects to login)
- Remove old controller tests for email/password updates (now in LiveView)
2026-01-15 16:29:50 -06:00
0ea2addc91
Fix Bandit configuration and user settings HTML test
Bandit 1.10.1 does not support read_timeout/write_timeout in http_1_options
or stream_idle_timeout in http_2_options. These invalid options caused the
application to crash on startup with 'Unsupported key(s) in http_1_options'.

Moved read_timeout to thousand_island_options where it belongs, and removed
the unsupported write_timeout and stream_idle_timeout options.

Also fixed UserSettingsHTMLTest to include the missing mobile_sessions assign
that is required by the edit.html.heex template.
2026-01-15 16:06:01 -06:00
8442d9e1fc
update liveview 2026-01-14 13:54:48 -06:00
a2d96f8e6e
Implement hierarchical agent assignment for SNMP polling
Add three-level agent assignment hierarchy (Equipment > Site > Organization)
allowing flexible agent deployment strategies. Agents now receive only equipment
assigned to them through direct assignment or inheritance from site/organization
defaults.

Key changes:
- Add agent_token_id to Sites table with migration
- Implement get_effective_agent_token/1 for hierarchical resolution
- Add list_agent_polling_targets/1 to return polling targets per agent
- Update API config endpoint to use hierarchical polling targets
- Add agent assignment UI to equipment, site, and organization forms
- Show agent source (direct/site/org/none) in equipment form
- Add equipment count column to agent list
- Update terminology from "poll from server" to "cloud polling"

Tests:
- Add 8 comprehensive tests for list_agent_polling_targets/1
- Add end-to-end test for hierarchical config endpoint
- All 775 tests passing
2026-01-14 08:38:50 -06:00
3eb95b5f90
Streamline login flow and fix test failures
Login flow improvements:
- Remove "Welcome back!" flash message on successful login
- Auto-login users clicking magic links without confirmation prompt
- Always use "remember me" for magic link logins
- Fix Accounts.login_user_by_magic_link/1 to handle invalid token format

Test fixes:
- Add @tag :integration to Ping tests (require actual system ping)
- Add halt() calls to UserAuth.start_impersonation error paths

Users now go directly to their intended destination after clicking a
magic link, with no interruption for "log in and stay logged in" choice.
2026-01-13 13:08:24 -06:00
11bc5dec4a
no post login page 2026-01-13 12:27:17 -06:00
8291c6092a
Add comprehensive AgentController edge case tests
Added 6 new tests covering previously untested scenarios:
- Equipment without SNMP device (nil sensors/interfaces)
- Protobuf metrics with unknown types
- JSON metrics with unknown types
- Metrics with nil timestamps
- Metrics with invalid ISO8601 timestamp strings

Coverage increased from 90.41% to near 100%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 08:37:58 -06:00
f0af777f6e
Add tests for UserSettingsHTML
Added 2 tests covering the edit.html settings form template:
- Settings form rendering with email, password, and passkeys sections
- Warning message when user cannot register passkey

This improves UserSettingsHTML coverage from 0% to 100%.
2026-01-13 07:52:46 -06:00
a430d09668
Add test for UserRegistrationHTML
Added test to cover the new.html registration form template.

This improves UserRegistrationHTML coverage from 0% to 100%.
2026-01-13 07:52:06 -06:00
29c8e1a8d3
Add comprehensive tests for UserSessionHTML
Added 5 tests covering both new.html and confirm.html templates:
- Login form rendering with multiple authentication methods
- Reauthentication message display
- Confirmation form for unconfirmed users
- Login form for confirmed users
- Simplified login for reauthentication with current_scope

This improves UserSessionHTML coverage from 50.00% to 100%.
2026-01-13 07:50:39 -06:00
89b038a14f
Add test for PageHTML home template
Added test to cover the home.html template rendering.

This improves PageHTML coverage from 0% to 100%.
2026-01-13 07:49:25 -06:00
6e02dc460a
Add test for ErrorHTML fallback render function
Added test to cover the fallback render/2 function that handles
error codes without custom templates (401, 403, 503, etc.).

This improves ErrorHTML coverage from 0% to 100%.
2026-01-13 07:48:23 -06:00
160007cab1
Add HealthController test (0% → 100%) 2026-01-13 07:39:28 -06:00
7cf3e61709
Add comprehensive tests for EquipmentLive.Form and UserCredentialController
- EquipmentLive.Form: 46.73% → 92.52% (+45.79%)
  - Added 27 tests covering form validation, SNMP testing, site selection
  - Tests mount behavior, save/update flows, deletion, and discovery triggers
  - Tests SNMP config changes and agent assignment

- UserCredentialController: 33.93% → 64.29% (+30.36%)
  - Added 7 tests for WebAuthn registration and authentication flows
  - Tests challenge generation, credential registration, and error cases
  - Tests discoverable authentication and account-specific auth

Overall coverage: 60.40% → 63.67% (+3.27%)
2026-01-12 18:46:15 -06:00
3ef04f261f
protobufs 2026-01-09 17:33:01 -06:00
cf77949527
add remote agent setup 2026-01-09 13:15:31 -06:00
4f924ba9a7
add passkey 2026-01-09 12:26:32 -06:00
41dcf3084f
add error pages 2026-01-06 14:37:48 -06:00
3b9fffdd07
add marketing site 2026-01-06 14:34:48 -06:00
93e0b869be
more features 2026-01-02 14:06:44 -06:00
c52f313e2d
1. User Authentication
- Full auth system with email/password (using phx.gen.auth)
  - Login, registration, password reset
  - Session management with remember-me functionality
  - Magic link login support

  2. Organization Management
  - Multi-tenant organization system
  - Organizations schema with unique slugs
  - Automatic organization creation when users register
  - Organization switcher UI at /orgs

  3. Membership System
  - Users can belong to multiple organizations
  - 4 permission levels: Owner, Admin, Member, Viewer
  - Complete permission matrix implemented
  - Join/leave organizations

  4. Invitation System
  - Email-based invitations with secure tokens
  - 7-day expiration on invites
  - Track who invited and who accepted

  5. Authorization
  - Full policy system (Organizations.Policy)
  - can?(membership, :action, :resource) helper
  - Enforced via plugs in router

  6. LiveView Pages
  - /orgs - List all your organizations
  - /orgs/new - Create new organization
  - /orgs/:slug - Organization dashboard (placeholder)

  7. Database Schema
  - users table
  - organizations table
  - organization_memberships table
  - organization_invitations table
  - All migrations run successfully
2025-12-21 13:31:59 -06:00
ba463dc5a2
init 2025-12-21 11:10:43 -06:00