# [BreakGlass] — what a break-glass sign-in may do

> When an organisation's rule says its people sign in only through its identity provider, and that provider is down, an Owner's designated break-glass passkey still lets them in — to repair sign-in. Such a sign-in is DENY BY DEFAULT: it may make plain reads, run a function marked `[BreakGlass]`, write directly an entity marked `[BreakGlass]`, and sign out. Everything else is refused, saying "A break-glass sign-in can only repair sign-in and policy. Sign in through … when it is back for anything else."

<!-- id: security-break-glass · area: security · stability: stable · html: https://osysharp.com/reference/security/break-glass/ -->

## Summary        {#summary}
A break-glass sign-in is an Owner let in by the organisation's break-glass waiver while its provider is down. It exists to
repair sign-in, so it reaches only what is marked for that.

```osy title="a sign-in rule a break-glass sign-in may repair" test app=security-break-glass
[BreakGlass]
entity SignInRule {
  [Required, MaxLength(200)] string Issuer;
  security { allow read, create, update when IsAuthenticated; }
}

/// Point sign-in at the provider's new endpoint.
[BreakGlass]
[Server, Authorize(IsAuthenticated)]
void RepairSignIn(Guid ruleId, string issuer) {
  var rule = SignInRule.Where(r => r.Id == ruleId).FirstOrDefault();
  if (rule == null) { throw new NotFoundException("No such sign-in rule."); }
  rule.Issuer = issuer;
}
```

## Signature      {#signature}
```osy syntax
[BreakGlass] <function>              // a break-glass sign-in may run it as the entry of a request
[BreakGlass] entity <Name> { … }     // a break-glass sign-in may write it directly, under its own security { }
```

## Description    {#description}
**On a function**, a break-glass sign-in may run it as the entry of a request: a page's call or hand-off, a declared REST
endpoint, an MCP tool, a live call or a stream. An unmarked function is refused — there is no exception for one that "only
reads", because nothing proves that of an arbitrary function; plain reads go through queries and CRUD reads. What a marked
function calls and writes follows that function's own rules (`security { }`, `deny … except via`), so the entities it writes
(an audit trail) need no marker.

**On an entity**, a break-glass sign-in may write it *directly* — REST and MCP CRUD, a page's save — under its own
`security { }`. Mark an entity only when direct CRUD on it is the repair; an unmarked entity is refused a direct write.

**Nothing is left to act later.** A break-glass sign-in's save is refused, before anything is written, when it would start
work that runs after the request: a new row whose entity starts a workflow (`Autostart`), a change an `Autostart` condition
reads (it would leave a row for a later save to start), a schedule it arms, or an event it raises (whoever handles it). A
set-based insert, update or delete of an entity a workflow starts on, or that a condition reads, is refused where it runs.
Those are the early refusals; the rule is the OUTCOME: at the end of every break-glass save, after its cascades and stored
values, the due sweep's own read asks whether any row now waits for a run it does not have, and if one does the save is
refused and rolled back — whatever wrote it (a computed member, a cascade, a set-based delete). It fails closed: a condition
the database cannot answer whole counts any row with no run, and a row left waiting by another session refuses the save too.
A condition that reads the clock (`Due <= DateTime.UtcNow`), or a computed member, can turn true later with nothing written,
so for it the check leaves out every part that may read the clock: any row with no run that the rest admits counts, however
far off its time. A set-based update the platform runs on its own connection is judged the same way before it commits, and a
write to an external data source — which commits in the source, outside the save — is refused before it is sent, as is a
set-based update aimed at another of the platform's databases. If the application's workflows could not be read when its
session was built, every break-glass save is refused: the check cannot tell which rows would wait.
A save is also refused when it would queue the platform's own work for later: an export's delivery (a change an export
reads) or the embedding pass (a row with a `[Searchable]` field, a semantic snapshot or indexed properties). A
workflow verb — `Workflow.Raise`, a `Correlate`, a row act, a slot's verb, a start — is refused at the call, and Admin's
platform calls are an allow-list too: only signing a sign-in client's secret grant. A workflow carries no
marker, so a break-glass sign-in starts none — even from a marked function, and even on a marked entity; a marked function's
`UnitOfWork.Commit()` starts no other run either. A page a break-glass sign-in saves is its own: it cannot commit a page
another session staged.

A break-glass sign-in is also refused every platform endpoint that is not on the list (an API key, a signed download link),
the debug channels (debug attach included), the platform's own log lines, an operation grant (so no log tail on a zone), and
everything on an app's runtime. Nothing is marked by default.

**Nothing outlives the hour.** A response to a break-glass sign-in — a function's stream included — is cut when the session
reaches its one-hour cap, and an app's log tail it opened closes then too. So does a stream's producer that runs on after
the response.

## See also       {#see-also}
- [[AuthMethod] — a function an unauthenticated visitor may call](https://osysharp.com/reference/security/auth-method/) — how a sign-in method is declared
- [security { }](https://osysharp.com/reference/security/entity-security/) — the `security { }` a marked entity is still written under
- [deny … except via](https://osysharp.com/reference/security/except-via/) — the `deny … except via` rules a marked function's writes still follow
- [secure by default (deny-all)](https://osysharp.com/reference/security/secure-by-default/) — why nothing is marked by default
