# How a request is decided

What the platform checks on every request, in which order, what a refusal looks like and what is recorded.

Identity and Access Management runs inside the Deutsche Cloud control plane; nothing of it runs on
your machines. Every request to the console or the API goes through the same steps.

## The steps

1. **Who is calling.** A console session, an access key (`Authorization: EWS-ACCESS-KEY <key id>:<secret>`)
   or an app you connected. The credential decides the organization; an organization id in the
   request body or path never does.
2. **Which policies.** The IAM user's policies: attached directly, through its groups and through
   its roles. They are read on every request, so a policy you attach or detach counts from the next
   request on. A managed policy's document is the platform's current definition of that name.
3. **Which action and resource.** The route names one action (`ec2:StopInstances`) and one
   resource name (`rn:ews:de1:org-EXAMPLE1234:ec2:instance/i-0123`), and the request supplies the
   condition keys it carries (source address, second factor, time, region, zone).
4. **The decision**, in this order:
   1. A `Deny` statement that matches and whose condition applies: **denied**. Nothing overrides
      it, not even `AdministratorAccess`.
   2. Otherwise, a matching `Allow` whose condition holds: **allowed**.
   3. Otherwise: **denied** (implicitly).
5. **The credential's own limit.** An access key with a scope, and an app you connected, are capped
   on top of the policies: the request must also fit the key's scope or the access the app was
   granted, or it is denied whatever the policies allow.

A stored document that cannot be read contributes no statements: it never grants anything.

## What a refusal looks like

The API answers `403`:

```json
{
  "success": false,
  "error": "Forbidden",
  "message": "Not allowed: ec2:StopInstances on rn:ews:de1:org-EXAMPLE1234:ec2:instance/i-0123. Ask an administrator for a policy that allows it.",
  "action": "ec2:StopInstances",
  "resource": "rn:ews:de1:org-EXAMPLE1234:ec2:instance/i-0123"
}
```

The [policy simulator](test-access-with-the-simulator.md) answers the same question for any user
or role without making the request, and names the statement that decides it.

## What is recorded

- Every write, allowed or refused, with its outcome.
- Every sensitive read (secret values, source code), also when it is allowed.
- A refused ordinary read that ends in `403`: at most one entry a minute for the same principal and
  action, the next one saying how many were left out.

Allowed ordinary reads are not recorded. Read the entries under **Identity** → **Audit log**; see
[Monitoring](monitoring.md).

## Related

- [Principals and policies](principals-and-policies.md)
- [Policy documents](policy-documents.md)
- [Security](security.md)
