User sign up thru iOS device

Hi,
I understand Sync Gateway’s Admin REST API can only be called on localhost (on couchbase server db. (please see below curl sample codes. it works with localhost but rejected with ip address)

Before user can login thru sync gateway, they need to sign up first…
Since we will allow user to sign up thru their iOS device (my company doesn’t use facebook/persona user auth methods), I need to call Admin REST API in objective-c and I can not use ‘localhost’ in objective-c to establish NSURLConnection , how can I call Admin REST API to create user account thru Objective-C?

~$curl -X POST http://localhost:4985/corpa-sync/_user/ \

-d ‘{“name”:“corpa_user01”, “password”:“mobile”}’
-H “Content-Type: application/json”

~$curl -X POST http://10.1.10.229:4985/corpa-sync/_user/ -d ‘{“name”:“corpa_user02”, “password”:“mobile2”}’ -H "Content-Type: application/json"
curl: (7) Failed to connect to 10.1.10.229 port 4985: Connection refused

Thanks!
Tim

@timyeh

You can control which interface and port Sync Gateway binds to for each REST API using the following top level properties in your sync_gateway_config.json file.

“interface”:“0.0.0.0:4984”,
“adminInterface”:“0.0.0.0:4985”,

The above example binds to all interfaces, if you wish to bind to a specific interface replace 0.0.0.0 with the IP address associated with that interface.

I would not recommend exposing the ADMIN REST API publicly, have you looked at Custom (Indirect) Authentication

Andy

1 Like

@jamiltz provided this link to some more info on custom auth

Hi Andy,
Thanks so much! It works!
I will also take a look at Custom Auth later.

=============
no error message:
~$curl -X POST http://10.1.10.229:4985/corpa-sync/_user/ -d ‘{“name”:“corpa_user03”, “password”:“mobile3”}’ -H “Content-Type: application/json”

and in couchbase server:
{
“name”: “corpa_user03”,
“all_channels”: {
"!": 1
},
“sequence”: 22,
“passwordhash_bcrypt”: “JDJhJDEwJGpOSmZPOTlZai5aSlV1RWZubXhWbHUybjdPNDdIeTFrNjVEQ1V3dFVlUXNOcXdzelo5Tlhp”,
“rolesSince”: {}
}

================

BTW, where can I find the Sync-Gateway JSON keywords list doc? like “interface” “adminInterface”?

Thanks!!
Tim

Hi @timyeh

I’m not sure if that list exists but if it doesn’t we should definitely work on it :).
I usually run the binary with the --help to print all the available options.
Having a list of all the config fields in the docs would be nice.

Check out this tutorial that explains how to set up a NodeJS app server to have signup in an Android app (i.e. exposing the admin user endpoint above to client apps). The same concept applies for iOS apps.
Will you be using 3rd party auth like Twitter login, Gmail…as well?

James