Building the foundation Claudius runs on Néstor Daza details the authentication and provisioning foundation for Claudius, his Claude-based chatbot, in the third part of a tutorial series. The system uses Auth.js v5 with Google OAuth and a MongoDB adapter, resolving user roles server-side with a clear precedence: admin email, member allowlist, then guest. Roles are cached in a JWT, and provisioning uses an aggregation pipeline with $ifNull to set defaults without overwriting admin changes. This tutorial was written by Néstor Daza. This is the third article in a series about building Claudius, my own Claude-based chatbot Github . The previous article discussed the MongoDB data model to use for the app. The previous article https://dev.to/mongodb/no-messages-table-the-data-model-behind-my-own-claude-based-chatbot-54jp decided the shape of the data. None of it matters until the app around it is working, and getting it there is the unglamorous half of this phase. It comes down to three things: an identity system the client cannot tamper with, proof that Claudius can reach the two services it depends on, and the deployment realities that decide whether any of it runs at all. This is the boring work that quietly decides whether a project survives contact with production. Any Google account on Earth can sign into Claudius safely because a user's role is never something the client sends. It is decided on the server every time. One piece of this lives outside the code. The Google provider needs an OAuth Open Authorization client that you register once in the Google Cloud Console, and the client identifier and secret from that registration are set in corresponding env variables. These setup steps live in the Auth.js and Google documentation, so I am not repeating them here. Sign-in runs on Auth.js v5 with the Google provider and the MongoDB adapter. There are three roles, admin, member, and guest, and they resolve in exactly one place on the server, with a clear precedence: export async function resolveRole email: string | null | undefined : Promise