views:

76

answers:

2

Hello !

I have a question about HTTP auth in a non browser env.

If i have an Air app which takes user/pass to "login" to a web app.

THe login action would be done with a request from Air to http://foo.bar/session/create and the uname/pass as POST var.

Now i can keep the answer and add it to the headers for my next requests ?

If then i do a call to http://foo.bar/links which is protected to get a bunch of links, it should work and return me the links.

How can i be automaticaly authentified in the browser (firefox/ie) opening one of this link ?

My first guess is i can't.

Thanks for your feedbacks.

Greg

A: 

You need to add some logic on your serverside. In /session/create

if (passed) { session["user"] = username }

And in /links

if (session["user"] == null) { redirect('/login') }
// Do the rest of your stuff here

THis isn't real code. It's just supposed to give you an idea. You CAN send a token back and forth on each request, but it's a lot easier to have your serverside check the session.

Sean Clark Hess
Oh, sorry, I didn't read carefully enough. You're using basic http authentication instead of a serverside? I'd recommend throwing a serverside language in there. They are easier
Sean Clark Hess
A: 

Yes you can login in the background and it will keep your authentication as you copy links. Unfortunately you can't keep that authentication when opening a web browser as they don't share cookies.

Al