热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在phonegap上安全的跨源ajax-Safecross-originajaxonphonegap

ThisisthefirsttimeI`mtoyingwithPhoneGap,soIactuallyneverneededCrossOriginResourceSh

This is the first time I`m toying with PhoneGap, so I actually never needed Cross Origin Resource Sharing (CORS) before.

这是我第一次玩PhoneGap,所以我以前从未需要跨源资源共享(CORS)。

It is by default blocked, and the options I found in the web are either hacks or insecure. My question is: What is the best or proper way to accomplish server integration using PhoneGap?

它默认被阻止,我在网络上找到的选项要么是黑客攻击,要么是不安全的。我的问题是:使用PhoneGap完成服务器集成的最佳或正确方法是什么?

Bear in mind:

记住:

  • I need session control serverside to keep the user logged in
  • 我需要会话控制服务器端以保持用户登录

  • The request is coming from a file in PhoneGap's webview so origin = null
  • 该请求来自PhoneGap的webview中的文件,因此origin = null

  • I'm using PHP serverside and have full control over it
  • 我正在使用PHP服务器端并完全控制它

  • is already added to config.xml (it enables me to reach out for the server, but doesn't guarantee it will respond to a cross-origin request)
  • 已添加到config.xml中(它使我能够联系服务器,但不保证它将响应跨源请求)

A long search on the web lead me to:

在网上长时间搜索引导我:

Access-Control-Allow-Origin *
Access-Control-Allow-Credentials true

But I understood they're rather unsafe, specially combined. I could save the user session ID locally, but that seems hacky and unsafe.

但我明白他们是不安全的,特别是结合起来。我可以在本地保存用户会话ID,但这看起来很麻烦且不安全。

There's also JSONP to the rescue, but that also seems hacky, unsafe and won't persist my session ID.

救援还有JSONP,但这似乎也很麻烦,不安全,不会持久保存我的会话ID。

I could use a proxy server, but that seems far from optimal and as I understand it'll be hard to prevent an attacker to not use this same proxy server to perform the same operations.

我可以使用代理服务器,但这似乎远非最佳,据我所知,很难防止攻击者不使用相同的代理服务器执行相同的操作。

1 个解决方案

#1


0  

Hi you can disable security to browser and use it. Please find the link for disabling security for chrome.

您好,您可以禁用浏览器的安全性并使用它。请找到禁用Chrome安全性的链接。

[Disable same origin policy in Chrome

[在Chrome中停用相同的来源政策


推荐阅读
author-avatar
爱昵宝贝H33_568
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有