Skip to content

Commit 87d1fad

Browse files
authored
Merge pull request #5952 from sahandilshan/ciba
Add ciba docs
2 parents 1827c24 + f0b78d0 commit 87d1fad

8 files changed

Lines changed: 191 additions & 0 deletions

File tree

227 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% set base_url_format = "https://api.asgardeo.io/t/{organization_name}" %}
2+
{% set base_url_sample = "https://api.asgardeo.io/t/bifrost" %}
3+
{% include "../../../../includes/guides/authentication/configure-ciba-grant.md" %}

en/asgardeo/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ nav:
379379
- JWT Secured Authorization Response Mode (JARM) for OAuth 2.0: guides/authentication/oidc/jarm.md
380380
- Grant types:
381381
- JWT Bearer Grant: guides/authentication/configure-jwt-bearer-grant.md
382+
- CIBA Grant: guides/authentication/configure-ciba-grant.md
382383
- Client authentication methods:
383384
- Private key JWT: guides/authentication/oidc/private-key-jwt-client-auth.md
384385
- Tokens and validation:
230 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% set base_url_format = "https://localhost:9443" %}
2+
{% set base_url_sample = "https://localhost:9443" %}
3+
{% include "../../../../../includes/guides/authentication/configure-ciba-grant.md" %}

