Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions en/includes/guides/authorization/rich-authorization-requests.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Rich Authorization Requests

Rich Authorization Requests (RAR) ([RFC 9396](https://datatracker.ietf.org/doc/html/rfc9396){:target="_blank"}) enhance authorization mechanisms by allowing clients to specify fine-grained authorization details in a structured format.

Check failure on line 3 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:3:235 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
This guide outlines how to configure your application for RAR, authorize API resources, customize authorization validation, and obtain tokens with authorization details.

## Configuring your application for RAR

Check failure on line 6 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Headings should be surrounded by blank lines

en/includes/guides/authorization/rich-authorization-requests.md:6 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## Configuring your application for RAR"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md022.md
You can go through the following steps to prepare your application for rich authorization requests.

### Step 1: Register a new authorization details type

Before using RAR, you need to define the authorization details types that your application supports.

Check failure on line 11 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:11:101 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
This involves registering an authorization details types using the [API Resource Management Rest API]({{base_path}}/apis/api-resource-management-rest-api/).
(The `authorizationDetailsTypes` field in the request payload follows the JSON Schema Draft 2020-12 standard.)

The following sample request registers a new authorization details types named `payment_initiation` for a Payments API

Check failure on line 15 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:15:119 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
and the response contains details of the newly registered API resource and its authorization details types.
This payload's schema can be referenced as a representation of [Figure 1](https://datatracker.ietf.org/doc/html/rfc9396#figure-1) in the RAR specification.

Expand Down Expand Up @@ -101,7 +101,7 @@
}
```

Once registered, to retrieve the supported authorization details types, invoke the discovery endpoint of {{product_name}}.

Check failure on line 104 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:104:123 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
The response confirms that the `payment_initiation` authorization details type is registered and available for use.

=== "Sample request (/openid-configuration)"
Expand Down Expand Up @@ -147,15 +147,15 @@
```

=== "Sample response (/authorized-apis)"

Check failure on line 150 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:150:1 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 4] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
```curl
HTTP/1.1 200 OK
```

### Step 3: (Optional) Customize authorization details validation

By default, {{product_name}} validates authorization details against the registered authorization details type schema.

Check failure on line 157 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:157:119 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
However, if additional validation is required, you can extend the `org.wso2.carbon.identity.oauth2.rar.core.AuthorizationDetailsProcessor`

Check failure on line 158 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces

en/includes/guides/authorization/rich-authorization-requests.md:158:139 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
Java interface and provide mechanisms to validate, enrich, and identify authorization details specific to your type.
To execute your custom validation, create a JAR file with your implementation and place it in `<IS_HOME>/repository/components/lib` directory and restart the server.

Expand All @@ -163,14 +163,14 @@

```java
ValidationResult validate(AuthorizationDetailsContext authorizationDetailsContext) throws AuthorizationDetailsProcessingException, IdentityOAuth2ServerException;
```

Check failure on line 166 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Fenced code blocks should be surrounded by blank lines

en/includes/guides/authorization/rich-authorization-requests.md:166 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
`validate` method is invoked once a new Rich Authorization Request is received to ensure that the
authorization details are valid and meet the required criteria. The validation logic should
be specific to the type of authorization details handled by the implementing class.

```java
String getType();
```

Check failure on line 173 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / lint

Fenced code blocks should be surrounded by blank lines

en/includes/guides/authorization/rich-authorization-requests.md:173 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
`getType` method used to retrieve the type of authorization details handled by this processor. Each implementation should return a unique type identifier that represents the kind of
authorization details it processes

Expand Down Expand Up @@ -323,9 +323,78 @@

The client application can now retrieve the user's payment information from the resource server by including the obtained access token in the request.

### Sample authorization code grant flow

The authorization code grant is a front channel grant that requires user interaction and consent. This section describes how to use rich authorization requests with the authorization code flow.

Check warning on line 328 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / Vale style check

[vale] reported by reviewdog 🐶 [write-good.E-Prime] Try to avoid using 'is'. Raw Output: {"message": "[write-good.E-Prime] Try to avoid using 'is'.", "location": {"path": "en/includes/guides/authorization/rich-authorization-requests.md", "range": {"start": {"line": 328, "column": 30}}}, "severity": "INFO"}

#### Step 1: Initiate authorization request

Check warning on line 330 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / Vale style check

