wso2 身份服务器 5.7.0 如何为 Role1 编写脚本? [英] wso2 identity server 5.7.0 How write Script for Role1?

查看:16
本文介绍了wso2 身份服务器 5.7.0 如何为 Role1 编写脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用此链接:

解决方案

  1. 如果你没有得到日志 Log.info(user.username + ' Has one of Roles: ' + rolesToStepUp.toString()); 检查你的情况.如果您的角色是内部角色,请按如下方式更改 rolesToStepUp 变量并尝试.

    var rolesToStepUp = ['Internal/Role1'];

    查看https://stackoverflow.com/a/66013019/10055162了解更多详情

  2. 为了使用户登录失败,仅返回 false 是行不通的.使用 sendError 实用函数 (https://docs.wso2.com/display/IS570/Adaptive+Authentication+JS+API+Reference#AdaptiveAuthenticationJSAPIReference-sendError(url,parameters)).检查基于用户年龄的脚本以了解 sendError 用法(https://docs.wso2.com/display/IS570/Configuring+User-Age-Based+Adaptive+Authentication)

I want Use this link:

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

I want Role1 Can't Login to my Application and Write this Code: and it's Don't Work and Role1 can login to my application. How can Write this script?

  // 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.......

解决方案

  1. If you didn't get the log Log.info(user.username + ' Has one of Roles: ' + rolesToStepUp.toString()); check your condition. If your Role is an internal role, change rolesToStepUp variable as follows and try out.

    var rolesToStepUp = ['Internal/Role1'];

    Have a look on https://stackoverflow.com/a/66013019/10055162 for more details

  2. In order to fail the user login, just returning false doesn't work. Use sendError utility function (https://docs.wso2.com/display/IS570/Adaptive+Authentication+JS+API+Reference#AdaptiveAuthenticationJSAPIReference-sendError(url,parameters)). Check user-age-based script for sendError usage (https://docs.wso2.com/display/IS570/Configuring+User-Age-Based+Adaptive+Authentication)

这篇关于wso2 身份服务器 5.7.0 如何为 Role1 编写脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