Set Duo Security as the Preferred Factor

This use case provides a step-by-step example of using the Oracle Identity Cloud Service Authentication API to set Duo Security as the preferred factor for authentication.

You can set the preferred flag to true to make Duo Security as a preferred factor, if a user already has other factor other than Duo Security as preferred.

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:

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

Submit the user's credentials as the first factor, which are the user name and password. For this step, the client must include the following attributes:
  • 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 Duo Security as the Preferred Factor

This step enables Duo Security as the preferred factor. For this step, the client must include the following attributes:
  • 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": {
	 "duoSecurityResponse": "AUTH
		|amFydmlzfERJNThZNFhVMlFXWEVSUDQzVTRKfDE1NjE1NjQzMzg=
		|4a40cc9c79d4a65b48d0f9b871d7a4e83481b3ca:APP
		|amFydmlzfERJNThZNFhVMlFXWEVSUDQzVTRKfDE1NjE1Njc4NDg=
		|af94d927d3e027141177e8f88baa19f6427502ee",
	 "preferred": true
 },
 "requestState": "{{requestState}}"
}

Response Example

The following example shows the contents of the response in JSON format:

{
    "authnToken": "{{authnToken}}",
    "status": "success",
    "ecId": "5MyZ41r0000000000"
}