首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wso2标识服务器5.7.0如何为Role1编写脚本?

wso2标识服务器5.7.0如何为Role1编写脚本?
EN

Stack Overflow用户
提问于 2021-04-28 07:33:53
回答 1查看 75关注 0票数 0

我想使用这个链接:

https://docs.wso2.com/display/IS570/Adaptive+Authentication

我希望Role1不能登录到我的应用程序并编写这个代码:它是不工作的,Role1可以登录到我的应用程序。怎么能写这个剧本?

代码语言:javascript
复制
  // 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.......

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-28 08:27:29

如果您没有得到日志

  1. ,请检查您的状态。如果您的角色是内部角色,请按以下方式更改rolesToStepUp变量并尝试。

var rolesToStepUp = ['Internal/Role1'];

有关更多详细信息,请访问https://stackoverflow.com/a/66013019/10055162

  1. 为了使用户登录失败,只返回false不起作用。使用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使用情况。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67295753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档