09 April 2013

RIAK-CS: Create admin user error


While trying for hours to create an admin user, all online docs were sugesting to POST data to either http://localhost:8080/user or http://localhost:8080/riak-cs/user. None of them are completely right.

I was getting either "HTTP/1.1 404 Object Not Found" or "HTTP/1.1 403 Forbidden" or "HTTP/1.1 405 Method Not Allowed". Detailed output below.

# curl -v -H 'Content-Type: application/json' -X POST http://localhost:8080/riak-cs/user --data '{"email":"my@email.com", "name":"adminuser"}'
* About to connect() to localhost port 8080 (#0)
*   Trying localhost... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /riak-cs/user HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json
> Content-Length: 48
>
< HTTP/1.1 405 Method Not Allowed
< Server: Riak CS
< Date: Mon, 08 Apr 2013 22:45:20 GMT
< Content-Length: 0
< Allow: HEAD, GET, DELETE, PUT
<
* Connection #0 to host localhost left intact
* Closing connection #0

# curl -v -H 'Content-Type: application/json' -X PUT http://localhost:8080/riak/user --data '{"email":"my@email.com", "name":"adminuser"}'
* About to connect() to localhost port 8080 (#0)
*   Trying localhost... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /riak/user HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json
> Content-Length: 48
>
< HTTP/1.1 404 Object Not Found
< Server: Riak CS
< Date: Mon, 08 Apr 2013 22:45:36 GMT
< Content-Type: application/xml
< Content-Length: 187
<
* Connection #0 to host localhost left intact
* Closing connection #0
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist.</Message><Resource>/riak/user</Resource><RequestId></RequestId></Error>

# curl -v -H 'Content-Type: application/json' -X PUT http://localhost:8080/user --data '{"email":"my@email.com", "name":"adminuser"}'
* About to connect() to localhost port 8080 (#0)
*   Trying localhost... connected
* Connected to localhost (localhost) port 8080 (#0)
> PUT /user HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: localhost:8080
> Accept: */*
> Content-Type: application/json
> Content-Length: 48
>
< HTTP/1.1 403 Forbidden
< Server: Riak CS
< Date: Mon, 08 Apr 2013 22:49:10 GMT
< Content-Type: application/xml
< Content-Length: 159
<
* Connection #0 to host localhost left intact
* Closing connection #0
<?xml version="1.0" encoding="UTF-8"?><Error><Code>AccessDenied</Code><Message>Access Denied</Message><Resource>/user</Resource><RequestId></RequestId></Error>

To fix it, I'm sure that's why you're here, I checked/changed the following:
1. In /etc/riak-cs/app.config, this is the most common mistake
from: {anonymous_user_creation, false},
to: {anonymous_user_creation, true},

2. In the CURL call, this is a documentation mistake.
curl -v -H 'Content-Type: application/json' -X POST http://127.0.0.1:8000/riak-cs/user --data '{"email":"my@email.com", "name":"admin"}'

Note the IP and PORT. Those are from /etc/riak-cs/app.conf the following settings:
{admin_ip, "127.0.0.1"},
{admin_port, 8000 } ,

I've spent about 4 hours to find this. Why don't you try a thank you below? :-)

5 comments:

  1. for local testing, you could also change the following setting in /etc/stanchion/app.config and no auth will be done afterwards...

    from: {auth_bypass, false }
    to: {auth_bypass, false }

    ReplyDelete
  2. don't forget to do this before complaining:

    http://docs.basho.com/riakcs/latest/cookbooks/configuration/Configuring-Riak/#Setting-up-the-Proper-Riak-Backend

    ReplyDelete
  3. HI Stefan, I have same issue, and I did configure what you mentioned, the problem is still there.
    I solved according to what this blog described.

    ReplyDelete
  4. Hi, Stefan, I have some issue even I did what you mentioned.

    ReplyDelete