简体   繁体   English

Adobe Air HTTP授权

[英]Adobe air http auth

I have a question about HTTP auth in a non browser env. 我对非浏览器环境中的HTTP身份验证有疑问。

If i have an Air app which takes user/pass to "login" to a web app. 如果我有一个Air应用程序,它需要用户/密码来“登录”到Web应用程序。

THe login action would be done with a request from Air to http://foo.bar/session/create and the uname/pass as POST var. 登录操作将通过Air请求http://foo.bar/session/create以及uname / pass作为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. 如果然后我打电话给受保护的http://foo.bar/links ,以获得一堆链接,它应该工作并向我返回链接。

How can i be automaticaly authentified in the browser (firefox/ie) opening one of this link ? 如何在打开此链接之一的浏览器(firefox / ie)中自动进行身份验证

My first guess is i can't. 我的第一个猜测是我做不到。

Thanks for your feedbacks. 感谢您的反馈。

Greg 格雷格

You need to add some logic on your serverside. 您需要在服务器端添加一些逻辑。 In /session/create 在/会话/创建

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

And in /links 并在/ 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. 您可以根据每个请求来回发送令牌,但是让服务器端检查会话要容易得多。

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. 不幸的是,打开网络浏览器时您无法保留该身份验证,因为它们不共享Cookie。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM