Hi Himanshu,
You can run the below SQL query to get a list of all spaces that can be accessed by anonymous users:
SELECT SPACENAME FROM SPACES WHERE SPACEID IN (SELECT SPACEID FROM SPACEPERMISSIONS WHERE PERMTYPE = 'VIEWSPACE' AND PERMGROUPNAME IS NULL AND PERMUSERNAME IS NULL AND PERMALLUSERSSUBJECT IS NULL);
Regards,
Mahesh
Hi Mahesh ,
I have same SQL query but we need to get information through API or Curl command
Thanks
Regards ,
Himanshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have created SQL query to get spaces which as anonymous access , but our client don't want to run SQL queries directly in prod system.
So , We are looking for other alternative may be API.could you please suggest a feasible alternative here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please let us know how you are planning to share the data with your client? Are you are planning to show the results on a Confluence page or some other way?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are planing to share data in excel through email.
The intention here is to trigger a email notification to get spaces which has anonymous access for that we are planing to create Jenkins job to achieve this .
Could you please suggest some feasible way.
Note : SQL query is not a feasible solution as per client requirement
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Himanshu,
Did some research and found the following example which should retrieve the Anonymous user permissions for Space
curl -v --data '["SpaceKey", ""]' -u admin:admin -H "Content-Type: application/json" http://localhost:8090/confluence/rpc/json-rpc/confluenceservice-v2/getPermissionsForUser?os_authType=basic\\
When I tried it in my local test instance, it returned empty even though I have anonymous access enabled for few spaces. This seems to be because anonymous does not have an actual user name, but the method requires two parameters, which are:
I tested the following three possibilities for the user name parameter, but all returned empty results:
With that in mind, we need to find an alternative way of gathering that information. I was able to find the following method that may be useful:
/rpc/json-rpc/confluenceservice-v2/getSpacePermissionSets
SpacePermissionSet\[\] getSpacePermissionSets(String token, String spaceKey)
- retrieves all permission sets specified for space with given spaceKey
.This method returns all permissions for a specific space key. Once you get the response, you can review it to find out if anonymous access is enabled. Here is how we can do that:
"type": "VIEWSPACE",
"spacePermissions": [
{
"type": "VIEWSPACE",
"userName": null,
"groupName": null
},
Let us know if this option is useful in your use case.
REST API
I did some research on the REST API methods and could see that we still don't have the ability to search for space permissions through the API. Here are the feature requests which are under consideration for future implementation:
Hope this information helps you.
Best Regards,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahesh ,
getSpacePermissionSets(String token, String spaceKey)
What we need to pass in "String Token"
Could you please provide some example
Thanks in advance
Regards ,
Himanshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Himanshu,
The token is used for authentication: creating a token
It is only valid if your Confluence is running on Cloud. For self-hosted or server versions, you can try the below (please tweak the values)
USRNAME="admin"
USRPWD="admin"
SPACEKEY="S1"
CONFBASEURL="http://localhost:8090"
curl --user $USRNAME:$USRPWD -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{ "jsonrpc" : "2.0", "method" : "getSpacePermissionSets", "params" : [ "S1" ] , "id": 7 }' $CONFBASEURL/rpc/json-rpc/confluenceservice-v2?os_authType=basic 2>/dev/null | python -mjson.tool
Good luck!
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahesh ,
we are running confluence on cloud and we are struggling , Because we don't know how to use above provided URL and after that how to use below provided response
"type": "VIEWSPACE",
"spacePermissions": [
{
"type": "VIEWSPACE",
"userName": null,
"groupName": null
},
Do you have any sample code ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please refer to link on how to create and use tokens: Confluence Tokens
In the response, if you see the below then it means that space has anonymous access. You may need to write additional logic to extract the space names from the response.
"userName": null,
"groupName": null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.