Reputation: 651
We have used AD/LDAP for authentication in SonarQube 7.0... We achieved AD/LDAP authentication successfully...However we want to give project level permissions to different users through program (php / Python).
SonarQube suggests to use web api as below
POST api/permissions/add_user
Params
1. login = XXX
2. permission = user / codereviewer / scan / issueadmin
3. projectid (optional )
4. projectkey (optional ) = ABC
Example Request suggested by SonarQube documentation
curl -X POST -v -u admin:admin 'http://localhost:9000/api/permissions/add_user?permission=codeviewer&user=XXX&component=ABC'
We attempted to write php curl to handle post web request and get json response as per below :
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://localhost:9000/api/permissions/add_user");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"login=XXX&permission=user&projectkey=ABC");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
if ($server_output == "OK") { ... } else { ... }
?>
It did not reflect any changes over the ABC project permission for user XXX....
Can anyone guide me on this topic ?
I want to know algorithm if any for Sonarqube web api post request... e.g. To access this post request we need web api admin login /logout for sonarqube before api/permission OR It needs some cookie or tokens...
Thank you for helping me on this..
Upvotes: 3
Views: 1810