Public demo: nothing is sent to any provider and the data resets regularly.

Roles, permissions and two-factor

Two authorization packages side by side on the same seeded users, and two-factor authentication for one of them. laravel-bouncer keeps abilities (with ownership and forbids) in its own tables with the bouncer_ prefix, because laravel-laratrust uses the table names roles and permissions too.

laravel-bouncer laravel-laratrust laravel-google2fa laravel-qrcode

laravel-bouncer

Admins may do everything, editors view, edit and publish every post, Cem may view posts and edit his own, and is forbidden to delete any (a forbid wins over everything).

UserRolesview postsedit postsedit Cem's postdelete postsban users
Ada Lovelace admin allowedallowedallowedallowedallowed
Barış Manço editor allowedallowedalloweddenieddenied
Cem Karaca - alloweddeniedalloweddenieddenied
bouncer.allow("editor").to_on(["view", "edit", "publish"], Entity::class("posts")).await?;
bouncer.allow(&cem).to_own(Entity::class("posts")).to("edit").await?;
bouncer.forbid(&cem).to_on("delete", Entity::class("posts")).await?;
bouncer.can(&user, "edit", Entity::new("posts", 3).with("user_id", cem.id)).await?

laravel-laratrust

Roles with permissions, and teams with the strict team check: Cem is an editor only inside the blog team, so the checks without a team say no for him, and Barış's global role does not count inside the team. posts.* is a wildcard check.

UserRolesrole adminrole editoreditor in team blogposts.editposts.deleteposts.*
Ada Lovelace admin alloweddenieddeniedallowedallowedallowed
Barış Manço editor deniedalloweddeniedalloweddeniedallowed
Cem Karaca - denieddeniedalloweddenieddenieddenied
laratrust.user(cem.subject()).in_team("blog").add_role("editor").await?;
laratrust.user(user.subject()).has_role("admin").await?
laratrust.user(user.subject()).in_team("blog").has_role("editor").await?
laratrust.user(user.subject()).is_able_to("posts.*").await?

Two-factor authentication with laravel-google2fa

Set up an authenticator app for ada@example.com: generate a secret, scan the QR code (made with laravel-qrcode), then type the six digit code the app shows. The secret is stored on the demo user.

No secret yet.

let session = laravel::resolve::<TwoFactorSession>().await?;
let secret = session.google2fa().generate_secret_key()?;
let qr = session.qr_code_inline(&user.email, &secret)?;   // data: URI, SVG
session.verify_google2fa(&request, &secret, &code)?          // then session.login(&request)
Özkan Özcan

Available for new projects

Hire the developer behind these packages

I am Özkan Özcan. I ported, tested and published every package in this demo, and I can do the same for your code:

  • Port your Laravel package or application to Laravel Rust
  • Move one slow service first and keep the rest in PHP
  • Priority support and custom features for any OzSuite package
Start a project See my services

I reply within one working day.