我可以从Confluence REST API获取权限列表(使用PythonConfluenceAPI):
p = api.get_space_information(space_key, expand="permissions")['permissions']
我得到了一个词典列表,其中包含有关操作和主题的信息。但是,API中的信息与Confluence中显示的权限之间存在不匹配:
我真正想要的是空间管理员列表。我希望有人可以解释API给我的这些权限结构。
答案 0 :(得分:3)
和你一样,我无法使用似乎已完全删除的RPC api。如果您想获取空间管理员列表,可以使用一些东西。
简单的方法是使用SkView
路由,它将返回自动为空间管理员的汇合管理员的所有成员列表。
如果您没有很多用户,您还可以使用可在管理面板上安装的Space Permissions Handler add-on。它将为您提供具有给定用户的所有权限的api,其格式与旧/rest/api/group/confluence-administrators/member
返回的格式相同。
但如果你有很多用户单独检查它们,那么它仍然可能是一种痛苦而不是最有用的事情。我创建了一个Confluence附加组件,允许我使用java api,并利用SpaceDirectoryEntity的getAdmins方法。
单一端点非常简单:
getSpacePermissionSets
如果给出有效的空格键,它会给出这种响应:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{key}")
public Response getAdmins(@PathParam("key") String key) {
Space space = spaceManager.getSpace(key);
if (space == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
List<User> admins = spaceManager.getSpaceAdmins(space);
List<Object> out = new ArrayList<Object>();
for (User admin: admins) {
Map<String, String> item = new HashMap<String, String>();
item.put("fullName", admin.getFullName());
item.put("name", admin.getName());
item.put("email", admin.getEmail());
out.add(item);
}
Gson gson = new Gson();
String json = gson.toJson(out);
return Response.ok(json).build();
}
如果你想让我开源,可能需要更多的工作来清理插件,只要告诉我你是否感兴趣。
答案 1 :(得分:0)
不幸的是,REST API中没有适当的文档以及通过此方式获得空间管理员权限的方式。但是,我相信您可以使用旧的 JSON-RPC API 来获取空间权限列表。它可以通过以下方式访问:
http://<confluence-url>/rpc/json-rpc/confluenceservice-v2/getSpacePermissionSets
技术上返回响应如下:
[
{
"type": "SETSPACEPERMISSIONS",
"spacePermissions": [
{
"type": "SETSPACEPERMISSIONS",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "EXPORTSPACE",
"spacePermissions": [
{
"type": "EXPORTSPACE",
"userName": null,
"groupName": null
},
{
"type": "EXPORTSPACE",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "EXPORTSPACE",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "SETPAGEPERMISSIONS",
"spacePermissions": [
{
"type": "SETPAGEPERMISSIONS",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "SETPAGEPERMISSIONS",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "REMOVEMAIL",
"spacePermissions": [
{
"type": "REMOVEMAIL",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "REMOVEMAIL",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "REMOVEMAIL",
"userName": null,
"groupName": null
}
]
},
{
"type": "REMOVEBLOG",
"spacePermissions": [
{
"type": "REMOVEBLOG",
"userName": null,
"groupName": null
},
{
"type": "REMOVEBLOG",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "REMOVEBLOG",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "EXPORTPAGE",
"spacePermissions": [
{
"type": "EXPORTPAGE",
"userName": null,
"groupName": null
},
{
"type": "EXPORTPAGE",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "EXPORTPAGE",
"userName": null,
"groupName": "confluence-users"
}
]
},
{
"type": "REMOVEATTACHMENT",
"spacePermissions": [
{
"type": "REMOVEATTACHMENT",
"userName": null,
"groupName": null
},
{
"type": "REMOVEATTACHMENT",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "REMOVEATTACHMENT",
"userName": null,
"groupName": "confluence-users"
}
]
},
{
"type": "CREATEATTACHMENT",
"spacePermissions": [
{
"type": "CREATEATTACHMENT",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "CREATEATTACHMENT",
"userName": null,
"groupName": null
},
{
"type": "CREATEATTACHMENT",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "VIEWSPACE",
"spacePermissions": [
{
"type": "VIEWSPACE",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "VIEWSPACE",
"userName": null,
"groupName": null
},
{
"type": "VIEWSPACE",
"userName": null,
"groupName": "confluence-users"
}
]
},
{
"type": "EDITBLOG",
"spacePermissions": [
{
"type": "EDITBLOG",
"userName": null,
"groupName": null
},
{
"type": "EDITBLOG",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "EDITBLOG",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "REMOVEPAGE",
"spacePermissions": [
{
"type": "REMOVEPAGE",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "REMOVEPAGE",
"userName": null,
"groupName": null
},
{
"type": "REMOVEPAGE",
"userName": null,
"groupName": "confluence-users"
}
]
},
{
"type": "REMOVECOMMENT",
"spacePermissions": [
{
"type": "REMOVECOMMENT",
"userName": null,
"groupName": null
},
{
"type": "REMOVECOMMENT",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "REMOVECOMMENT",
"userName": null,
"groupName": "confluence-administrators"
}
]
},
{
"type": "EDITSPACE",
"spacePermissions": [
{
"type": "EDITSPACE",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "EDITSPACE",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "EDITSPACE",
"userName": null,
"groupName": null
}
]
},
{
"type": "COMMENT",
"spacePermissions": [
{
"type": "COMMENT",
"userName": null,
"groupName": "confluence-users"
},
{
"type": "COMMENT",
"userName": null,
"groupName": "confluence-administrators"
},
{
"type": "COMMENT",
"userName": null,
"groupName": null
}
]
}
]
如果您没有任何限制并且可以对数据库运行查询,则还可以使用以下查询:
SELECT s.SPACENAME, u.username FROM SPACES s
JOIN SPACEPERMISSIONS p ON s.SPACEID = p.SPACEID
JOIN user_mapping u ON p.PERMUSERNAME = u.user_key
WHERE p.PERMTYPE = 'SETSPACEPERMISSIONS';
以上查询返回实例中所有空格的空间管理员列表。