# UserInfo and scopes

```text
GET or POST https://sso.user.m7.org/userinfo
```

UserInfo returns claims for an active access token. M7 derives the owning OAuth
`client_id` from the validated token and applies that client's current policy.
A standard UserInfo request does not need a separate `client_id` parameter.

For an RFC 8705 certificate-bound access token, use the discovered
`https://mtls-sso.user.m7.org/userinfo` alias and present the same client
certificate whose SHA-256 thumbprint appears in `cnf."x5t#S256"`. A request
without that exact certificate fails closed; the access token cannot be used
as an ordinary bearer token.

## Request

For an unbound access token returned with `token_type: "Bearer"`:

```bash
curl --fail-with-body --silent --show-error \
  --header 'Authorization: Bearer ACCESS_TOKEN' \
  'https://sso.user.m7.org/userinfo'
```

For compatibility with older M7 clients, `client_id` may still be supplied as
a query parameter for `GET` or in the form body for `POST`. When supplied, it
is an additional assertion that MUST exactly match the validated token's
`client_id`; it never selects or overrides the token's client. M7 also accepts
`token` or `access_token` request fields for unbound compatibility requests.

For an access token returned with `token_type: "DPoP"`, send:

| Header | Required proof target |
| --- | --- |
| `Authorization: DPoP ACCESS_TOKEN` | The DPoP-bound access token. |
| `DPoP: USERINFO_PROOF` | Fresh proof for `https://sso.user.m7.org/userinfo` and the actual `GET` or `POST` method. |

The proof uses the key identified by the token's `cnf.jkt`, has a unique
`jti`, and binds the exact access token with
`ath = base64url(SHA-256(ACCESS_TOKEN))`. It is single-use. For consumer and
tenant-member tokens, SSO converts the verified binding into a sealed,
one-use internal attestation for the exact downstream profile request. Clients
do not create a second proof or send an M7-specific relay header. A
machine-application UserInfo request does not load a human session.

