API Maker
The backend engine for the AI era
RolesEpisode 26 6:17 10 chapters November 2026
Groups decide which APIs a caller may use; which rows are theirs is the other half. Give the customers of Calm Home access to their own orders and nothing else: roles as groups, a pre-hook that scopes rows with $and, rules that fail closed, g.req.auth, and a hook for one application only.
In the playlists The complete course Security & access
Groups decide which APIs a caller can use. The other half is which rows belong to them. In this video, the customers of Calm Home read their own orders, and nothing else.
Here are the usual bugs. Someone changes an id in the address, and reads another person's order. An admin endpoint is left open. Roles are written as if statements in every handler. And code from an AI assistant forgets the check. With API Maker, a role is a set of groups. One hook limits every read of a table. A hook can target one application. And the Security Report reads the rules and the hooks.
In this video: roles as groups, a customer who reads every order, the row scope, what g.req.auth holds, a hook for one application, and the best practices.
A role screen is a list of checkboxes. In API Maker, each checkbox is a small group. The row of a person holds their groups, in a column that the auth provider names. A role is that list. A call passes when the groups of the application and the groups of the person both allow the API. To give someone a role, you update one column. They do not need to sign in again.
The orders in MySQL ask for the token of a customer. Open API Testing. Pick MySQL, then sales, then orders, and Get all. We call as Diya, a customer. Send. We get the orders of customer twelve, of customer twenty five, all one hundred and eighty of them. Her token is valid, and her groups allow Get all. Groups decide which APIs. Which rows belong to her is the job of a pre-hook, on the table.
So every API of the table is covered, today and tomorrow.
Open Instance API. Pick MySQL, then sales. Open the pre-hooks of orders. Click Add Hook, name it Row scope - orders, and open its code. Calls made by your own code are trusted, so they pass. Next, it gets the customer behind the person token, from g.req.auth. If there is no customer, it answers four hundred and one. Their id is added to the filter with $and, never with a spread.
So what the caller asks for is kept, and the owner is added on top. Any API that the hook does not limit is refused. It fails closed. Save it. Now the same call gives two orders, both hers, as customer two. Now we try a query. In its body, we ask for the orders of customer five. Send. We get nothing. Her id was added with $and, so no filter can widen what she reads.
Every hook and custom API gets the identities that API Maker already checked. authAMUser is the application, from x-am-authorization. authAMDB is the person: the row of customers they signed in with. There is nothing to parse and nothing to verify. And never send the password column back.
A hook can also target one application. Open the post-hooks of orders, click Add Hook, and name it Status in words. Under Groups, pick Shop app. Now it runs only for API users in that group. Open the Code tab. It adds the status in words to each order, in g.res.output. Save it. In API Testing, pick the orders again, as Diya. Through the API user Default, the status stays a code: PAID.
Through the shop app, the same orders say: Paid, being packed. Each application gets its own behaviour, with no if in the code.
Here are the best practices. Keep token access by default. To share data publicly, use a small custom API. Use one API user for each application, small groups, and no broad flags. And lock down the group Default before production. Ask for a person token on every table that belongs to people, and add a row scope hook to it. Never open the users table through the generic APIs. Hash its passwords, and never select them.
A four oh one means: sign in again. A four oh three means: a permission is missing.
Access lives in groups and hooks, not in handlers. The Security Report reads them, even hooks written by AI assistants. It flags a spread merge, a missing owner, or an API that slips past. Video twenty seven shows it. And every rule is a file in Git, reviewed like code.
To sum up. A role is a set of groups. Groups say which APIs, and a pre-hook says which rows. Use $and, never a spread, and fail closed. g.req.auth holds the application and the person. And a hook can target one application. Next: the APIs Security Report. API Maker. Build faster, spend smarter, deliver better.
Length 12:24Security report
Length 9:18Code scan
Length 5:05Security
Length 6:54Authorization