配置WSO2 API管理器以基于SAML2属性设置权限
我试图在登录时根据SAML2令牌中包含的自定义属性在WSO2 API管理器中设置用户权限级别(发布、创建、订阅等)。不基于活动用户及其映射角色的列表。是否可以使用一组动态自定义属性自定义用户权限配置WSO2 API管理器以基于SAML2属性设置权限,wso2,wso2carbon,wso2-am,Wso2,Wso2carbon,Wso2 Am,我试图在登录时根据SAML2令牌中包含的自定义属性在WSO2 API管理器中设置用户权限级别(发布、创建、订阅等)。不基于活动用户及其映射角色的列表。是否可以使用一组动态自定义属性自定义用户权限 SAML令牌来自第三方来源,但是如果需要,可以与WSO2 Identity Server集成。API Manager在后台运行Identity Server应用程序管理以查找用户角色和权限。在org.wso2.carbon.identity.application.mgt.ApplicationMgtU
SAML令牌来自第三方来源,但是如果需要,可以与WSO2 Identity Server集成。API Manager在后台运行Identity Server应用程序管理以查找用户角色和权限。在
org.wso2.carbon.identity.application.mgt.ApplicationMgtUtil
中,您可以看到isUserAuthorized
方法,该方法可能在应用程序需要检查用户权限时触发
/**
* @param applicationName
* @param username
* @return
* @throws IdentityApplicationManagementException
*/
public static boolean isUserAuthorized(String applicationName, String username)
throws IdentityApplicationManagementException {
String applicationRoleName = getAppRoleName(applicationName);
try {
if (log.isDebugEnabled()) {
log.debug("Checking whether user has role : " + applicationRoleName + " by retrieving role list of " +
"user : " + username);
}
String[] userRoles = CarbonContext.getThreadLocalCarbonContext().getUserRealm()
.getUserStoreManager().getRoleListOfUser(username);
for (String userRole : userRoles) {
if (applicationRoleName.equals(userRole)) {
return true;
}
}
} catch (UserStoreException e) {
throw new IdentityApplicationManagementException("Error while checking authorization for user: " +
username + " for application: " + applicationName, e);
}
return false;
}
你应该能够替换
String[] userRoles = CarbonContext.getThreadLocalCarbonContext().getUserRealm()
.getUserStoreManager().getRoleListOfUser(username);
使用基于SAML2令牌中存在的属性检索角色的代码,尽管显然您必须构建并支持能够存储此类映射的结构
API Manager在后台运行Identity Server应用程序管理,以查找用户角色和权限。在
org.wso2.carbon.identity.application.mgt.ApplicationMgtUtil
中,您可以看到isUserAuthorized
方法,该方法可能在应用程序需要检查用户权限时触发
/**
* @param applicationName
* @param username
* @return
* @throws IdentityApplicationManagementException
*/
public static boolean isUserAuthorized(String applicationName, String username)
throws IdentityApplicationManagementException {
String applicationRoleName = getAppRoleName(applicationName);
try {
if (log.isDebugEnabled()) {
log.debug("Checking whether user has role : " + applicationRoleName + " by retrieving role list of " +
"user : " + username);
}
String[] userRoles = CarbonContext.getThreadLocalCarbonContext().getUserRealm()
.getUserStoreManager().getRoleListOfUser(username);
for (String userRole : userRoles) {
if (applicationRoleName.equals(userRole)) {
return true;
}
}
} catch (UserStoreException e) {
throw new IdentityApplicationManagementException("Error while checking authorization for user: " +
username + " for application: " + applicationName, e);
}
return false;
}
你应该能够替换
String[] userRoles = CarbonContext.getThreadLocalCarbonContext().getUserRealm()
.getUserStoreManager().getRoleListOfUser(username);
使用基于SAML2令牌中存在的属性检索角色的代码,尽管显然您必须构建并支持能够存储此类映射的结构
您最终有了一个可以与社区共享的解决方案吗?谢谢。你终于有了一个可以与社区分享的解决方案了吗?非常感谢。