en/identity-server/next/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ nav:
706706
- JWT Secured Authorization Response Mode (JARM) for OAuth 2.0: guides/authentication/oidc/jarm.md
707707
- Grant types:
708708
- JWT Bearer Grant: guides/authentication/configure-jwt-bearer-grant.md
709+
- CIBA Grant: guides/authentication/configure-ciba-grant.md
709710
- Client authentication methods:
710711
- Private key JWT: guides/authentication/oidc/private-key-jwt-client-auth.md
711712
- Tokens and validation:
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Configure CIBA grant
2+
3+
[Client Initiated Backchannel Authentication (CIBA)]({{base_path}}/references/grant-types/#ciba-grant) is designed for scenarios where the device used to consume a service is different from the device used for authentication. For example, a user may initiate a login on a smart TV or kiosk and approve the authentication request on their mobile phone.
4+
5+
In a CIBA flow, the consuming device initiates the authentication request through the client application. The authorization server then notifies the user’s authenticating device, where the user can approve the login.
6+
7+
Follow this guide for instructions on configuring the CIBA grant type in your application.
8+
9+
## Prerequisites
10+
11+
- You need to register a [Standard-Based Application]({{base_path}}/guides/applications/register-standard-based-app/) in {{product_name}}.
12+
13+
## Enable CIBA grant in your app
14+
15+
To enable the CIBA grant type in your application:
16+
17+
1. On the {{ product_name }} Console, go to **Applications**.
18+
2. Open your application from the list and go to the **Protocol** tab.
19+
3. Under the **Allowed grant types** section, check the box for **CIBA**.
20+
21+
Once enabled, you can configure the specific CIBA properties:
22+
23+
- **Expiry Time:** The validity period of the authentication request (`auth_req_id`) in seconds. Default: `120`. Increase this value if users need more time to authenticate on the separate device (e.g., when using email or SMS notifications).
24+
- **Notification Channels:** The mechanisms by which the user will be notified to authenticate. The supported channels are:
25+
26+
- **Email** - Sends an authentication notification to the user's registered email address. The organization must have an [email provider configured]({{base_path}}/guides/notification-channels/configure-email-provider/), and the user must have a verified email address in their profile.
27+
28+
- **SMS** - Sends an authentication notification to the user's registered mobile number. The organization must have an [SMS provider configured]({{base_path}}/guides/notification-channels/configure-sms-provider/), and the user must have a mobile number in their profile.
29+
30+
- **External** - Delegates the notification delivery to the client application. Instead of {{product_name}} sending the notification directly, it returns an `auth_url` in the backchannel authentication response, and the client application is responsible for delivering the authentication link to the user.
31+
32+
!!! note
33+
You can enable multiple notification channels for an application. However, when multiple channels are configured, only **Email** and **SMS** are triggered automatically. The **External** channel is triggered only if:
34+
35+
- It is the only notification channel configured for the application, or
36+
- It is explicitly requested via the `notification_channel` parameter in the CIBA request.
37+
38+
When an application has multiple notification channels enabled, you can request a specific channel by including the `notification_channel` parameter in the authentication request. Supported values are `email`, `sms`, and `external`.
39+
40+
4. Click **Update** to save the configurations.
41+
42+
## Try it out
43+
44+
Follow the steps given below to test the CIBA flow.
45+
46+
1. The client application sends a backchannel authentication request to the `/oauth2/ciba` endpoint:
47+
48+
```bash
49+
curl -v -k -X POST {{base_url_sample}}/oauth2/ciba \
50+
--header "Authorization: Basic <Base64Encoded(CLIENT_ID:CLIENT_SECRET)>" \
51+
--header "Content-Type:application/x-www-form-urlencoded" \
52+
--data-urlencode "scope=openid profile" \
53+
--data-urlencode "login_hint=admin" \
54+
--data-urlencode "binding_message=Please authenticate to My App"
55+
```
56+
57+
!!! tip
58+
To trigger a specific notification channel, include the `notification_channel` parameter in the request. For example, add `--data-urlencode "notification_channel=email"` to send the notification via email. Supported values are `email`, `sms`, and `external`.
59+
60+
2. If successful, you will receive a response with an `auth_req_id`.
61+
62+
- If the **Email** or **SMS** channel is used, the user receives a notification through the respective channel with an authentication link. The response will contain:
63+
64+
```json
65+
{
66+
"auth_req_id": "015a2f21-6844-4e9c-80dd-a608544dcd8f",
67+
"interval": 2,
68+
"expires_in": 120
69+
}
70+
```
71+
72+
- If the **External** channel is used, an `auth_url` is also returned in the response. The client application is responsible for delivering this URL to the user.
73+
74+
```json
75+
{
76+
"auth_req_id": "015a2f21-6844-4e9c-80dd-a608544dcd8f",
77+
"interval": 2,
78+
"auth_url": "{{base_url_sample}}/oauth2/ciba_authorize?authCodeKey=2d9999e0-debb-4f9d-860b-ec221a478e42",
79+
"expires_in": 120
80+
}
81+
```
82+
83+
3. The user opens the authentication link (received via email, SMS, or delivered by the client application), logs in, and grants consent.
84+
85+
4. While or after the user authenticates, the client application polls the `/oauth2/token` endpoint using the `auth_req_id`:
86+
87+
```bash
88+
curl -v -k -X POST {{base_url_sample}}/oauth2/token \
89+
--header "Authorization: Basic <Base64Encoded(CLIENT_ID:CLIENT_SECRET)>" \
90+
--header "Content-Type:application/x-www-form-urlencoded" \
91+
--data-urlencode "grant_type=urn:openid:params:grant-type:ciba" \
92+
--data-urlencode "auth_req_id=015a2f21-6844-4e9c-80dd-a608544dcd8f"
93+
```
94+
95+
Upon successful execution (and after user authentication is complete), you will receive the requested access and ID tokens.
96+
97+
Refer to the [CIBA grant reference]({{base_path}}/references/grant-types/#ciba-grant) for more information on how the complete flow works.

en/includes/references/grant-types.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Grant types in OAuth 2.0 are defined as the methods used by a client to obtain a
1111
- [Password grant](#password-grant)
1212
- [Device authorization grant](#device-authorization-grant)
1313
- [Token exchange grant](#token-exchange-grant)
14+
- [CIBA grant](#ciba-grant)
1415
{% if product_name == "WSO2 Identity Server" %}
1516
- [JWT Bearer Grant](#jwt-bearer-grant)
1617
- [SAML 2.0 bearer grant](#saml-20-bearer-grant)
@@ -393,6 +394,91 @@ The diagram below illustrates the device flow.
393394

394395
9. The resource server returns the requested user information to the client application.
395396

397+
## CIBA grant
398+
399+
[Client Initiated Backchannel Authentication (CIBA) grant](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0.html) is an authentication flow that decouples the consumption device from the authentication device. Instead of the user authenticating on the same device where the application resides (like a standard authorization code flow), the application initiates the authentication request in the background, and the user is prompted to authenticate via a separate device (such as a smartphone).
400+
401+
The diagram below illustrates the CIBA flow.
402+
403+
![How the CIBA grant works]({{base_path}}/assets/img/references/grants/ciba-grant.png)
404+
405+
1. The client application (Consumption Device) sends a backchannel authentication request to {{product_name}}.
406+
407+
=== "Request format (/ciba)"
408+
409+
```bash
410+
curl -v -k -X POST {{base_url}}/oauth2/ciba \
411+
--header "Authorization: Basic <Base64Encoded(CLIENT_ID:CLIENT_SECRET)>" \
412+
--header "Content-Type:application/x-www-form-urlencoded" \
413+
--data-urlencode "scope=<scopes>" \
414+
--data-urlencode "login_hint=<username>" \
415+
--data-urlencode "binding_message=<custom_message>"
416+
```
417+
418+
=== "Sample request (/ciba)"
419+
420+
```bash
421+
curl -v -k -X POST {{base_url_example}}/oauth2/ciba \
422+
--header "Authorization: Basic YmJ3SkVheVJfT013UGtBZ205Vk9NekxuWUxnYTpTZDU2RGY3UkhLQm9JTWpWdzJLMnRhUzg5MjBh" \
423+
--header "Content-Type:application/x-www-form-urlencoded" \
424+
--data-urlencode "scope=openid profile" \
425+
--data-urlencode "login_hint=admin" \
426+
--data-urlencode "binding_message=Please authenticate to My App"
427+
```
428+
429+
2. {{product_name}} validates the request and issues an authentication request identifier (`auth_req_id`). Depending on the notification channel configured, it might also return an `auth_url` for user authentication.
430+
431+
```json
432+
{
433+
"auth_req_id": "015a2f21-6844-4e9c-80dd-a608544dcd8f",
434+
"interval": 2,
435+
"auth_url": "{{base_url}}/oauth2/ciba_authorize?authCodeKey=2d9999e0-debb-4f9d-860b-ec221a478e42",
436+
"expires_in": 120
437+
}
438+
```
439+
440+
3. {{product_name}} notifies the user to authenticate on a separate Authentication Device (e.g. by sending an email, SMS, or relying on external delivery of the `auth_url`).
441+
442+
4. The user authenticates and provides consent via the Authentication Device.
443+
444+
5. Meanwhile, the client application polls the token endpoint with the `auth_req_id` to retrieve the access token.
445+
446+
=== "Request format (/token)"
447+
448+
```bash
449+
curl -v -k -X POST {{base_url}}/oauth2/token \
450+
--header "Authorization: Basic <Base64Encoded(CLIENT_ID:CLIENT_SECRET)>" \
451+
--header "Content-Type:application/x-www-form-urlencoded" \
452+
--data-urlencode "grant_type=urn:openid:params:grant-type:ciba" \
453+
--data-urlencode "auth_req_id=<AUTH_REQ_ID>"
454+
```
455+
456+
=== "Sample request (/token)"
457+
458+
```bash
459+
curl -v -k -X POST {{base_url_example}}/oauth2/token \
460+
--header "Authorization: Basic YmJ3SkVheVJfT013UGtBZ205Vk9NekxuWUxnYTpTZDU2RGY3UkhLQm9JTWpWdzJLMnRhUzg5MjBh" \
461+
--header "Content-Type:application/x-www-form-urlencoded" \
462+
--data-urlencode "grant_type=urn:openid:params:grant-type:ciba" \
463+
--data-urlencode "auth_req_id=015a2f21-6844-4e9c-80dd-a608544dcd8f"
464+
```
465+
466+
6. If the user has authenticated successfully, the authorization server responds with the access token.
467+
468+
```json
469+
{
470+
"access_token":"74d610ab-7f4a-3b11-90e8-279d76644fc7",
471+
"refresh_token":"fdb58069-ecc7-3803-9b8b-6f2ed85eff19",
472+
"id_token":"eyJ4...",
473+
"token_type":"Bearer",
474+
"expires_in":3600
475+
}
476+
```
477+
478+
7. The client application can now request resources from the resource server by providing the access token.
479+
480+
8. The resource server returns the requested user information to the client application.
481+
396482
## Token exchange grant
397483

398484
OAuth 2.0 token exchange is a grant type in the OAuth 2.0 framework that enables the exchange of one type of token for another with a different set of permissions or attributes. This grant type is defined in the [OAuth Token Exchange specification (RFC 8693)](https://datatracker.ietf.org/doc/html/rfc8693){:target="_blank"}

0 commit comments

Comments
 (0)