2
我正在使用Firebase作为后端的应用程序。我有一个使用Firebase的GitHub身份验证工作实现。但是,我想将完整的应用程序(所有读/写操作)限制在特定GitHub组织中的人员。通过Firebase中的Github组织限制登录
从我收集的内容来看,这是通过在Forge中添加安全规则来完成的。但是,用户的组织不属于GitHub提供给Firebase使用的“基本身份验证数据”。我有没有办法让应用程序仅供特定组织的成员使用?
目前代码:
var FB = new Firebase('https://XXXXX.firebaseio.com');
var auth = new FirebaseSimpleLogin(FB, function(error, user){
if(user==null){
auth.login('github',{rememberMe:true});
}
else{
//We are logged in
$.getJSON("https://api.github.com/user/orgs?access_token="+user.accessToken+"&callback=?", function(data){
var orgs = data.data.map(function(org){return org.login});
if(orgs.indexOf(config.github_org)>-1){
//Public Member of Chosen Github Org
//Now we fetch the data and render it
}
else{
//Throw them out
alert("Join the group "+config.github_org+" on GitHub to get access to Eon");
document.location="https://github.com/"+config.github_org;
}
})
}
});