GraphQL, gRPC and Living API Documentation
GraphQL and gRPC are extra adapters over the same tools, and OpenAPI docs can come straight from Schema-layer definitions. Where each concern belongs in LVD.
One tool checks the caller's role. Another trusts a user id sent in the request body. A third was written before login existed and has never been revisited. When security checks are scattered through business logic, every change to how people sign in becomes a change to the business. LVD gives identity a single home, a sublayer called L5.1.
The book places authentication and authorization within the API layer and labels them L5.1 to stress that they form a cross-cutting concern of the protocol boundary. They are not business logic. Authentication establishes who the caller is. Authorization decides what that caller may do. Both run before the request reaches a tool handler.
The reasoning is volatility. How a system recognises its callers changes for reasons unrelated to the business: a new identity provider, a switch from one token format to another, a tightening of lifetimes. If that logic lives inside tool handlers, each of those changes reaches into stable code. Kept at the boundary, they touch only the layer designed to change often. Tools simply receive a user context as ordinary data and never verify a token themselves.
The sublayer is built from a few small pieces, each of them a middleware step.
The role check is small enough to show whole:
export const requireRole = (...allowed: string[]) =>
(req: Request, res: Response, next: NextFunction) => {
const roles = req.user?.roles ?? [];
if (!allowed.some((role) => roles.includes(role))) {
return res.status(403).json({ error: "Insufficient permissions" });
}
next();
};
router.delete("/api/v1/visits/:id", requireRole("reception"), cancelVisitRoute);
The route declares which role it requires, the middleware enforces it, and the tool behind cancelVisitRoute never learns that a role check happened. If the roles ever come from a different identity system, only the code that populates req.user has to change.
The book lists five security invariants that protocol layers must enforce. Three of them stand out because they are easy to postpone:
The other two concern rotating secrets on a schedule without downtime and logging every authentication success and failure for audit. Each is a practice about the boundary rather than about any single tool, which is why they sit comfortably in one sublayer.
Treat identity as plumbing at the edge of the system. Verify, authorise and rate-limit before a request reaches a tool, then pass the tool a clean user context and nothing more. When the way you identify people changes, the diff stays in L5.1. The same thinking carries over to AI callers in MCP authentication, and the REST routes that use these checks are shown in REST at Layer 5. For a regulated setting, see security across the layers in MedConnect.