# Access and identity

> Who gets into an app, private and public apps, invites and their state, sign-in in front of the app, analytics, and how the app learns who the person is.

A person opens the app URL, signs in with an account they already have, and the platform decides whether they get in. The app author writes no login code.

## Roles inside the app

Roles inside the app, such as "HR manager" in a leave tracker, are the app's own data. SmallRun has no roles: a person either has access to the app or does not.

- Store them in the app's database, by `X-SmallRun-User-Id` (see "Headers the app reads" below).

## Private and public apps

| Setting | Who opens the app |
|---|---|
| `private` (default) | People who pass the rules in "Who gets in" below |
| `public` | Anyone, with no sign-in |

```sh
smallrun visibility            # shows the current setting
smallrun visibility public     # anyone can open the app
smallrun visibility private    # back to sign-in
```

- An app with its own login is usually made public, so visitors see only the app's login. An app without one stays private behind SmallRun's sign-in screen.
- A new app is private. Only this command makes it public; the manifest cannot.
- There is no unlisted "anyone with the link" setting.
- A change takes effect on the next request.
- A public app can still sign a visitor in: link to `/.smallrun/login?next=<path>`. After sign-in the app receives the identity headers.
- On a public app, a request without `X-SmallRun-User-Id` is an anonymous visitor.
- A public app has no company-only pages. Put internal pages in a separate private app. Do not decide access by the domain of an email address.
- SmallRun adds no indexing header to a public app. The app decides whether search engines index it.

## Who gets in

On a private app, SmallRun decides before the request reaches the app. One rule set applies to every private app. There are no roles.

| Rule | Who |
|---|---|
| Same company | Anyone who signs in with a company account on the owner's company domain |
| Invited | Anyone the owner invited by email, or whose access request the owner approved |

Example: the owner deployed the app while signed in as `owner@example.com`, a Google Workspace account.

| Visitor signs in as | Result |
|---|---|
| `coworker@example.com`, a Workspace account on the same domain | In. No invite needed |
| `someone@gmail.com`, a personal Google account | Refused. Sees "Request access" |
| `someone@gmail.com`, after the owner invites or approves | In |
| `coworker@example.com` with an emailed code | Refused unless invited. Email sign-in does not prove company membership |

- The company domain is the domain of the owner's own account. Nobody types it.
- The decision comes from the provider's signed company claim, never from the text of an email address.
- An owner with a personal account has no company domain. That owner's private apps open for invited people only.

## Invites and access requests

```sh
smallrun share <email>...          # invite and send the invite email, or approve a request
smallrun share <email> --resend    # send the invite email again
smallrun share <email> --no-email  # invite without sending an email
smallrun unshare <email>           # remove an invite
smallrun unshare <email> --deny    # refuse a pending request
smallrun access --json             # invited people and pending requests, with their state
```

- `smallrun share` sends the person an email with the app name, the owner's name and the app URL. `--message` adds a short note.
- The invite, not the email, grants access. If the email does not arrive, the person still gets in by opening the URL and signing in with that address.
- A signed-in person without access sees a "Request access" page. The owner receives an email; the request is approved with `smallrun share`, by the owner or by the owner's agent, or by the link in that email.
- An invite is bound to an email that the provider states as verified.
- Removing an invite ends access at the next request.

### What `smallrun access` shows

| Field | Values |
|---|---|
| `email` | The invited or requesting address |
| `source` | `invite` or `request` |
| `status` | `invited` (not opened yet), `active` (has opened the app), `requested` (pending) |
| `email_status` | `sent`, `delivered`, `bounced`, `failed`, `not_sent` |
| `invited_at`, `accepted_at`, `last_seen_at` | When the person was invited, first got in, and last opened the app |

Coworkers who get in by the same-company rule are not invited, so they are not in this list. `smallrun analytics --people` shows them.

## Who opened the app

```sh
smallrun analytics --period 7d --json
smallrun analytics --people --json
```

- Analytics come from the edge, so the app needs no script and sets no cookie.
- They show page views, visitors, top paths, referrers, countries, devices, browsers and status codes. Known bots are counted apart.
- `--people` lists every signed-in person who opened the app, how they got in (`same_company`, `invite` or `visitor`), their page views and their last visit.
- Only the owner reads an app's analytics.

## Who manages the app

The owner is the account that deployed the app. Only the owner deploys new versions, reads logs, manages secrets, invites people, changes visibility, reads analytics, rolls back and deletes.

## Account providers

| Provider | Counts as "same company" | Invited people |
|---|---|---|
| Google | Yes, for Google Workspace accounts | Yes |
| Microsoft | Yes, for work and school accounts | Yes |
| GitHub | No | Yes |
| Facebook | No | Yes |
| Email (code or link) | No | Yes |

## Sign-in with email

For a person without one of the accounts above, for example a contractor on their own mail server.

- The person types an address. SmallRun sends one email with a 6-digit code and a sign-in link. Either one signs the person in.
- Code and link are single-use and expire after a few minutes.
- The screen answers the same way for every address, so it does not show who has access.
- Sending is rate limited per address, per IP and per app.

## Headers the app reads

| Header | Content |
|---|---|
| `X-SmallRun-User-Email` | Verified email of the signed-in person |
| `X-SmallRun-User-Name` | Display name |
| `X-SmallRun-User-Id` | Stable id, unchanged if the email changes |
| `X-SmallRun-Identity` | The same facts as a signed, short-lived JWT |

- The plain headers can be trusted as they are. The app accepts traffic only from the edge, and the edge removes any `X-SmallRun-*` header sent by a client.
- The app needs no library and no verification.
- The JWT and its JWKS endpoint are optional, for apps that want cryptographic proof.
- On a private app the headers are present on every request that reaches the app. On a public app they are present only for a signed-in visitor.

```php
$email = $_SERVER['HTTP_X_SMALLRUN_USER_EMAIL'];
```

## Sign-out

Every app has a fixed sign-out path: `/.smallrun/logout`. Link to it; do not build a logout handler.

## What the visitor sees

The visitor signs in to the app, not to SmallRun. There is no SmallRun signup form, no password and no profile step.

```text
            Sign in to leave

      [ Continue with Google    ]
      [ Continue with Microsoft ]
      [ Continue with GitHub    ]
      [ Continue with Facebook  ]

      ───────────── or ─────────────
      [ you@example.com ] [ Email me a code ]
```

---
Source: https://www.smallrun.app/docs/identity/ · Index of all pages: https://www.smallrun.app/llms.txt
