Skip to content

javaabu/auth v3.0 (next-gen) - #2

Open
n4ff4h wants to merge 14 commits into
Javaabu:mainfrom
n4ff4h:next-gen
Open

n4ff4h wants to merge 14 commits into
Javaabu:mainfrom
n4ff4h:next-gen

Conversation

@n4ff4h

@n4ff4h n4ff4h commented Nov 10, 2026

Copy link
Copy Markdown

javaabu/auth v3.0: a rewrite around user types, matching Laravel's current starter kits, with multi-auth at the centre. Tracked in n4ff4h#14 (developed on the fork because the orchestrating account has read-only access here).

What's in it

  • User types (config('javaabu-auth.user_types'), UserTypes::register()): each kind of user has its own model, guard, password broker, route names, home, Blade/Inertia stack, layouts, features, two-factor mode, lockout limit and login methods. Nothing assumes web or App\Models\User.
  • Routes from macros: Route::authRoutes('admin', ['prefix' => 'admin']) registers login/logout, registration, password reset, email verification, password confirmation, the 2FA challenge, passkeys, account status, required password change, and the profile and security pages, with starter-kit route names (admin.login, admin.password.request, …). Also Route::authApiRoutes() and Route::userAccountActions().
  • Controllers, actions and responses in the starter-kit shape: actions behind contracts (CreatesNewUsers, …), controllers overridable from config, rebindable responses, auth.type:{type} middleware for app pages, password confirmation kept per user type.
  • Security: rate limits per type/username/IP, timeboxed password checks, account lockout after failed logins (v2 behaviour, kept), single-use TOTP codes, cross-type checks everywhere (a user can't log in on the admin page, finish another type's 2FA challenge, reuse another type's confirmation, passkey or token).
  • Two-factor authentication: TOTP + recovery codes, off/optional/required per type, in laravel/fortify's column format.
  • Passkeys with Laravel's own laravel/passkeys: login, confirmation and management for every type, one morph table. Tested end to end with a software authenticator (real P-256 keys and CBOR).
  • API: Sanctum, Passport or both (php artisan auth:install --api=…), Sanctum token logins with 2FA, Passport per-provider tokens, personal access tokens on the security page.
  • Admin account actions: unlock, reset 2FA, require a new password, log out everywhere, behind UserAccountPolicy and permissions registered through javaabu/permissions.
  • Extension points for javaabu/mobile-verification and other packages: LoginMethod + StartAuthenticatedSession for other ways to log in, and account navigation links (UserTypes::accountLink('mobile-number', 'Mobile number'), per type with $type->accountLink() / withoutAccountLink()), shown in Blade and React wherever the type has the route (Let packages add links to the account navigation n4ff4h/auth#15).
  • Pages in Blade (javaabu/forms v2) and Inertia React (@javaabu/forms, through javaabu/manifest), same props, Dhivehi (lang/dv.json) and right to left.
  • Docs: docs/ (including a "For package authors" page), llms.txt, Laravel Boost guideline and skill, AGENTS.md, CHANGELOG.md. docs/, llms.txt and resources/boost ship in the Composer package (no longer export-ignored), so assistants find them under vendor/javaabu/auth (docs/ is export-ignored, but llms.txt and the Boost skill point at vendor/javaabu/auth/docs n4ff4h/auth#16).

Decisions and why are on the issues: not building on Fortify (n4ff4h#2), laravel/passkeys (n4ff4h#5), gate abilities instead of a model policy (n4ff4h#12), no javaabu/stencil for these small forms (n4ff4h#11), javaabu/passport dropped (n4ff4h#6).

Upgrading from v2

Breaking. Full guide: docs/upgrading.md. The short version:

  • PHP 8.4+, Laravel 12+. No longer required: laravel/ui, javaabu/helpers, javaabu/activitylog, javaabu/passport, javaabu/schema, spatie/laravel-medialibrary.
  • Config moves from config/auth.php to config/javaabu-auth.php; describe each user type there. Guards, providers and brokers stay in config/auth.php.
  • Delete the controllers that extended Javaabu\Auth\Http\Controllers\Auth\* and their routes; call Route::authRoutes() per type. Route names follow the starter kits (password.new-password is now password.required).
  • Javaabu\Auth\User → Javaabu\Auth\Models\User (built from traits); the UserContract methods (guardName(), homeUrl(), …) go away in favour of the user type. Add the 2FA columns with UserSchema::twoFactorColumns().
  • Middleware: auth:x + active:x + password-update-not-required:x → auth.type:{type}; password.confirm → auth.password.confirm:{type}.
  • Views are shipped; point javaabu-auth.layouts at your layouts, or publish them.
  • Session\Session and Agent move to Sessions\; Events\PasswordChanged is now PasswordUpdated; translations are JSON.
  • Removed: the new_email verification flow, the media-library avatar, IsAdminModel/LogsActivity on the model.

Checks

CI on the fork is green: Pint, PHP 8.4/8.5 × Laravel 12/13 × lowest/stable, the React pages (typecheck + Vitest), and a run without the optional packages (Inertia, Sanctum, Passport, activitylog). 146 PHP tests, 12 JS tests.

For you

  • Review and merge (Actions on a fork PR may need approval).
  • Codecov: the org needs CODECOV_TOKEN for the coverage upload and badge.
  • Register the package with docs.javaabu.com (Register with Javaabu Docs (docs.javaabu.com) n4ff4h/auth#13).
  • Have a Dhivehi speaker check the strings listed in docs/advanced-usage/translations.md.
  • The Inertia pages were tested with PHPUnit and Vitest, not in a real browser; passkeys likewise (software authenticator, not a real device).
  • Tag and release when ready.

🤖 Generated with Claude Code

n4ff4h and others added 14 commits November 4, 2026 16:18
…core

Replaces the v2 controllers (laravel/ui traits) and the abstract User with user types,
Route::authRoutes(), actions, controllers, middleware and Blade pages. Drops javaabu/helpers,
javaabu/activitylog, javaabu/passport, javaabu/schema, laravel/ui and medialibrary.

Closes #1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e, security and two-factor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gin methods, session driver

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…abu/permissions

Route::userAccountActions() adds unlock, reset two-factor, require password update and
log out everywhere for one user type's accounts, behind the auth.* abilities of
UserAccountPolicy. Permissions ({action}_{type plural}) are registered per user type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nticator

Passkeys (laravel/passkeys) live in one table with a morph to the user, so admins and
users with the same id keep separate keys and can't use each other's. WebAuthn failures
answer 422. The tests register and sign with a real P-256 key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route::authApiRoutes() issues and revokes Sanctum tokens per user type (with the two-factor
code when the user has one). The security page manages personal access tokens with either
driver. Passport uses its own per-provider clients; auth:install publishes, makes keys and
prints the guards for each user type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… checks

The React pages (auth::Login, …, auth::Settings/Security) ship through javaabu/manifest
with the same props as the Blade pages, and a shared WebAuthn client for passkeys.
lang/dv.json covers every string. Tests check both stacks, the translations, logical
direction utilities only, and that the package works without its optional packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docusaurus pages for every flow, option and public class, Blade and React side by side,
an upgrade guide from v2, AGENTS.md and the changelog. Records last_login_at on login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e models without MustVerifyEmail

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
llms.txt and the Boost skill point at vendor/javaabu/auth/docs, so docs must not be
export-ignored. Dev-only JS tooling files are now export-ignored instead.

Closes #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UserTypes::accountLink() adds a link for every user type that has the route, and
UserType::accountLink() / withoutAccountLink() change one type. The Blade navigation and
React AccountLayout render Profile, Security and the added links from the new
account_links prop, marking the current page; the Blade partial also works on pages that
didn't come from auth. Documented for package authors.

Closes #15

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blade-only apps' manifest:check no longer asks them to install React,
@inertiajs/react, @javaabu/forms or @javaabu/onu (Javaabu/manifest#17).
The Blade scripts import no npm packages, and a test keeps it that way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Composer read composer.json from every branch and tag of each VCS
repository through the GitHub API: about 350 calls per CI job, around
3,800 per run. A second run within the hour exhausted the workflow
token's limit, and Composer failed with "Could not authenticate against
github.com" (Javaabu/exports#2, Javaabu/translatable#4). "no-api": true
makes Composer clone these repositories instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every job downloaded each package's zipball from api.github.com, around
140 calls a job, which counts against the workflow token's hourly limit.
Each job now restores Composer's files cache, keyed by job, matrix entry
and composer.json/composer.lock, and falls back to the job's last cache
when those change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant