Last active
November 28, 2022 11:54
-
-
Save NilukaSripalim/530bfe3834b2ac021afc9196080a9bc6 to your computer and use it in GitHub Desktop.
Sample adaptive authentication script for callChoreo - IP address from UK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connectionMetaData = { | |
"url": "https://2599de0c-00bf-49f4-b922-505be18a8677-dev.e1-us-east-azure.choreoapis.dev/iraa/testnilukaasgardeo/1.0.0/risk", | |
"consumerKey": "<consumer key>", | |
"consumerSecret": "<consumer secret>", | |
}; | |
var onLoginRequest = function(context) { | |
executeStep(1, { | |
onSuccess: function (context) { | |
// IP address from UK | |
var requestIp = "31.3.255.255"; | |
Log.info("request ip:" + requestIp); | |
var requestData = {"ip": requestIp}; | |
Log.info("Start Call Choreo function!"); | |
callChoreo(connectionMetaData, requestData, { | |
onSuccess: function(context, data) { | |
Log.info('Received risk:' + data.hasRisk); | |
if (data.hasRisk === true) { | |
executeStep(2); | |
} | |
}, | |
onFail: function(context, data) { | |
Log.info('Failed to call URL. Stepping up authentication by default.'); | |
executeStep(2); | |
}, | |
onTimeout: function(context, data) { | |
Log.info('Call to Choreo API timed out. Stepping up authentication by default.'); | |
executeStep(2); | |
} | |
}); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment