Support Trusted Device when using Duo as an Authentication Factor
This use case provides a step-by-step example of using the Oracle Identity Cloud Service Authentication API to support trusted device when using Duo as an authentication factor.
Note:
See the Oracle Identity Cloud Service Authentication API Postman collection for extensive authentication use case examples. Download the collection and the global variables file from the idcs-authn-api-rest-clients folder within GitHub and then import them into Postman.Step 1: Begin the Authentication flow
Obtain the initial requestState
to begin the authentication flow.
Request Example
The following example shows the request in cURL format :
curl
-X GET
-H "Content-Type: application/json"
-H "Authorization: Bearer {{access_token_value}}"
https://tenant-base-url/sso/v1/sdk/authenticate?appName={{app_name}}
Note:
TheappName
is optional. The
appName
is the name of the App that the client wants to access. If an
appName
is provided, sign-on policies specific to the App are processed, and the client is challenged for the required factors based on that policy.
Response Example
The following example shows the contents of the response in JSON format:
{
"status": "success",
"ecId": "HI^kd1M0000000000",
"nextOp": [
"credSubmit"
],
"nextAuthFactors": [
"USERNAME_PASSWORD"
],
"USERNAME_PASSWORD": {
"credentials": [
"username",
"password"
]
},
"requestState": "{{requestState}}"
}
In the response, the nextOp
value indicates what can be sent as the op
value in the next request. In this use case example, credSubmit
should be sent in the next step. The requestState
contains contextual data needed to process the request.
Step 2: Submit the User's Credentials
-
credentials:
user name and password -
requestState:
received in the Step 1 response -
op:
tells the server what kind of operation the client wants
Request Example
The following example shows the contents of the POST request in JSON format:
{
"op": "credSubmit",
"credentials": {
"username": "{{username}}",
"password": "{{password}}"
},
"requestState": "{{requestState}}"
}
Response Example
The following example shows the contents of the response in JSON format:
{
"status": "success",
"ecId": "g5CAF1i1000000000",
"nextAuthFactors": [
"DUO_SECURITY"
],
"DUO_SECURITY": {
"credentials": [
"duoSecurityResponse"
],
"authnDetails": {
"duoSecurityChallenge": "TX
|amFydmlzfERJNThZNFhVMlFXWEVSUDQzVTRKfDE1NjE1NjM2Njc=
|73894f83e7ee87c81388f84b4c0015cb86c6fd0b:APP
|amFydmlzfERJNThZNFhVMlFXWEVSUDQzVTRKfDE1NjE1NjY5Njc=
|11f57d2ad044abee78d3290fdff69af7c3d22d71",
"duoSecurityHost": "api-example.duosecurity.com"
}
},
"nextOp": [
"credSubmit",
"getBackupFactors"
],
"scenario": "AUTHENTICATION",
"requestState": "{{requestState}}",
"trustedDeviceSettings": {
"trustDurationInDays": 15
}
}
In the response, the nextOp
values indicate what can be sent as the op value in the next request. In this use case example, credSubmit
is sent in the next step.
Step 3: Initiate Duo Security Authentication
Oracle Identity Cloud Service uses Duo's Web SDK to integrate with Duo Security. Duo offers a JavaScript library that interacts with iFrame that is used for secondary authentication.
After primary authentication, you must pass the authentication details like duoSecurityHost
and duoSecurityChallenge
that you received from Oracle Identity Cloud Service to iFrame. You can use the following example to initiate the Duo security authentication and load iFrame to make a connection with the Duo Security Server.
function duo(msg, duoSecurityCallback) {
Duo.init({iframe: "duo_iframe",
host: msg.DUO_SECURITY.authnDetails.duoSecurityHost,
sig_request: msg.DUO_SECURITY.authnDetails.duoSecurityChallenge,
submit_callback: duoSecurityCallback,
post_argument: "resp"
});
}
After completing the Duo authentication process, Duo calls the duoSecurityCallback method to get a Duo response.
var duoSecurityCallback = function(details, credentials) {
var credentials = {};
credentials.duoSecurityResponse = details.firstElementChild.value;
operation = "credSubmit";
initiateAuth(credentials);
}
Then upon receiving the response for Duo Security, you must pass the response to Oracle Identity Cloud Service to complete the authentication.
Step 4: Enable a Device as Trusted
This step enables a device as trusted. Once the device is trusted, then MFA will not be challenged even though Duo Security is enrolled.
Request Example
The following example shows the contents of the POST request in JSON format:
{
"op": "credSubmit",
"credentials": {
"duoSecurityResponse": "AUTH
|amFydmlzfERJNThZNFhVMlFXWEVSUDQzVTRKfDE1NjE1NjQ2MDY=
|ba16e2eb734e00d9ebe6f8129ce32669437052e9:APP
|amFydmlzfERJNThZNFhVMlFXWEVSUDQzVTRKfDE1NjE1NjgwNjc=
|ba4f415559ff2c30b23a912a18ee5f717a398563"
},
"trustedDevice": true,
"trustedDeviceDisplayName": "Postman on Windows",
"requestState": "{{requestState}}"
}
Response Example
The following example shows the contents of the response in JSON format:
{
"authnToken": "{{authnToken}}",
"trustToken": "{{trustToken}}",
"status": "success",
"ecId": "5MyZ41u0000000000"
}