# Organizations and domains

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> An organization is the company that owns a set of namespaces, and its verified domain lets employees join without an invitation.


An organization is the company that owns a set of namespaces, which are its teams and business units. Once its email domain is verified, employees who sign in with a company address join the organization on their own. Ringleader creates the organization and its domain claim, and an organization administrator publishes the DNS record that verifies the domain.

The fields of both objects are in the [Organization and OrgDomain](https://docs.ringleader.dev/reference/resources/organization/) reference.

## Organizations

An organization (`Org`) is the tenancy layer above namespaces. A namespace stays the unit of isolation, because access control, Secrets and resources all scope to it. But the company-to-team relationship is real, and an organization is what records it. Without one, five business-unit namespaces are just five unrelated namespaces, and nothing says they are one customer.

Recording it lets Ringleader offer these things:

- **A billing and plan entity**, the one thing a namespace cannot be.
- **Self-serve team formation.** A verified `@acme.com` organization adds the next Acme employee to it, instead of leaving them alone in a personal namespace.
- **An administrator with reach.** One `org-admin` binding covers every namespace of the organization, present and future, with no setup per namespace.
- **Cloud federation.** A [CloudAccount](https://docs.ringleader.dev/reference/resources/cloudaccount/) belongs to an organization, and the assertion Ringleader signs for your cloud carries the organization's id as its subject.

Ringleader creates organizations. An `org-admin` can read their own organization but cannot change its plan or suspension state. What they administer is everything under it, as [Roles and grants](https://docs.ringleader.dev/organizations-teams/accounts-access/roles-grants/#organization-administrators) explains.

### Organization shape

Each namespace points at its organization, and an organization never holds a list of its namespaces. A namespace belongs to at most one organization.

*Diagram: Namespaces, an OrgDomain and a CloudAccount each point up at a single Org. The Org holds no list of its children.* A namespace, an OrgDomain and a CloudAccount each name their organization in spec.org.

```mermaid
flowchart BT
  NS1["<b>Namespace</b><br/>acmecorp"]
  NS2["<b>Namespace</b><br/>acmecorp-team-a"]
  Domain["<b>OrgDomain</b><br/>acme.com (verified)"]
  Account["<b>CloudAccount</b><br/>acme-gcp (cluster-scoped)"]
  Org["<b>Org</b> &mdash; acmecorp<br/>plan, autoJoin, defaultNamespace"]

  NS1 --> Org
  NS2 --> Org
  Domain --> Org
  Account --> Org
```


A namespace with no organization still works for everything local to it. But it cannot get a cloud credential through federation. There is no organization for Ringleader to sign an assertion for, and Ringleader refuses rather than guess one.

### The local organization

`local` is a reserved name. Standalone mode creates a `local` organization alongside the reserved `local` namespace, so that code that works with organizations has one path to run locally. It never leaves your computer, and no one may create an organization called `local`.

## Domain verification

An organization domain (`OrgDomain`) claims a DNS domain for an organization. Verifying the domain is what turns on self-serve membership.

Ringleader creates the `OrgDomain` when it sets up your organization. An organization administrator can read it but cannot create or change it. Your part is to publish a TXT record on the domain, as [Publish your domain's TXT record](#publish-your-domains-txt-record) shows.

Ringleader checks DNS periodically and sets the `Verified` condition on the domain. The status fields and the reasons the condition gives are in the [Organization and OrgDomain](https://docs.ringleader.dev/reference/resources/organization/#organization-domain-status) reference. A few behaviors are worth knowing:

- **The token is deterministic, not random.** The same domain and key always give the same record. You publish it once, and a redeploy of Ringleader never invalidates it.
- **Ringleader scans every TXT record**, not just the first, so the verification record can sit alongside the other TXT records on the domain.
- **One failed DNS lookup never de-verifies the domain.** Public DNS fails now and then, and one failure should not revoke a whole organization's membership. De-verification takes several failures in a row, and `consecutiveFailures` shows the count the whole time. While the grace window runs, `status.message` says that the record could not be confirmed on the last checks. That message is your warning that a record went missing while the condition still reads `True`.
- **Free email domains are refused.** `gmail.com`, `outlook.com`, `icloud.com` and similar domains are rejected outright. Otherwise one organization could verify a public domain and absorb everyone who signs up with a matching address.

If two organizations claim the same verified domain, one wins and the other is marked `Conflict`. Duplicate claims within one organization never conflict.

### Admission before DNS verifies the domain

If someone else runs your DNS, publishing the TXT record waits on their schedule. In the meantime, Ringleader can open a temporary trust window on your organization by setting `spec.domainTrustUntil` to a deadline. Until the deadline passes, or Ringleader clears the field, every domain of the organization admits members as a verified domain does. Ringleader keeps checking DNS. Only Ringleader can set the field, so ask Ringleader if you need a window.

While the window is the only thing admitting members, the domain's `Verified` condition reads `False` with reason `Pending`. An `Attested` condition reads `True` with reason `Trusted`. Its `status.message` says so: `acme.com is admitting members on a temporary trust window, and is still waiting for its DNS TXT record`. When DNS confirms the record, `Verified` turns `True` and the `Attested` condition goes away. The reasons `Attested` gives when the window does not apply are in the [Organization and OrgDomain](https://docs.ringleader.dev/reference/resources/organization/#organization-domain-status) reference.

The window stands in for the DNS record and nothing else. A `Rejected` domain admits nobody, the organization still needs `autoJoin: true`, and an email address that the identity provider has not verified still lands in a personal namespace. When the window closes, new people stop joining through it, but anyone who joined while it was open stays in the organization's shared namespace.

## Organization membership

On a person's first sign-in, Ringleader decides once where they land. It applies three rules, in this order:

1. **Ringleader assigned them in advance.** The person is placed in a shared namespace, on the role `spec.defaultMemberRole` selects.
2. **Their email domain is verified and the organization allows auto-join.** The domain matches an `OrgDomain` that is verified, or admitted under a trust window, and the organization has `autoJoin: true`. The person lands in the organization's shared namespace on the same role. That namespace is `spec.defaultNamespace`, or a namespace named after the organization. Nobody at Ringleader needs to act.
3. **Otherwise, a personal namespace.** Ringleader derives its name from the person's email address with a short random suffix, such as `alice-acme-com-k3f9x2`. The person owns it as `namespace-admin`, and administers the personal organization it belongs to as `org-admin`. A deployment can admit invited people only. There, an address that is not on the invite list is refused with `NotInvited`, and nothing is created for it.

Rule 3 lets a solo signup administer their own tenancy. They can register a trust anchor or author a [service account](https://docs.ringleader.dev/reference/resources/serviceaccount/) with nobody acting for them first. It applies to the personal case only. Someone who joins a company's organization under rule 2 is an ordinary member of it, never an administrator of the company.

### Default role for new members

Rules 1 and 2 give the person the role the organization's `spec.defaultMemberRole` selects: `namespace-member`, the default, or `namespace-reader`, the read-only role for people who should see a namespace without provisioning anything. [Roles and grants](https://docs.ringleader.dev/reference/resources/roles/#built-in-roles) says what each role allows.

Ringleader reads the setting from the namespace the person lands in, so it applies to a pre-assignment and an auto-join alike. Three cases fall back to `namespace-member` or fail:

- A namespace with no `spec.org`, or one that names an organization that does not exist, gives `namespace-member`.
- A row that Ringleader cannot read, the organization's or the namespace's, fails the sign-in instead of guessing a role. The next attempt tries again.
- A namespace created for a pre-assignment carries no organization, so every member lands on the default role until the namespace names one. An `org-admin` can create a namespace that already names their organization. Stamping an existing namespace that has no organization is Ringleader's to do, so ask Ringleader.

Rule 3 never reads the setting, because a personal namespace always gives `namespace-admin`.

### Gates on auto-join

Two gates guard rule 2:

- **The identity provider must have verified the email address.** An unverified identity is never auto-joined into someone else's organization. It still onboards, into a personal namespace, and never lands inside another tenant.
- **Ringleader re-checks the domain at the moment of joining.** A domain that lapsed between the lookup and the placement cannot add the person.

### Placement happens once

Ringleader decides placement and role once and does not revisit them. Someone who onboarded into a personal namespace before their company's domain was verified stays there. Changing `defaultMemberRole` later moves nobody who already onboarded, because both settings only change where and how new people land. To move an existing member between roles, edit their `RoleBinding`, as [Give someone a role](https://docs.ringleader.dev/organizations-teams/accounts-access/roles-grants/#give-someone-a-role) shows. Moving a member to another organization is not something that happens behind their back, so ask Ringleader if you need one moved.

## Publish your domain's TXT record

Publish the verification record when Ringleader tells you your organization's domain is ready to verify. You need access to the domain's DNS settings, and the organization's domain must already exist, because Ringleader creates it.

1. Read the token the domain asks you to publish: `rl orgdomain get acme-com -o jsonpath='{.status.expectedToken}'`.
2. In your DNS provider, add a TXT record on the domain, with the token in this form:

   ```text
   acme.com.   IN TXT   "ringleader-verification=<token>"
   ```

3. Wait for the next DNS check, then run `rl orgdomain describe acme-com`. The message reads `acme.com is verified` once the record is found. Until then it reads `waiting for the ringleader-verification= DNS TXT record to appear on acme.com`.

`rl od get` lists every domain of your organization with its state.

## Find your organization

To see your organization, run `rl org get`. To see the organization your default namespace belongs to, run `rl auth status -o json`.

## Next steps

- [Namespaces and limits](https://docs.ringleader.dev/organizations-teams/accounts-access/namespaces-limits/): create the namespaces that make up your teams and limit what runs in them.
- [Roles and grants](https://docs.ringleader.dev/organizations-teams/accounts-access/roles-grants/): decide who can do what in each namespace.
- [Set up a team](https://docs.ringleader.dev/guides/set-up-team/): walk through a team's namespace, people and roles.
- [Organization and OrgDomain](https://docs.ringleader.dev/reference/resources/organization/): every field of an organization and its domain.

