Creating a custom authentication component for CakePHP 5

Hi all,

I am currently looking for an example of how to create a custom authentication component (or identifier perhaps) for CakePHP 5.

Essentially, I am in the first step of creating a multi-tenant application that is using row level security. Each tenant will be identified by host name (i.e. they point their dns at the public address of the service). The tenant is being identified by mapping the host name to a record in the database.

So far, this has worked a treat.

The service will be using an email address as the way to identify a tenant’s end user. The problem is that they may have users that have the same email address. i.e. A customer with an email address of bob@shop.com could be a user for both Tenant A and Tenant B.

In theory, I could shard the database, use multiple schemas, etc. However, my client wants to use row level security.

Essentially, I need to match users by username,password and tenant id. The plain SQL version of this would read something like:
select * from users where username=‘bob@shopcom’ and tenant_id=3;

Thanks!
Dan

This is just a custom finder in the authentication config, I think?

OK, that sounds good and probably a way simpler solution than what I was thinking of!