mirror of
https://github.com/hanzoai/iam.git
synced 2026-11-19 18:37:16 +00:00
A shared application with signup open admitted any existing org a signup named. The tenant gate read ServesAnyOrg, which a shared application passes, so an unauthenticated POST naming acme made the caller a member of acme, and TestSignup_sharedApp_admitsLegitimateTenant asserted that it should. Shared means an application serves many orgs at sign-in, where the person already belongs to one. At signup nobody belongs anywhere yet. A signup now lands in one of three places. It can found an org of its own at an application that founds one for each account. It can join the application's own org when the application serves no other. Or it can join an org whose admin invited it. oidc.Registers states the first two, and the password, provider and wallet doors all ask it, so a shared application that founds nothing no longer files strangers in the operator's org through any of them. The third needed an invitation that something redeems. /v1/iam/invitations has always stored rows, owned by the org and written only for its admin, but no code read them. Signup now takes invitationCode. It finds the named org's invitation that admits the signup: active, a seat left, this application or none, the code (a literal compared in constant time, or a whole-match pattern), and any pinned username, address or number. It spends one seat under a row lock after the address code and before the account exists. An invited account stays in the org it joined, even at a founding application, and records the invitation it came by. A code that redeems nothing is refused rather than read as no code. Every refusal is the one tenant sentence, so a prober learns neither which orgs stand nor which codes exist. The two tests that enshrined the hole now assert refusal. New tests cover each path in, each door's shared case, and each way an invitation fails. Co-authored-by: Hanzo Dev <[email protected]>