When the access token is fingerprint-bound, also send its matching
`fingerprint` request field. A lineage bound by both fingerprint and DPoP needs
both forms. An unbound token must not use the `DPoP` scheme, send a `DPoP`
proof, or send any relay value; the internal relay is not a client input. See
[DPoP status](https://m7.org/docs/api/sso.user.m7.org/authorization.md#dpop-status).

An absent, invalid, expired, revoked, or mismatched token returns HTTP 401 with
`error: "invalid_token"`. A valid token issued to a different `client_id`
returns `insufficient_scope` with HTTP 403. A missing, malformed, stale,
replayed, wrong-method, wrong-URI, or wrong-`ath` DPoP proof returns HTTP 401
with `invalid_dpop_proof` and a `WWW-Authenticate: DPoP` challenge advertising
`algs="ES256"`. A token, authorization-scheme, or wrong-key binding failure
uses `invalid_token`.

UserInfo is an OIDC control-plane projection, not one of the token's business
resource servers. It therefore does not require a dedicated UserInfo audience.
The token's resource `aud` continues to govern use at those resources, while
UserInfo access is controlled by active-token validation, exact client
ownership, and the `openid` and claim-family scopes below.
UserInfo also applies current client registration policy to the verified
token. A token whose signed scope or resource-audience set is no longer fully
registered is inactive, even though UserInfo itself does not require an SSO
audience. Only the audience UUID matching the verified nested
`m7.target_client_id` is recognized as issuer-added metadata; an arbitrary UUID
does not bypass the registration check. This access-token stamp is separate
from the UserInfo `m7` identity projection below. For
an organization-owned client, the organization must also still exist and be
active and non-archived; UserInfo fails closed when that state cannot be
verified.

The access token must include `openid`. A valid access token without `openid`
returns HTTP 403 with `error: "insufficient_scope"` and advertises the required
scope in `WWW-Authenticate`. M7 does not infer `openid` or `profile` for legacy
tokens that have no scope claim.

## Consumer organizations

Use the separate [consumer organization discovery endpoint](https://m7.org/docs/api/sso.user.m7.org/userinfo-orgs.md),
`GET`/`POST /userinfo/orgs`, with the registered and consented `orgs` scope.
It returns caller access level, the implicit Management group/membership,
membership `pub`, assigned tags with definition `data`, and per-org `consumer`
and `tenant` app identity lists. An `orgs`-only token
can call it; this standard `/userinfo` endpoint still requires `openid`.
Ordinary client-credentials apps can retrieve their own explicit Management
memberships using registered, explicitly requested `orgs`. Creator membership
is never inherited by ordinary apps. Validated personal owner proxies can retrieve
their current registered owner's direct Management memberships, with separate
receiving-service disclosure checks and the machine's original response subject.
Tenant member tokens are ineligible.

For primary email use `openid email` here. The account email list is separately
available through [API User and the SDK](https://m7.org/docs/sdk/m7-identity/cli/account-emails.md)
with `account.me.email.list` and an API User access bundle. SSO advertises no
separate email-list endpoint, and `email` does not authorize API User's list.

## Response format

The registered client controls the response format. With no
`userinfo_signed_response_alg` override, UserInfo returns the claims as
`application/json`. A client registered for `RS256` or `RS512` receives the
same authorized claims as a signed JWT with `Content-Type: application/jwt`.

The signed JWT includes the canonical SSO `iss`, the requesting `client_id` as
`aud`, and the same required `sub` and scope-authorized claims described below.
Validate its `kid` and signature against the SSO `jwks_uri`, then require the
returned `iss`, `aud`, and `sub` to match the expected issuer, client, and
authenticated subject. Response signing is registration policy; it cannot be
toggled with a `/userinfo` request parameter.

With registered `userinfo_encrypted_response_alg=RSA-OAEP-256` and
`userinfo_encrypted_response_enc=A256GCM`, the same signed JWT is encrypted to
the application's registered public key. The response remains `application/jwt`
with no-store headers. The client must decrypt before checking the inner
signature and claims. Runtime enforces RS256/RS512 signed UserInfo as a
prerequisite; malformed policy, key or signer failure never falls back to JSON.
This path is locally tested; runtime deployment and SDK decryption remain
pending. See [response encryption](https://m7.org/docs/api/sso.user.m7.org/response-encryption.md).

## Scope-to-claim mapping

Every successful response includes `sub`, the canonical subject ID. Other
claims depend on the granted access-token scopes.

| Scope | Claims returned |
| --- | --- |
| `openid` | Required to call UserInfo, enables OpenID Connect semantics and ID-token issuance at `/token`, and permits the canonical `sub` response. |
| `profile` | Standard profile claims and the M7 profile projection. |
| `email` | Primary active email address as `email` and its state as `email_verified`, when one exists. |
| `groups` | Tenant-member organization and group claims. It does not expose consumer-account groups. |
| `offline_access` | Requests durable offline-access behavior; it does not itself add UserInfo claims. |

### Principal-list membership

For a validated access token already carrying `m7.principal`, standard
UserInfo returns `m7.principal` from the current association to that token's
application list. `openid` is sufficient for this lookup; `groups` still
controls the separate tenant organization/group projection. UserInfo does not
enroll a member. It requires the current principal ID and list to match the
signed token, and a signed `pending` or `denied` status cannot become `active`
through this lookup. Active membership includes its current `role` and JSON
`data`; pending or denied results contain only `id`, `status`, and `list`.
Each app independently decides whether new access tokens include role and
data; both token-enrichment switches default off. UserInfo returns both
current fields for an active member regardless of those switches, including
a stored role that has since been removed from the list's selectable choices.
Changing the membership or list settings does not rewrite an issued access
token. A receiving service must check `status`
before using either projection for authorization.

## Consumer-user response

For a consumer-user token with `profile` and `email`, the response resembles:

```json
{
  "sub": "USER_UUID",
  "name": "Alice Example",
  "preferred_username": "alice",
  "picture": "https://cdn.example.com/alice.png",
  "locale": "en-US",
  "website": "https://example.com",
  "zoneinfo": "UTC",
  "updated_at": 1786309200,
  "email": "alice@example.com",
  "email_verified": true,
  "m7": {
    "user": {
      "id": "USER_UUID",
      "handle": "alice"
    },
    "links": {}
  }
}
```

The exact `m7.user` profile projection may include publicly available profile
metadata. M7 can also return `m7.preferences` when the account has opted to
publish preferences. Treat the `m7` object as an extension that may gain
additional fields; ignore fields your application does not understand.

## Tenant-member response

For a tenant member, `sub` is the canonical member ID. With `profile`, M7
returns the same standard profile names where available and adds
`m7.client`. With `groups`, it can add `m7.org` and `m7.groups`:

```json
{
  "sub": "MEMBER_UUID",
  "name": "Alice Example",
  "preferred_username": "alice",
  "m7": {
    "client": {
      "id": "MEMBER_UUID",
      "handle": "alice"
    },
    "org": {
      "id": "ORG_UUID",
      "name": "Example Organization"
    },
    "groups": [
      { "id": "GROUP_UUID", "name": "Engineering", "slug": "engineering" }
    ]
  }
}
```

Applications must authorize actions using the organization and group state
returned at the time of the request, not by assuming cached membership remains
valid indefinitely.

## Machine-application response

For a `client_credentials` access token, `sub` equals the public OAuth
`client_id`. M7 does not load a human session. With `profile`, `m7.application`
contains the application's record ID, client ID, handle, application type, and
tenant ID when applicable.

## Privacy and reliability

- Request only scopes your application needs.
- Treat `email` as optional even when `email` scope is granted; an account may
  have no active primary email.
- Use `sub` as the durable identifier. Do not use a display name or email as a
  database key.
- Do not assume profile or `m7` extension fields are always present.
- Do not use UserInfo as a substitute for resource-server authorization. Each
  resource must still validate the token and require its own audience and
  scopes.
