<!-- Generated by website/scripts/sync-docs.mjs from docs/usage.md. Edit that file, not this one. -->

# Usage

> Every page of this site: https://dyokto.github.io/saysno/llms.txt

## What it does

- Decodes a JWT from GitHub Actions, GitLab CI/CD (`id_tokens`), a Kubernetes projected service account token, or any OIDC provider, and shows the claims the decision depends on.
- Evaluates an AWS role trust policy the way STS does for `sts:AssumeRoleWithWebIdentity`: `Principal.Federated` against the token issuer, `Action` / `NotAction`, every condition key and operator, explicit Deny over Allow, and `sts:TagSession` when the token carries session tags.
- Evaluates Entra federated identity credentials: exact issuer, subject and audience, and flexible credentials with a `claimsMatchingExpression`.
- Explains the GitHub immutable subject change. Repositories created, renamed or transferred after 2026-07-15 send `sub` as `repo:OWNER@ID/REPO@ID:...`, so trust policies written for `repo:OWNER/REPO:...` stop matching. When that is the cause, `saysno` says so and prints the corrected pattern.
- `saysno reverse` reads an AWS trust policy without a token and lists which subjects it accepts, flagging patterns that accept more than intended.

## What it does not do

- It does not call AWS, Azure or the token issuer. It cannot see whether the IAM OIDC provider exists or which client IDs it lists, resource control policies, or Conditional Access. The output lists these under "not checked".
- It does not verify the token signature unless you pass `--verify-jwks`. Without it the output says `signature NOT VERIFIED` and the verdict assumes the signature is valid.
- It does not evaluate GCP Workload Identity Federation attribute conditions (CEL). Planned for v0.2.
- `reverse` covers AWS trust policies only.

## Commands and flags

```bash
saysno check   --policy trust.json token.jwt        # AWS trust policy
saysno check   --policy fic.json   token.jwt        # Entra federated credential(s)
saysno reverse --policy trust.json --issuer github  # what does this policy accept?
saysno decode  token.jwt                            # claims as JSON, no evaluation
```

The token can be an argument, a file (`--token-file`, or a path as the argument), or standard input. `--policy` accepts a policy document, the output of `aws iam get-role` (including the URL-encoded form the IAM API returns), `az identity federated-credential show|list`, `az ad app federated-credential show|list`, or a Microsoft Graph `federatedIdentityCredential` (single or collection).

Flags for `check`:

```text
--policy FILE         AWS trust policy or Azure federated credential(s); type is detected
--type aws|azure      skip detection
--token-file FILE     read the token from FILE ("-" for stdin)
--verify-jwks SRC     verify the signature with a JWKS from an https URL or a file
--context KEY=VALUE   request-side AWS key such as aws:SourceIp or sts:RoleSessionName (repeatable)
--at RFC3339          check exp/nbf at this time instead of now
--json                print saysno.result/v1 JSON
--no-color            no colour (also NO_COLOR=1; colour is only used on a terminal)
```

Exit status of `check`: `0` allowed, `1` denied, `2` cannot evaluate or usage error. Exit status of `reverse`: `0` no high or critical finding, `1` at least one, `2` error.

### Getting the token in GitHub Actions

A GitHub Actions token is valid for minutes, so run `saysno` in the same job, right after the step that failed. The job needs `permissions: id-token: write`.

```yaml
- name: Why was the role refused?
  if: failure()
  run: |
    TOKEN=$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
      "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" | jq -r .value)
    aws iam get-role --role-name deploy-app > role.json   # or commit the policy file
    echo "$TOKEN" | saysno check --policy role.json
```

The token is a live credential until it expires. Do not paste it into an issue or a chat; `saysno decode` shows the claims without it.

### Example: immutable subject against a name-based policy

The repository below was created after 2026-07-15, so GitHub sends the immutable `sub`. The trust policy still uses the name form. The token and policy are the fixtures in [testdata/](https://github.com/dyokto/saysno/tree/main/testdata).

```text
$ saysno check --policy testdata/aws/trust-name-form.json testdata/tokens/github-immutable.jwt
token  github-actions  alg EdDSA  kid saysno-fixture-1
  iss  https://token.actions.githubusercontent.com
  sub  repo:octo-org@1000001/deploy-app@2000002:ref:refs/heads/main  (immutable-ID form)
  aud  sts.amazonaws.com
  ...
signature  NOT VERIFIED  pass --verify-jwks <url|file> to check it; the verdict below assumes the signature is valid
target  aws-trust-policy  testdata/aws/trust-name-form.json
  1 statement(s); evaluated for sts:AssumeRoleWithWebIdentity

token checks
  PASS     exp
           actual    "2026-12-03T09:01:00Z"
  PASS     nbf
           actual    "2026-12-03T09:01:00Z"

Statement[0] GitHubDeploy  Allow  does not apply
  PASS     Principal.Federated
           expected  "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
           actual    "arn:aws:iam::<account>:oidc-provider/token.actions.githubusercontent.com"
  PASS     Action
           actual    "sts:AssumeRoleWithWebIdentity"
  PASS     StringEquals token.actions.githubusercontent.com:aud
           actual    "sts.amazonaws.com"
  FAIL     StringLike token.actions.githubusercontent.com:sub
           expected  "repo:octo-org/deploy-app:ref:refs/heads/main"
           actual    "repo:octo-org@1000001/deploy-app@2000002:ref:refs/heads/main"

verdict  DENIED  no Allow statement matches the token (implicit deny)

likely fix
  1. The token's sub uses GitHub's immutable-ID form
     (repo:octo-org@1000001/deploy-app@2000002:...), but the trust pattern
     "repo:octo-org/deploy-app:ref:refs/heads/main" uses the name form.
     Repositories created, renamed or transferred after 2026-07-15 (or opted in)
     send the immutable form, so name-based patterns stop matching.
     try: repo:octo-org@1000001/deploy-app@2000002:ref:refs/heads/main

not checked (outside the inputs)
  - that an IAM OIDC provider for token.actions.githubusercontent.com exists in
    the role's account and lists "sts.amazonaws.com" among its client IDs
    (audiences)
  - resource control policies (RCPs) and the role's other settings; an RCP can
    deny sts:AssumeRoleWithWebIdentity
  - the token signature (no --verify-jwks)
```

The full outputs for every fixture, including Entra flexible credentials, an explicit Deny, a GitHub environment job and an EKS service account, are in [testdata/golden/](https://github.com/dyokto/saysno/tree/main/testdata/golden). `--json` output for the same run: [testdata/golden/aws-json.json](https://github.com/dyokto/saysno/blob/main/testdata/golden/aws-json.json).

### Example: reverse

```text
$ saysno reverse --policy testdata/aws/trust-broad.json
...
Statement[0] OrgWide accepts tokens from token.actions.githubusercontent.com
  audience  any (no aud condition)
  subject   repo:octo-org/*                                  StringLike: every repository of octo-org, any branch, tag, pull request or environment
...
findings
  CRITICAL Statement[2] Anything: sub pattern "repo:*:ref:refs/heads/main" matches repositories of every GitHub owner.
  HIGH     Statement[0] OrgWide: sub pattern "repo:octo-org/*" accepts every repository of octo-org, including repositories created later, on any branch, tag, environment or pull_request run.
  ...
```
