我想使用这个链接:
https://docs.wso2.com/display/IS570/Adaptive+Authentication
我希望Role1不能登录到我的应用程序并编写这个代码:它是不工作的,Role1可以登录到我的应用程序。怎么能写这个剧本?
// Role-Based from Template...
// This script will step up authentication for any user belonging
// to one of the given roles
// If the user has any of the below roles, authentication will be stepped up
var rolesToStepUp = ['Role1'];
function onLoginRequest(context) {
executeStep(1, {
onSuccess: function (context) {
// Extracting authenticated subject from the first step
var user = context.currentKnownSubject;
// Checking if the user is assigned to one of the given roles
var hasRole = hasAnyOfTheRoles(user, rolesToStepUp);
if (hasRole) {
Log.info(user.username + ' Has one of Roles: ' + rolesToStepUp.toString());
return false;
}
}
});
}
// End of Role-Based.......

发布于 2021-04-28 08:27:29
如果您没有得到日志
rolesToStepUp变量并尝试。var rolesToStepUp = ['Internal/Role1'];
有关更多详细信息,请访问https://stackoverflow.com/a/66013019/10055162
sendError实用程序函数(https://docs.wso2.com/display/IS570/Adaptive+Authentication+JS+API+Reference#AdaptiveAuthenticationJSAPIReference-sendError(url,parameters) )。检查基于用户年龄的脚本以了解(https://docs.wso2.com/display/IS570/Configuring+User-Age-Based+Adaptive+Authentication)的sendError使用情况。
https://stackoverflow.com/questions/67295753
复制相似问题