|
| 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