我正在尝试为我的门户编写一个FirefoxOS应用程序,它使用Mozilla进行身份验证。如果我想实现以下目标,我应该如何进行:
我已经找到了这篇文章中已经集成的信息:http://identity.mozilla.com/post/47114516102/persona-on-firefox-os-phones,但是我找不到任何真正的例子。
我需要创建什么样的应用程序?网络应用还是特权?
我正在尝试使用常规教程:Setup实现它
但是有了这个代码:
signinLink.onclick = function() { navigator.id.request(); };我只收到以下错误:
[17:25:18.089] Error: Permission denied to access object发布于 2014-03-03 18:26:07
有一件事是确保在调用watch()之前调用request()来设置回调。
例如,在您的页面中有这样的内容:
<script src="https://login.persona.org/include.js"></script>
<script>
window.addEventListener("DOMContentLoaded", function() {
navigator.id.watch({
// Provide a hint to Persona: who do you think is logged in?
loggedInUser: null,
// Called when persona provides you an identity assertion
// after a successful request(). You *must* post the assertion
// to your server for verification. Never verify assertions
// in client code. See Step 3 in this document:
// https://developer.mozilla.org/en/Persona/Quick_Setup
onlogin: function(assertion) {
// do something with assertion ...
// Note that Persona will also call this function automatically
// if a previously-signed-in user visits your page again.
},
onlogout: function() {
// handle logout ...
},
onready: function() {
// Your signal that Persona's state- and callback-management
// business is complete. Enable signin buttons etc.
}
});
// Set up click handlers for your buttons
document.getElementById("signin").addEventListener(
'click', function() {
navigator.id.request({
// optional callback to request so you can respond to
// a user canceling the sign-in flow
oncancel: function() { /* do something */ }
});
}
});
});
</script>下面是一个示例,它显示了这一点的作用:
但是,在FirefoxOS上,您应该知道已安装的应用程序(不是打包或认证的,而是通用安装的应用程序)是表单app://{uuid}的唯一来源,每个设备都有不同的uuid。不幸的是,对于登录目的来说,这是无用的,因为您的服务器无法知道请求登录的应用程序是朋友还是敌人。解决此问题的方法是在服务器上托管的不可见的iframe中运行您的角色代码。因此,iframe将有正确的来源,您的服务器将知道它是您的应用程序。iframe和应用程序可以通过postMessage进行通信。
在打包应用程序(有时称为特权应用程序)的情况下,您的来源将是在您的webapp清单中声明的原产地。例如,app://yourapp.yoursite.org。这给你更好的保证,该应用程序真的是你的,但真正的偏执狂可能仍然希望部署iframe技巧。
希望这能有所帮助!J
https://stackoverflow.com/questions/22148484
复制相似问题