Userpass login with http API

157 views
Skip to first unread message

navi...@gmail.com

unread,
Aug 1, 2016, 3:29:51 PM8/1/16
to Vault


Not sure if I'm missing something very basic here but I dont get any response (no errors either) when I use curl http to login for userpass auth. Using CLI however works. Using version 0.6


curl http://localhost:8200/v1/auth/userpass/login/someuser -d '{"password": "somepwd"}' 

  No output


vault auth -method=userpass username=someuser password=somepwd

Successfully authenticated! You are now logged in.

The token below is already saved in the session. You do not

need to "vault auth" again with the token.

token: f7eadc22-823c-a439-84cb-dc88ce8a2f8e

token_duration: 2592000

token_policies: [cassandra, default]



Thanks

Navin

Jeff Mitchell

unread,
Aug 1, 2016, 3:32:03 PM8/1/16
to vault...@googlegroups.com
Hi Navin,

Can you please run curl with -v to see any extra information it might have?

Additionally, what happens if you use 127.0.0.1 instead of localhost?

Best,
Jeff
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/hashicorp/vault/issues
> IRC: #vault-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vault" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vault-tool+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vault-tool/57905f20-67b7-4a7f-8dee-2e20f5c51355%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

navi...@gmail.com

unread,
Aug 1, 2016, 3:53:24 PM8/1/16
to Vault


Interesting ! I was running this on the standby node when it got redirected to the active node and go no response but works on the active node. Also works on the same standby node when I made it active.

Standby node 
------------------

curl -v -d '{"password": "somepwd"}' http://localhost:8200/v1/auth/userpass/login/someuser

* Hostname was NOT found in DNS cache

*   Trying 127.0.0.1...

* Connected to localhost (127.0.0.1) port 8200 (#0)

> POST /v1/auth/userpass/login/someuser HTTP/1.1

> User-Agent: curl/7.35.0

> Host: localhost:8200

> Accept: */*

> Content-Length: 28

> Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 28 out of 28 bytes

< HTTP/1.1 307 Temporary Redirect

< Location: http://10.42.32.61:8200/v1/auth/userpass/login/someuser

< Date: Mon, 01 Aug 2016 19:35:19 GMT

< Content-Length: 0

< Content-Type: text/plain; charset=utf-8


Active node
---------------

curl -v -d '{"password": "somepwd"}' http://localhost:8200/v1/auth/userpass/login/someuser* Hostname was NOT found in DNS cache* Trying 127.0.0.1...* Connected to localhost (127.0.0.1) port 8200 (#0)> POST /v1/auth/userpass/login/someuser HTTP/1.1> User-Agent: curl/7.35.0> Host: localhost:8200> Accept: */*> Content-Length: 28> Content-Type: application/x-www-form-urlencoded> * upload completely sent off: 28 out of 28 bytes< HTTP/1.1 200 OK< Content-Type: application/json< Date: Mon, 01 Aug 2016 19:36:01 GMT< Content-Length: 322< {"lease_id":"","renewable":false,"lease_duration":0,"data":null,"wrap_info":null,"warnings":null,"auth":{"client_token":"6e620045-78b7-7b96-96bc-adbb591e9747","accessor":"3d2a98a8-ed33-52be-1f57-faf8b18186a5","policies":["cassandra","default"],"metadata":{"username":"someuser"},"lease_duration":2592000,"renewable":true}}


Thanks
Navin

Jeff Mitchell

unread,
Aug 1, 2016, 4:55:27 PM8/1/16
to vault...@googlegroups.com
Hi Navin,

You need to use the -L option to curl to tell it to follow redirects.

Best,
Jeff
> https://groups.google.com/d/msgid/vault-tool/94c1e6da-b550-4828-8612-aa1f73207c08%40googlegroups.com.

navi...@gmail.com

unread,
Aug 1, 2016, 8:38:54 PM8/1/16
to Vault

Ah thanks ! Knew it was something very basic.
Reply all
Reply to author
Forward
0 new messages