[REST API] Can't update the admin account

423 views
Skip to first unread message

rasmey...@gmail.com

unread,
Sep 2, 2015, 4:51:22 PM9/2/15
to SonarQube
Hi everybody,

For an internal project, I'm working on a deployment shell script for SonarQube-4.5.5 with Postgresql-9.3.9 and OpenJDK 1.7.0_79 packaged in Ubuntu 14.04.3 LTS. With that script, I want to change the admin's password with just one curl. But I can't.

Here it is the commands I'm using : 
$ curl -XPOST -u admin:admin -d @sonar_admin.json -H "Accept: application/json" "http://localhost:9000/sonar/api/users/update"

This is the sonar_admin.json's content :
{
"login": "admin",
"name": "Administrator",
"password": "<new_password>",
"password_confirmation": "<new_password>"
}

And the response is : {"err_code":400,"err_msg":"Missing parameter: login"}

I've changed the sonar.properties in order to have more logs. The only logs I've seen were about the SQL queries executed :
2015.09.02 20:14:09 INFO  http-bio-127.0.0.1-9000-exec-2 web[sql]  2ms Executed SQL: SELECT * FROM "users" WHERE (login='admin' AND active='t') LIMIT 1
2015.09.02 20:14:09 INFO  http-bio-127.0.0.1-9000-exec-2 web[sql]  1ms Executed SQL: SELECT * FROM "groups" INNER JOIN "groups_users" ON "groups".id = "groups_users".group_id WHERE ("groups_users".user_id = 1 )
2015.09.02 20:14:09 INFO  http-bio-127.0.0.1-9000-exec-2 web[sql]  1ms Executed SQL: SELECT role FROM "group_roles" WHERE (resource_id is null and (group_id is null or group_id in(1,2)))
2015.09.02 20:14:09 INFO  http-bio-127.0.0.1-9000-exec-2 web[sql]  1ms Executed SQL: SELECT * FROM "user_roles" WHERE ("user_roles".user_id = 1)
2015.09.02 20:14:09 INFO  http-bio-127.0.0.1-9000-exec-2 web[http]  36ms POST /sonar/api/users/update

In executing the 4th query, I found it weird that the "admin" user is not associated to the "admin" group :
sonar=# SELECT * FROM "user_roles" WHERE ("user_roles".user_id = 1);
 id | user_id | resource_id | role
----+---------+-------------+------
(0 rows)

Do you have any idea, please ?

Thank you

Rasmey

Teryk Bellahsene

unread,
Sep 3, 2015, 8:31:01 AM9/3/15
to SonarQube
Hi Rasmey,
Visibly it's a problem with your curl command as for example the command
curl -XPOST -u admin:admin -d "login=admin" -H "Accept: application/json" "http://localhost:9000/api/users/update"
does not return a problem with the login parameter.

HTH,

Teryk

rasmey...@gmail.com

unread,
Sep 3, 2015, 10:33:20 AM9/3/15
to SonarQube
Hi Teryk,

Thank you for your response.

I've succeeded with this command :
curl -XPOST -u admin:admin -H "Content-Type: application/json; charset=utf-8" -d @sonar_admin.json -XPOST "http://localhost:9000/sonar/api/users/update"

The password contains a special character. I've supposed because of just one character the hole thing hasn't behaved correctly.

Thanks anyway for your quick answer !

Rasmey
Reply all
Reply to author
Forward
0 new messages