Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
Configure a service provider with basic authenticator as the first step
Add the following script to script based adaptive authentication
function onLoginRequest(context) {
executeStep(1, {
onSuccess: function (context) {
// Extracting authenticated subject from the first step
var user = context.currentKnownSubject;
}
});
}
First try to login with an invalid credentials pair
Try to login with a valid credentials pair
Following error is logged and authentication fails
ERROR {org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilder} - Error in executing the javascript for service provider : test, Javascript Fragment :
function (context) {
// Extracting authenticated subject from the first step
var user = context.currentKnownSubject;
}
java.lang.IllegalArgumentException: Wrapped object cannot be null.
at org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.AbstractJSObjectWrapper.<init>(AbstractJSObjectWrapper.java:32)
at org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser.<init>(JsAuthenticatedUser.java:78)
at org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticatedUser.<init>(JsAuthenticatedUser.java:65)
at org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext.getMember(JsAuthenticationContext.java:79)
at jdk.nashorn.internal.scripts.Script$Recompilation$29$19A$\^eval\_.L:1(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:659)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
at org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.GraphBasedSequenceHandler.lambda$executeFunction$1(GraphBasedSequenceHandler.java:606)
at org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilder$JsBasedEvaluator.evaluate(JsGraphBuilder.java:840)
at org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.GraphBasedSequenceHandler.executeFunction(GraphBasedSequenceHandler.java:606)
at org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.GraphBasedSequenceHandler.handleDecisionPoint(GraphBasedSequenceHandler.java:571)
at org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.GraphBasedSequenceHandler.handleNode(GraphBasedSequenceHandler.java:168)
at org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.GraphBasedSequenceHandler.handle(GraphBasedSequenceHandler.java:125)
at org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.DefaultAuthenticationRequestHandler.handle(DefaultAuthenticationRequestHandler.java:139)
at org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.DefaultRequestCoordinator.handle(DefaultRequestCoordinator.java:244)
at org.wso2.carbon.identity.application.authentication.framework.servlet.CommonAuthenticationServlet.doPost(CommonAuthenticationServlet.java:53)
Workaround
To avoid this issue, we can get the subject from the previous step as below.
var user = context.steps[1].subject;
Steps to reproduce
Workaround To avoid this issue, we can get the subject from the previous step as below.
var user = context.steps[1].subject;