Skip to content

Commit 3d4cd28

Browse files
Merge pull request #5866 from Thisara-Welmilla/custom-auth-in-app-native
Add documentation on custom authentication in app native flow.
2 parents dc0db01 + 0765469 commit 3d4cd28

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

en/asgardeo/docs/references/app-native-authentication.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
{% include "../../../includes/references/concurrent-session-based-access-control-app-native-reference.md" %}
99
{% set api_oauth2_path = "https://api.asgardeo.io/t/{organization_name}/oauth2" %}
1010
{% include "../../../includes/references/device-flow-app-native-reference.md" %}
11+
{% include "../../../includes/references/custom-authentication-app-native-reference.md" %}

en/identity-server/next/docs/references/app-native-authentication.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
{% include "../../../../includes/references/concurrent-session-based-access-control-app-native-reference.md" %}
99
{% set api_oauth2_path = "https://localhost:9443/oauth2" %}
1010
{% include "../../../../includes/references/device-flow-app-native-reference.md" %}
11+
{% include "../../../../includes/references/custom-authentication-app-native-reference.md" %}

en/includes/guides/service-extensions/in-flow-extensions/custom-authentication.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,3 +667,14 @@ Content-Type: application/json
667667

668668
!!! note
669669
Currently, the <code>errorMessage</code> or <code>errorDescription</code> from the external service’s <code>ERROR</code> response isn't directly included in the error response sent back to the application.
670+
671+
{% if (product_name == "WSO2 Identity Server" and is_version > "7.2.0" ) %}
672+
## Custom authentication with app-native authentication
673+
674+
You can configure custom authentication services in app-native authentication flows, which authenticate users through API-based mechanisms instead of redirecting them to a web browser.
675+
676+
!!! note
677+
Learn more about [app-native authentication]({{base_path}}/guides/authentication/app-native-authentication/add-app-native-authentication/)
678+
679+
Refer to the [custom authentication-based app-native authentication flow]({{base_path}}/references/app-native-authentication/#scenario-9-user-logs-in-with-service-based-custom-authentication) for a detailed guidance on how to implement this.
680+
{% endif %}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
### Scenario 9: User logs in with service based custom authentication
2+
3+
!!! note
4+
Learn more about [custom authentication]({{base_path}}/guides/service-extensions/in-flow-extensions/custom-authentication/)
5+
6+
The application goes through the following steps to complete app-native authentication for a user logging in with service based custom authentication.
7+
8+
- **Step 1**: Initiate the request with the `/authorize` endpoint.
9+
10+
!!! note
11+
The response contains information on the first authentication step (the only step for this flow).
12+
13+
=== "Request (`/authorize`)"
14+
15+
```bash
16+
curl --location '{{api_base_path}}'
17+
--header 'Accept: application/json'
18+
--header 'Content-Type: application/x-www-form-urlencoded'
19+
--data-urlencode 'client_id=XWRkRNkJDeTiR5MwHdXROGiJka'
20+
--data-urlencode 'response_type=code'
21+
--data-urlencode 'redirect_uri=https://example.com/home'
22+
--data-urlencode 'scope=openid profile'
23+
--data-urlencode 'response_mode=direct'
24+
```
25+
=== "Response (`/authorize`)"
26+
27+
```json
28+
{
29+
"flowId": "162b7547-e057-4c84-9237-1c7e69bdc122",
30+
"flowStatus": "INCOMPLETE",
31+
"flowType": "AUTHENTICATION",
32+
"nextStep": {
33+
"stepType": "AUTHENTICATOR_PROMPT",
34+
"authenticators": [
35+
{
36+
"authenticatorId": "Y3VzdG9tLWFiY19hdXRoZW50aWNhdG9y",
37+
"authenticator": "custom-abc_authenticator",
38+
"idp": "ABC Authenticator",
39+
"metadata": {
40+
"i18nKey": "AbstractAuthenticatorAdapter",
41+
"promptType": "INTERNAL_PROMPT",
42+
"additionalData": {
43+
"endpointUrl": "https://externalservice/authentication/userinput",
44+
"state": "ec159061-2a93-415d-8786-652d4f344241"
45+
}
46+
}
47+
}
48+
]
49+
},
50+
"links": [
51+
{
52+
"name": "authentication",
53+
"href": "{{authn_path}}",
54+
"method": "POST"
55+
}
56+
]
57+
}
58+
```
59+
- **Step 2**: The application should interact with the external service, and authenticate the user. After it's complete, proceed with the next /authn request as outlined in the subsequent step.
60+
61+
!!! important
62+
Service-based custom authentication is categorized under the `INTERNAL_PROMPT` prompt type authenticator, which requires the application to explicitly trigger the authentication option for the user. The application is responsible for handling and processing the data received and invoking the external authenticator accordingly.
63+
64+
- **Step 3**: Carry the same `flowId` and request the `/authn` endpoint for custom authentication.
65+
66+
!!! note
67+
The application is not required to return the state or parameters with the /authn request.
68+
69+
=== "Request 2 (`/authn`)"
70+
71+
```bash
72+
curl --location '{{authn_path}}'
73+
--header 'Content-Type: application/json'
74+
--data '{
75+
"flowId": "162b7547-e057-4c84-9237-1c7e69bdc122",
76+
"selectedAuthenticator": {
77+
"authenticatorId": "Y3VzdG9tLWFiY19hdXRoZW50aWNhdG9y"
78+
}
79+
}'
80+
```
81+
82+
=== "Response 2 (`/authn`)"
83+
84+
```json
85+
{
86+
"flowStatus": "SUCCESS_COMPLETED",
87+
"authData": {
88+
"code": "5f1b2c2a-1436-35a5-b8e4-942277313287"
89+
}
90+
}
91+
```
92+
93+
!!! note
94+
As this is the only step configured for the application, the `/authn` endpoint returns an authorization code, upon successful authentication.

0 commit comments

Comments
 (0)