Secure API example
Hi,
Still trying to get across hapi. Looks great.
Would you be able to a a simple example for a secure api example and show how to limit access to various api's that users can call?
I know it's a alot to ask.
Thanks
G.
They have some auth examples embedded in API reference http://spumko.github.io/resource/api/#server-auth-name--options-
Examples folder in Github repo https://github.com/spumko/hapi/blob/master/examples/auth.js
Integration tests https://github.com/spumko/hapi/blob/master/test/integration/auth.js
And an external authentication plugin module which has examples too https://github.com/spumko/travelogue
Hi,
looking at auth.js in the examples folder. the first curl statement works ok (basic), but the second (hawk) fails. what am I doing wrong.
console.log('\nHawk request to /hawk:');
console.log('curl ' + server.info.uri + '/hawk -H \'Authorization: ' + internals.hawkHeader('john', '/hawk', server) + '\'');
console.log('\nBasic request to /multiple:');
{"code":401,"error":"Unauthorized","message":"Missing authentication"}curl: (6) Could not resolve host: Hawk .. ..
Can you paste the actual console of what the example prints and what you typed?
as below (the hawk examples did not work) I cut and pasted as is.
Basic request to /basic: curl http://HAULT024:8000/basic -H "Authorization: Basic am9objpzZWNyZXQ="
Hawk request to /hawk: curl http://HAULT024:8000/hawk -H 'Authorization: Hawk id="john", ts="1374553996", nonce="ldt2qN", mac="RWYfIAbvmRJ10PlUBe076aweMob62e4x3JpyIBGZA/c="'
Basic request to /multiple: curl http://HAULT024:8000/multiple -H "Authorization: Basic am9objpzZWNyZXQ="
Hawk request to /multiple: curl http://HAULT024:8000/multiple -H 'Authorization: Hawk id="john", ts="1374553997", nonce="dWxbhQ", mac="p8C6niP9FBKTNgf0MMka0ZiVvT3CSWbMejrN5yjPi+U="'
On Wed, Jul 17, 2013 at 5:27 PM, Eran Hammer [email protected]:
Can you paste the actual console of what the example prints and what you typed?
— Reply to this email directly or view it on GitHubhttps://github.com/spumko/hapi/issues/964#issuecomment-21096360 .
Looks like a problem with the hostname. I'll take a look.
also I changed. http://HAULT024:8000/hawk http://hault024:8000/hawk
to http://127.0.0.1:8000/hawk http://hault024:8000/hawk
this did not work either.
Thanks
On Tue, Jul 23, 2013 at 3:56 PM, Eran Hammer [email protected]:
Looks like a problem with the hostname. I'll take a look.
— Reply to this email directly or view it on GitHubhttps://github.com/spumko/hapi/issues/964#issuecomment-21394681 .
Hi Eran,
While I am in contact. What's the best authentication to use with hapi for an api server. hawk - bewit?
On Tue, Jul 23, 2013 at 4:18 PM, Graeme Cox [email protected] wrote:
also I changed. http://HAULT024:8000/hawk http://hault024:8000/hawk
to http://127.0.0.1:8000/hawk http://hault024:8000/hawk
this did not work either.
Thanks
On Tue, Jul 23, 2013 at 3:56 PM, Eran Hammer [email protected]:
Looks like a problem with the hostname. I'll take a look.
— Reply to this email directly or view it on GitHubhttps://github.com/spumko/hapi/issues/964#issuecomment-21394681 .
Hi,
Have you had a chance to look into this?
Thanks
Looks like a problem with the hostname. I'll take a look.
On Tue, Jul 23, 2013 at 4:37 PM, Graeme Cox [email protected] wrote:
Hi Eran,
While I am in contact. What's the best authentication to use with hapi for an api server. hawk - bewit?
On Tue, Jul 23, 2013 at 4:18 PM, Graeme Cox [email protected] wrote:
also I changed. http://HAULT024:8000/hawk http://hault024:8000/hawk
to http://127.0.0.1:8000/hawk http://hault024:8000/hawk
this did not work either.
Thanks
On Tue, Jul 23, 2013 at 3:56 PM, Eran Hammer [email protected]:
Looks like a problem with the hostname. I'll take a look.
— Reply to this email directly or view it on GitHubhttps://github.com/spumko/hapi/issues/964#issuecomment-21394681 .
Sorry, not yet. Busy with some production issues...
@zakkwylde is this still an issue? What versions of hapi and node are you using.
Please reopen if this still an issue.