[vale] reported by reviewdog 🐶 [write-good.TooWordy] 'Initiate' is too wordy. Raw Output: {"message": "[write-good.TooWordy] 'Initiate' is too wordy.", "location": {"path": "en/includes/guides/authorization/rich-authorization-requests.md", "range": {"start": {"line": 330, "column": 14}}}, "severity": "WARNING"}

The client initiates an authorization request to the authorization endpoint with the `authorization_details` parameter. The request includes the url-encoded `payment_initiation` authorization details type.

=== "Sample request (/authorize)"

```bash
https://localhost:9443/oauth2/authorize?response_type=code&client_id=<clientID>&redirect_uri=<redirectURI>&scope=openid&authorization_details=%5B%7B%22type%22%3A%22payment_initiation%22%2C%22actions%22%3A%5B%22initiate%22%5D%2C%22locations%22%3A%5B%22https%3A%2F%2Fexample.com%2Fpayments1%22%5D%2C%22instructedAmount%22%3A%7B%22currency%22%3A%22USD%22%2C%22amount%22%3A%223000.00%22%7D%2C%22creditorName%22%3A%22Merchant%20A%22%2C%22creditorAccount%22%3A%7B%22iban%22%3A%22%22%7D%7D%5D
```

The user authenticates and provides consent for the requested authorization details. After consent, the authorization server redirects to the specified redirect URI with an authorization code.

=== "Sample response (/authorize)"

```bash
<redirectURI>?code=<authorizationCode>&session_state=<sessionState>
```

#### Step 2: Exchange authorization code for access token

The client exchanges the authorization code for an access token by sending a request to the token endpoint.

=== "Sample request (/token)"

```bash
curl --location 'https://localhost:9443/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic <base64EncodedClientCredentials>' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code=<authorizationCode>' \
--data-urlencode 'redirect_uri=<redirectURI>'
```

=== "Sample response (/token)"

```json
{
"access_token": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8",
"refresh_token": "z9y8x7w6-v5u4-t3s2-r1q0-p9o8n7m6l5k4",
"authorization_details": [
{
"locations": [
"https://example.com/payments1"
],
"instructedAmount": {
"currency": "USD",
"amount": "3000.00"
},
"type": "payment_initiation",
"creditorName": "Merchant A",
"actions": [
"initiate"
],
"creditorAccount": {
"iban": "c6142dc9-588c-49ec-8341-1b157c441d02"
}
}
],
"token_type": "Bearer",
"expires_in": 3600
}
```
Comment on lines +365 to +391
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Gitleaks flagged sample tokens—document as placeholders.

Gitleaks detected lines 367–368 as Generic API Keys. These are placeholder tokens in documentation examples, not secrets. However, to prevent confusion and reinforce that these are sample values, consider adding a brief comment before the JSON block indicating these are example/placeholder tokens.

Example improvement:

 === "Sample response (/token)"
+    
+    <!-- Example response with placeholder tokens -->
 
     ```json

Alternatively, use more explicit placeholder markers in the sample values themselves (e.g., <sample-access-token> as inline comments near the JSON block).

🧰 Tools
🪛 Gitleaks (8.28.0)

[high] 367-367: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 368-368: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🤖 Prompt for AI Agents
In en/includes/guides/authorization/rich-authorization-requests.md around lines
365 to 391, the JSON sample contains realistic-looking tokens that triggered
Gitleaks; update the documentation to clearly mark these values as non-sensitive
placeholders by either adding a one-line comment immediately above the code
block stating "Example values — do not use in production" (or similar), and/or
replace the access_token and refresh_token values with explicit placeholder
strings like "<sample-access-token>" and "<sample-refresh-token>" so the example
cannot be misinterpreted as real credentials.


The client application can now retrieve the user's payment information from the resource server by including the obtained access token in the request.

### Validate the access token

To verify if an access token is valid and check its associated authorization details, invoke the token introspection endpoint.

Check warning on line 397 in en/includes/guides/authorization/rich-authorization-requests.md

View workflow job for this annotation

GitHub Actions / Vale style check

[vale] reported by reviewdog 🐶 [write-good.E-Prime] Try to avoid using 'is'. Raw Output: {"message": "[write-good.E-Prime] Try to avoid using 'is'.", "location": {"path": "en/includes/guides/authorization/rich-authorization-requests.md", "range": {"start": {"line": 397, "column": 30}}}, "severity": "INFO"}
If the token is active, the response will include its associated authorization details.

=== "Sample request (/introspect)"
Expand Down
Loading