Commit graph

76 commits

Author SHA1 Message Date
Johan Lundberg
a65af90320
feat: require current password when changing password, add zxcvbn strength check
Use PasswordChange model (requires current password) for users with
existing passwords and PasswordSet for first-time setup. Add zxcvbn
strength validation and current password field to credentials template.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 15:34:43 +02:00
Johan Lundberg
72a93984f2
feat: wire validation models into admin routes and deduplicate error handling
Replace manual validation error formatting with shared helper in both
admin and manage profile routes. Add UsernameInput validation to invite
route and GroupListInput validation to groups route.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 15:34:28 +02:00
Johan Lundberg
d4acb46cf5
feat: add rate limiting middleware for authentication endpoints
Add slowapi-based rate limiting: 5/min on password login, 10/min on
WebAuthn login. Includes shared rate limiter reset fixture for tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 15:23:51 +02:00
Johan Lundberg
23ca6272a2
fix: block inactive users from all authentication paths
Add active-user checks to password login, WebAuthn login, and magic
link registration to prevent deactivated accounts from authenticating.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 15:18:51 +02:00
Johan Lundberg
aff6ddb99b
feat: add validation models (locale, username, groups, password) and error helper
Add BCP 47 locale validator to ProfileUpdate, UsernameInput model,
GroupListInput model, PasswordSet/PasswordChange with zxcvbn strength
checking, and shared format_validation_errors HTML helper.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 15:18:24 +02:00
Johan Lundberg
2dfa3f3bff
test: add profile validation e2e tests and fix pre-existing failures
Add 7 new e2e tests verifying profile form validation in both manage
and admin UIs: invalid phone number, phone normalization, E.164 hint
attributes, and admin-side email/phone/picture URL validation errors.

Fix 3 pre-existing test failures:
- Replace invalid seeded phone number (+1234567890) with valid E.164
  (+12025551234) that was causing profile update tests to fail
- Update email validation error assertion to match actual pydantic
  message (value_error type uses raw message, not label-prefixed)
2026-03-16 10:00:46 +01:00
Johan Lundberg
7bfea306ab
refactor: use shared ProfileUpdate validation in admin routes 2026-03-13 20:43:52 +01:00
Johan Lundberg
5fd63d61ff
feat: wire ProfileUpdate validation into manage profile route 2026-03-10 15:36:47 +01:00
Johan Lundberg
3cbf7cda5f
test: add e2e tests for logout buttons in admin and manage nav bars 2026-03-10 10:50:44 +01:00
Johan Lundberg
7c9e426bb8
feat: add ProfileUpdate pydantic model with email and phone validation 2026-02-20 15:21:28 +01:00
Johan Lundberg
0435b81c5a
feat: add landing page at / with navigation links
Route GET / to a landing page with the Porchlight logo, tagline,
and card-style navigation links to My Account and Administration.
2026-02-19 15:38:09 +01:00
Johan Lundberg
befcef9395
fix: add CSRF token handling to admin tests after merge
The CSRF middleware added to main after the admin-pages branch was
created caused all admin test POSTs/DELETEs to be rejected. Add
get_csrf_token() calls and X-CSRF-Token headers to login helpers and
all mutation requests, matching the pattern used by other tests.
2026-02-19 15:02:51 +01:00
Johan Lundberg
33a61ecc2a
Merge branch 'feature/admin-pages'
# Conflicts:
#	src/porchlight/app.py
2026-02-19 14:36:48 +01:00
Johan Lundberg
5a24a9c70b
test: add E2E tests for admin pages 2026-02-19 14:31:41 +01:00
Johan Lundberg
1054feb534
fix: reorder imports and use ty-compatible type suppression 2026-02-19 14:29:01 +01:00
Johan Lundberg
f648422227
test: update all tests to include CSRF tokens 2026-02-19 14:19:47 +01:00
Johan Lundberg
186be17b97
test: add comprehensive unit tests for admin routes 2026-02-19 14:17:41 +01:00
Johan Lundberg
d1f2b39cb6
feat: wire CSRF middleware and harden session cookie 2026-02-19 13:45:58 +01:00
Johan Lundberg
f93290d43e
feat: add CSRF middleware with synchronizer token pattern 2026-02-19 13:26:33 +01:00
Johan Lundberg
dd1f85d8d3
feat: add admin router with admin group guard 2026-02-19 11:18:50 +01:00
Johan Lundberg
be35c17fa5
Merge branch 'feature/consent-screen' 2026-02-19 11:16:51 +01:00
Johan Lundberg
b8464284c2
test: update existing tests to handle consent step 2026-02-19 11:13:11 +01:00
Johan Lundberg
7e9eeb1339
feat: add search_users and count_users to user repository 2026-02-19 11:00:47 +01:00
Johan Lundberg
1d8fd91f68
feat: add consent check to authorization flow 2026-02-19 09:47:59 +01:00
Johan Lundberg
9ccc6c885f
feat: add Consent model, migration, and repository 2026-02-18 15:01:35 +01:00
Johan Lundberg
8a610a0cd6
feat: add self-service profile page with manage navigation
Add /manage/profile page where authenticated users can view and edit
their OIDC profile fields (given_name, family_name, preferred_username,
email, phone_number, picture, locale).

