5 Commits
Author SHA1 Message Date
petriandClaude Opus 5.5 1acdaa5b19 Harden the app: block project files, add rate limits and security headers
- Root .htaccess refuses everything outside public/, because local Apache
  serves the whole project folder (.env, logs with set-password links, .git).
- Login allows 20 failed attempts a minute per IP across accounts, besides
  5 per email and IP; the forgot-password page 5 requests a minute per IP.
- A global middleware sends X-Frame-Options, frame-ancestors, nosniff,
  Referrer-Policy, Permissions-Policy and HSTS over HTTPS, and drops
  X-Powered-By.
- The weekly time sheet locks the shown week and selected day, so the
  browser cannot set them.
- Users who may not see personal identity codes can save a new code at
  most 10 times an hour, so the duplicate check cannot be used to test codes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 06:25:26 +02:00
petriandClaude Opus 5.5 8dfc02c4e5 End other sessions on password change and give admin links 72 hours
- AuthenticateSession in the web group logs out a user's other sessions
  when their password changes.
- Set-password links made by an admin use a new admin_links broker with
  its own password_setup_tokens table and a 72-hour expiry, so links
  handed over by hand don't expire in an hour. Forgot-password links
  keep 60 minutes. The reset page accepts both, and issuing or using a
  link ends the user's earlier links.
- Admin links are emailed with PasswordSetupLinkNotification; the email
  body is shared with the forgot-password email via PasswordLinkMail.
- Spec chapter 3 and CLAUDE.md describe the link lifetimes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 17:42:37 +02:00
petriandClaude Opus 5.5 246e806c1c Add structured specification and show set-password links to admins
The customer answered the open questions in määrittely.txt. Collect the
answers into docs/maarittely.md: roles and permission table, money
visibility, customer job fields and enum keys, Kanban, tasks, time
entries, expenses, pricing, Fennoa billing export, data model, revised
phases with phase 1 in detail, and remaining open questions. CLAUDE.md
now points to it.

Apply the answers that change the Users module:
- Passwords need 12+ characters with mixed case, a number and a symbol,
  with a Finnish message for each rule.
- When an admin creates a user or asks for a new link, the set-password
  link is emailed and also shown to the admin to copy, even if the email
  fails. The link lives only in the page state. users:create-admin
  prints it too. Self-service "forgot password" stays as it was.
- The copy field uses x-input + x-button with a status message, because
  x-clipboard has an unlabelled input and a changing button name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 17:22:43 +02:00
petriandClaude Opus 5.5 c9a7f970ab Fix review findings in login and user management
- Load stored users without re-checking role rules, so an intern whose
  supervisor was deleted no longer gets a 500 on every request; the
  rules apply again on the next change.
- Refuse to deactivate or demote a supervisor of active interns
  (SupervisorHasInterns).
- Lock active admin rows in the last-admin check so concurrent changes
  cannot remove every admin.
- Creating a user survives mail failures: the error is reported and
  the admin is asked to resend the link (CreatedUserAccount result).
- Session-ended redirect passes the reason in the URL
  (/login?access=ended), so Livewire requests also show it.
- Same login message for a wrong password and a disabled account.
- Forgot-password sends links only to users who may sign in today
  (RequestPasswordReset), with the same neutral message.
- Use the default callout instead of the low-contrast warning variant.
- Document make:class/make:test for module files in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 11:18:22 +02:00
petriandClaude Opus 5.5 8c7cb9e3b4 Add login, password reset and user management (Users module)
New Users module with the four layers:
- Domain: Role enum, UserAccount entity (intern needs end date and
  supervisor, login allowed until the end of the last day), email and
  name value objects, SupervisorRule, last-admin protection.
- Application: CreateUserAccount (emails a set-password link),
  UpdateUserAccount, SendPasswordSetupLink, CheckLoginAllowed, query
  contract and Clock (business time zone Europe/Helsinki).
- Infrastructure: users table gets role, is_active, employment_ends_on
  and supervisor_id; Eloquent repository and queries; Password broker
  link sender with a Finnish email; Gate users.manage.
- Presentation: Livewire login (rate limited), forgot and reset
  password pages, logout, EnsureAccountIsUsable middleware that ends
  sessions of deactivated users, admin-only user list and form, and
  users:create-admin command.

Also:
- Layout gets a labelled main menu, the signed-in user and logout.
- Remove the local /dev/login; guests are redirected to /login.
- Customers: customers.use ability (no subcontractors), authorization
  in mount and save, locked customerId, 404 for a missing customer,
  empty-state check uses the total count.
- Architecture test lets module providers register their own
  Presentation classes; docs and CLAUDE.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 11:03:00 +02:00