如果您尝试 XACML JSON 请求,应该如下所示:
{
"Request": {
"http://wso2.org/identity/user": [
{
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "adminUser",
"IncludeInResult": true,
"DataType": "string"
}
]
},{
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "publicUser",
"IncludeInResult": true,
"DataType": "string"
}
]
} ],
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": true,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Action": [{
"Attribute": [{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-welcome",
"IncludeInResult": true,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},{
"Attribute": [{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-status",
"IncludeInResult": true,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},{
"Attribute": [{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-summary",
"IncludeInResult": true,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},{
"Attribute": [{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "modify-welcome",
"IncludeInResult": true,
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
} ]
}
}
相关回应如下,
{
"Response": [
{
"Decision": "Deny",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Obligations": [
{
"Id": "fail_to_permit",
"AttributeAssignments": [
{
"AttributeId": "obligation-id",
"Value": "You can not access the resource index.jsp",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
],
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "adminUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-status",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Deny",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Obligations": [
{
"Id": "fail_to_permit",
"AttributeAssignments": [
{
"AttributeId": "obligation-id",
"Value": "You can not access the resource index.jsp",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
],
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "adminUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-summary",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Permit",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-welcome",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "publicUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Permit",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-summary",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "publicUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Deny",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Obligations": [
{
"Id": "fail_to_permit",
"AttributeAssignments": [
{
"AttributeId": "obligation-id",
"Value": "You can not access the resource index.jsp",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
],
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "adminUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-welcome",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Deny",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Obligations": [
{
"Id": "fail_to_permit",
"AttributeAssignments": [
{
"AttributeId": "obligation-id",
"Value": "You can not access the resource index.jsp",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
],
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "view-status",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "publicUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Deny",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Obligations": [
{
"Id": "fail_to_permit",
"AttributeAssignments": [
{
"AttributeId": "obligation-id",
"Value": "You can not access the resource index.jsp",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
],
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "modify-welcome",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "publicUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
},
{
"Decision": "Permit",
"Status": {
"StatusCode": {
"Value": "urn:oasis:names:tc:xacml:1.0:status:ok"
}
},
"Resource": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:resource:resource-id",
"Value": "index.jsp",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"http://wso2.org/identity/user": {
"Attribute": [
{
"AttributeId": "http://wso2.org/identity/user/username",
"Value": "adminUser",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
},
"Action": {
"Attribute": [
{
"AttributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
"Value": "modify-welcome",
"IncludeInResult": "true",
"DataType": "http://www.w3.org/2001/XMLSchema#string"
}
]
}
}
]
}
在 XACML 的多决策配置文件中 - 结果将提供可以针对特定主题或资源所有者对资源采取行动的所有决策组合。
“IncludeInResult”属性会将这些参数包含在响应中,您可以通过将其设置为 false 来缩短响应。
在 WSO2 身份服务器中,您可以添加自定义类别,如“ http://wso2.org/identity/user ”,用户声明为 AttributeId:如“ http://wso2.org/identity/user/username ”
WSO2 IS Multi-Decision Profile in JSON 支持 JSON 简化格式以及 XAML 标准 URI。你可以两个都试试。
例如:urn:oasis:names:tc:xacml:1.0:action:action-id -> action-id