- Create manage/base.html with tab-style nav for Profile/Credentials
- Update credentials.html to extend manage/base.html
- Add GET/POST routes with server-side validation
- Add input styling for tel and url input types
- Add profile test user with pre-filled data in setup_db.py
- Add 19 E2E tests covering structure, navigation, updates, validation
- All 76 E2E tests and 172 Python tests pass
2026-02-18 14:35:17 +01:00
Johan Lundberg
404fcac4dd
Merge branch 'feature/config-file' 2026-02-18 13:09:58 +01:00
Johan Lundberg
64f8c1936b
refactor: fix lint warnings and remove stale type: ignore comments 2026-02-18 13:08:03 +01:00
Johan Lundberg
eeb09321e2
feat: register OIDC clients from config file 2026-02-18 12:48:23 +01:00
Johan Lundberg
fa614e9321
Merge branch 'feature/playwright-webauthn-e2e' 2026-02-18 12:48:03 +01:00
Johan Lundberg
70c97233c5
fix(e2e): fix WebAuthn and integration test failures
- Use localhost instead of 127.0.0.1 as TARGET_URL so the WebAuthn RP ID
  is a valid domain (the spec forbids IP addresses)
- Replace request.post('/logout') with page.context().clearCookies() since
  Playwright's request fixture has a separate cookie jar from the page
- Add registerPasskey() helper that waits for 'load' event to reliably
  detect the page reload after successful registration
- Track credential count with getCredentialCount() since credentials
  accumulate across serial tests sharing the same database
- Fix login.spec.js selector from #webauthn-login-form to #webauthn-login-btn
  to match the actual template

All 57 E2E tests now pass (50 migrated + 7 WebAuthn).
2026-02-18 12:45:03 +01:00
Johan Lundberg
61ca3063ca
feat: add TOML config file support with client registrations 2026-02-18 12:44:00 +01:00
Johan Lundberg
71ddf5d8ff
feat(e2e): add WebAuthn E2E tests with CDP virtual authenticator 2026-02-18 11:52:47 +01:00
Johan Lundberg
c96ebe1b64
feat(e2e): add WebAuthn test user to fixture seeding 2026-02-18 11:47:11 +01:00
Johan Lundberg
ef8bf10555
refactor(e2e): remove old custom test runner 2026-02-18 11:43:17 +01:00
Johan Lundberg
7900f264ba
refactor(e2e): migrate all tests to Playwright Test 2026-02-18 11:37:23 +01:00
Johan Lundberg
80960d5a1f
Merge branch 'feature/cli-module' 2026-02-18 11:35:15 +01:00
Johan Lundberg
4e83c3807e
feat: add initial-admin CLI command 2026-02-18 11:29:13 +01:00
Johan Lundberg
bcddf5d1c8
feat: add create-invite CLI command 2026-02-18 11:27:36 +01:00
Johan Lundberg
174c6c001e
feat: migrate e2e test infrastructure to @playwright/test
Replace direct playwright dependency with @playwright/test and add
playwright.config.js for centralized test configuration. Update run.sh
to invoke 'npx playwright test' instead of running test files with node.
2026-02-18 11:10:23 +01:00
Johan Lundberg
1c21d6d199
test: add failing test for registering pre-existing users
Part of CLI module work (fastapi-oidc-op-9lb.1). The test verifies that
/register/{token} handles users already created by initial-admin.
2026-02-17 14:09:00 +01:00
Johan Lundberg
cd9469342b
refactor: fix lint warnings in webauthn login tests 2026-02-17 13:46:02 +01:00
Johan Lundberg
32567b5484
feat: rewrite WebAuthn login routes for usernameless discoverable credential flow 2026-02-17 13:38:17 +01:00
Johan Lundberg
2ffe968342
feat: require discoverable credentials and prefer user verification in WebAuthnService 2026-02-17 13:18:46 +01:00
Johan Lundberg
51d03bc780
refactor: extract open_db() context manager from lifespan 2026-02-16 15:41:15 +01:00
Johan Lundberg
7cb1adbd06
update all imports in test files: fastapi_oidc_op → porchlight 2026-02-16 15:34:53 +01:00
Johan Lundberg
c5a80b51de
rename package directory fastapi_oidc_op → porchlight 2026-02-16 15:29:31 +01:00
Johan Lundberg
c381896de4
test: add comprehensive e2e test suite with shared helpers and DB seeding
Extract shared test runner (helpers.js), add file-based SQLite with
setup_db.py for fixture seeding, and add tests for auth guard, credentials
management, full registration flow, health endpoint, password auth, and
magic link registration errors. 66 checks across 7 test files.
2026-02-16 14:41:14 +01:00
Johan Lundberg
dbd7449ea1
test: add end-to-end OIDC authorization code flow test 2026-02-16 14:05:11 +01:00
Johan Lundberg
11a76d4ea8
feat: add OIDC userinfo endpoint 2026-02-16 13:57:10 +01:00