# Authorization requests, PAR, and JAR

The authorization endpoint is the browser entry point for authorization code
flow:

```text
GET https://sso.user.m7.org/authorize
```

Use the discovery document for the live endpoint URL. M7 presents sign-in and
related user interaction in the browser. Top-level navigation is the default;
[Web Message modes](https://m7.org/docs/api/sso.user.m7.org/response-modes.md#web-message-popup-and-iframe) also
support a popup or an approved embedding origin.

## Hosted two-factor verification

An enabled consumer setting may require an authenticator or recovery code
during password sign-in, email sign-in, or reuse of an open account. M7 handles
this within the hosted authorization flow. Keep the original transaction's state, nonce,
and PKCE material until completion. An account-verification step due during
`prompt=none` returns `login_required` with
`error_reason=account_two_factor_required`; start a fresh interactive request
when the user chooses. See [two-factor authentication](https://m7.org/docs/api/sso.user.m7.org/two-factor-authentication.md).

Consumer users may choose [email sign-in](https://m7.org/docs/api/sso.user.m7.org/email-sign-in.md) on the hosted
login page. Both the link and code return through this same authorization
transaction; application callback and token-exchange handling are unchanged.

## Ordinary request parameters

| Parameter | Required | Description |
| --- | --- | --- |
| `client_id` | Yes | Public identifier of the registered OAuth client. |
| `redirect_uri` | Yes | Exact registered HTTPS callback URI. |
| `response_type` | Yes | Must be `code`. |
| `response_mode` | No | One exact registered and advertised mode; omission selects `query`. See the [ten-mode delivery table](https://m7.org/docs/api/sso.user.m7.org/response-modes.md#delivery-table). |
| `state` | Yes | Opaque, high-entropy CSRF correlation value. Returned unchanged on success. |
| `code_challenge` | Yes | PKCE challenge derived from your code verifier. |
| `code_challenge_method` | Yes | Must be the exact, case-sensitive value `S256`; `plain`, omitted, and unknown methods are rejected. |
| `scope` | No | Space-delimited requested scopes. Every value must exactly match a scope registered for the client. Omission requests the client's full registered set. |
| `aud` | No | Exact resource audience. Repeat it to request several audiences. Every value must match the client's registered `allowed_audiences`; omission requests the complete configured set. |
| `nonce` | Recommended with `openid` | Returned in the ID token, allowing the relying party to bind the token to this browser transaction. |
| `dpop_jkt` | Recommended for DPoP authorization-code flow | Canonical unpadded base64url SHA-256 thumbprint of the DPoP public JWK. It binds the authorization code to that key. |
| `prompt` | No | Space-delimited, case-sensitive values: `none`, `login`, `consent`, and `select_account`. M7 also supports the exclusive `create` extension. |
| `max_age` | No | Non-negative maximum authentication age in seconds. |
| `login_hint` | No | An email address or username hint used to prefill the sign-in experience. |
| `request` | Conditional | A signed Request Object for a JAR-enabled client; use the separate [JAR request contract](https://m7.org/docs/api/sso.user.m7.org/authorization-requests.md#signed-request-objects-jar). |
| `request_uri` | Conditional | An M7-issued [PAR](https://m7.org/docs/api/sso.user.m7.org/authorization-requests.md#pushed-authorization-requests-par) value, or an exactly registered HTTPS Request Object URI for a JAR-enabled client. |

M7 supports only `response_type=code` across all ten response modes.
`redirect_uri` must be a valid HTTPS URL and match one of the client's
registered redirect URIs exactly, including path, query, and trailing slash.
Scope names are case-sensitive opaque strings. M7 normalizes separating
whitespace, removes duplicates while preserving first-requested order, and
returns `invalid_scope` when any requested value is not registered. An empty
registered allowlist grants no scope; it never means unrestricted.
Audience identifiers are also case-sensitive and exact: M7 does not normalize
hosts, paths, ports, or trailing slashes. An authorization may select any
nonempty subset of the registered audiences. A one-value result is emitted as
a JWT string and a multi-value result as a JWT `aud` array. An empty audience
allowlist cannot issue a token.
`/authorize` rejects a missing or malformed challenge before beginning the
hosted flow. The challenge must contain 43 to 128 RFC 3986 unreserved
characters, and the matching verifier must be retained exactly for `/token`.

When `max_age` is omitted, M7 applies the client's registered
`default_max_age`, if configured. An explicit request value, including `0`,
overrides that default. Freshness is measured from the immutable time of the
last successful authentication, not from later session activity. When the
effective age has elapsed, the user must authenticate again. A client with
`require_auth_time=true` receives `auth_time` in every ID token, but that
setting alone does not impose a freshness limit.

### Prompt values

| Value | Behavior |
| --- | --- |
| `none` | Requests a non-interactive result. If M7 cannot continue without interaction, the authorization attempt fails rather than showing a sign-in page. |
| `login` | Requests fresh sign-in. |
| `consent` | Requires an explicit authorization decision for this request, even when an active grant already covers the request. |
| `select_account` | Requires the M7 account chooser before authorization continues; the user may select an eligible remembered account or sign in with another account. |
| `create` | Starts the account-creation path for eligible clients. |

Standard values other than `none` may be combined, for example
`prompt=login consent` or `prompt=select_account consent`. `none` must be the
only value when present. M7's `create` extension is also exclusive and cannot
be combined with a standard value. Repeated values are collapsed while their
first-requested order is retained; unknown values and incorrect casing are
rejected with `invalid_request`.

### Consent behavior

Every consumer or tenant OAuth application requires consent from the authenticated
individual account. M7 asks for consent when no active grant covers both the
requested scopes and audiences, then records the approved permissions. A later
request covered by one active grant can continue without another consent screen.
New permissions or target services require a new decision.

`prompt=consent` always requests a fresh, request-bound decision. `prompt=none`
returns `login_required` when authentication is needed, or `consent_required` when
no covering grant exists. Start an interactive request to obtain consent.

The Authorized Apps page offers two revocation choices. Both mark the account's
grants inactive and make the next authorization require consent again:

- **Let them expire normally** preserves existing access and refresh tokens under
  their normal expiry/rotation rules.
- **Revoke open sessions** also revokes the access and refresh sessions issued
  under those grants, including rotated tokens and pending activation candidates.
  The root M7 SSO login, other applications, and other users remain active.

Revoked records remain as history. A later approval creates a new grant ID and
cannot revive old revoked tokens. Browser code redemption, browser-direct pickup
and Device Code pickup validate their original active grant before initial
issuance. Refresh retains its original grant ID; consent-only removal permits
that lineage to continue, whereas session revocation rejects it.

Revocation is authoritative at Identity's online token validation/introspection.
Applications validating JWTs entirely offline can accept an issued token until
expiry. Application-owned cookies are not deleted by this operation; the app
observes withdrawal when it next validates or refreshes its credentials.
Failed upstream revocations remain pending and retry the original saved grant
snapshot, including after a lost response; a retry cannot select newly approved
consent. See [Authorized Apps](https://m7.org/docs/api/api.user.m7.org/authorized-apps).

Registration ownership and organization membership do not grant user consent or
make it organization-wide. App-to-app connection approvals remain a separate
feature under Advanced Application Connections.

## Success and errors

After successful user interaction, M7 redirects to the registered callback:

```text
https://app.example.com/callback?code=AUTHORIZATION_CODE&state=STATE
```

The authorization code is confidential, short-lived, and single-use. Exchange
it only from your application. Validate `state` before using the code, then
send the code and the original PKCE verifier to `/token`.
When the authorization request included `dpop_jkt`, the token request must
also contain a valid `DPoP` proof signed by that exact key. A missing or
different proof is rejected with `invalid_dpop_proof`.

When M7 can safely return an error to the callback, it uses a top-level browser
`GET` with the OAuth `error`, M7 `error_reason`, optional safe
`error_description`, optional opaque `trace_id`, and original `state` in the
query. Validate state before acting on either a success or an error. A malformed
request that has no trusted redirect URI receives an error at M7 instead of
being redirected.

For a rejected scope after the exact callback has been validated, the callback
uses `error=invalid_scope` and
`error_reason=authorization_scope_not_allowed`, with the original byte-exact
`state`.

For a rejected audience set after the exact callback has been validated, the
callback uses `error=invalid_target` and
`error_reason=authorization_audience_not_allowed`, with the original
byte-exact `state`.

See [Authorization callback outcomes](https://m7.org/docs/api/sso.user.m7.org/authorization-callback-outcomes.md) for
the complete error and cancellation matrix, field-dependency rules,
retryability, PAR re-entry behavior, and required client actions.

## Pushed Authorization Requests (PAR)

PAR lets a client send authorization parameters directly to M7 before the
browser redirect. It is useful when request parameters are lengthy or should
not appear in the front-channel URL.

```text
POST https://sso.user.m7.org/par
Content-Type: application/x-www-form-urlencoded
```

Authenticate the client using its registered token-endpoint authentication
method. The PAR request carries the same authorization parameters as
`/authorize`: `client_id`, `redirect_uri`, `response_type=code`, `state`, PKCE
parameters, and any optional authorization parameters.

For authorization-code key binding, either send `dpop_jkt` in the PAR form
body or attach a `DPoP` proof for exact HTU `https://sso.user.m7.org/par` and
HTTP method `POST`. M7 derives the thumbprint from the proof. If both forms are
present, they must identify the same key. A PAR proof needs a fresh `jti` but
does not contain `ath`; it is replay protected independently of the later
token and resource proofs.

For `client_secret_jwt` or `private_key_jwt`, the client assertion audience is
either the canonical authorization-server issuer `https://sso.user.m7.org` or
the exact PAR endpoint URL, `https://sso.user.m7.org/par`.

An mTLS-authenticated client presents its registered certificate and sends
the PAR request to the discovered
`https://mtls-sso.user.m7.org/par` alias. The resulting browser authorization
request still uses the canonical authorization endpoint and issuer.

Example with `client_secret_basic`:

```bash
curl --fail-with-body --silent --show-error \
  --request POST 'https://sso.user.m7.org/par' \
  --user 'CLIENT_ID:CLIENT_SECRET' \
  --data-urlencode 'client_id=CLIENT_ID' \
  --data-urlencode 'redirect_uri=https://app.example.com/oauth/callback' \
  --data-urlencode 'response_type=code' \
  --data-urlencode 'scope=openid profile email' \
  --data-urlencode 'state=STATE' \
  --data-urlencode 'nonce=NONCE' \
  --data-urlencode 'code_challenge=CODE_CHALLENGE' \
  --data-urlencode 'code_challenge_method=S256'
```

On success, M7 returns HTTP `201 Created` with an opaque URI and expiry:

```json
{
  "request_uri": "urn:ietf:params:oauth:request_uri:OPAQUE_VALUE",
  "expires_in": 600
}
```

Immediately redirect the browser to `/authorize` with the returned
`request_uri` and, optionally, the matching `client_id`:

```text
https://sso.user.m7.org/authorize?client_id=YOUR_CLIENT_ID&request_uri=REQUEST_URI
```

Do not add or override request fields in this browser request. M7 hydrates the
stored request; a supplied `client_id` must match it. Start a new PAR request
if it expires.

## Signed Request Objects (JAR)

JAR signs the authorization request before the browser sends it to M7. Enable
JAR in the OAuth client's **Request Policy** in the
[M7 account application](https://user.m7.org/), select one signing algorithm
(`RS256`, `RS384`, `RS512`, or `ES256`), and configure exactly one public key
source: inline JWKS or a public HTTPS JWKS URI. Register each customer-hosted
Request Object URI exactly before using it. JAR keys are separate from the
client's token-endpoint authentication keys. Enabling JAR permits signed
requests; ordinary authorization remains available.

### Send the signed request

Use top-level browser `GET /authorize` with the outer `client_id` and exactly
one of these mutually exclusive delivery parameters:

| Parameter | Value |
| --- | --- |
| `request` | Compact signed JWS containing the Request Object. |
| `request_uri` | Exact registered public HTTPS URI whose response is that compact JWS. |

URL-encode each query value independently. For URI delivery, the browser URL
has this form:

```text
https://sso.user.m7.org/authorize?client_id=CLIENT_ID&request_uri=https%3A%2F%2Fapp.example.com%2Foauth%2Frequest.jwt
```

The signed object's required claims are:

| Claim | Contract |
| --- | --- |
| `iss` and `client_id` | Both equal the exact outer `client_id`. |
| `aud` | The canonical authorization-server issuer `https://sso.user.m7.org`, or an array containing that exact value. This is not the resource audience. |
| `exp` | Integer expiry time in seconds since the Unix epoch; use a short validity period. |
| `jti` | Fresh nonempty string, at most 512 bytes; never reuse it for another authorization attempt. |
| `redirect_uri`, `response_type`, `state`, `code_challenge`, `code_challenge_method` | The ordinary authorization-code requirements above; `response_type=code` and PKCE `S256` remain mandatory. |

Put optional authorization parameters such as `scope`, `nonce`, `prompt`,
`max_age`, and `dpop_jkt` inside the signed object. Optional `iat` and `nbf`
must be valid numeric dates. M7 permits 60 seconds of clock skew for JWT time
checks. Use the exact configured JOSE algorithm and a `kid` that identifies
the verification key. Unsigned objects, encrypted objects, nested delivery
parameters, and unsupported critical JWS headers are rejected.

The signed inner authorization parameters are authoritative. Outer query
parameters cannot override signed redirect, state, scope, PKCE, prompt, or
other authorization choices. Because JWT `aud` identifies M7, this JAR profile
uses the client's complete registered resource-audience set. It does not
provide a separate signed resource-subset selector.

### Host the Request Object and keys

The Request Object endpoint must return HTTP 200 with
`Content-Type: application/oauth-authz-req+jwt` or `application/jwt`. A remote
JWKS endpoint must return HTTP 200 with `application/jwk-set+json` or
`application/json`. Both must use publicly reachable HTTPS with a valid TLS
certificate; redirects, private destinations, credentials in URLs, and URI
fragments are rejected. Documents are limited to 256 KiB, and URI values to
2048 bytes. Browser URL-size limits can further restrict by-value delivery.

M7 fetches and verifies the Request Object before user interaction and
preserves those accepted parameters for the transaction. Changing the hosted
object during sign-in cannot change the authorization already in progress.
A replay or invalid request fails before code issuance; restart with a freshly
signed object and a new `jti`. URI/retrieval and signature/claim failures are
rejected at M7 until a trustworthy callback can be established. Never log the
raw Request Object, private keys, or PKCE verifier.

JAR submission to `/par`, JAR policy configuration through `/register`, and
encrypted Request Objects are not supported in this profile. Signed authorization responses are a
separate [JARM capability](https://m7.org/docs/api/sso.user.m7.org/response-modes.md#signed-authorization-responses-jarm).
Existing unsigned PAR and ordinary authorization continue to use their
documented contracts.

## Security requirements

- Always use `state`, validate it on return, and expire it after one use.
- Always use PKCE `S256`; authorization rejects a missing challenge or method,
  and redemption fails closed if the sealed PKCE binding is invalid.
- Do not use an unregistered redirect URI or construct a redirect URI from
  user input.
- Do not send client secrets in the browser or in an `/authorize` URL.
- Do not place authorization codes in logs, analytics, screenshots, or issue
  reports.

## Consumer organization consent

Request explicit registered `orgs` for a consumer organization selector.
Hosted authorization requires consent for it; omitted scopes cannot grant it.
After authorization, fetch the separate [org endpoint](https://m7.org/docs/api/sso.user.m7.org/userinfo-orgs.md).
Tenant `groups`, standard `openid` UserInfo, and product resource authorization
retain separate contracts. Device authorization also requires hosted
[consent after authentication](https://m7.org/docs/api/sso.user.m7.org/device-authorization.md#user-approval) for `orgs`.
