|
| 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. |
0 commit comments