我生命中stackoverflow中的第一个问题!
我来自嵌入式编程世界,我对网络安全有非常肤浅的了解。 我使用谷歌应用脚本构建了一个平台。所有数据都存储在数据表中。一切都很好。 我很快就提出了这种认证方案,老实说,我确信它必须是不安全的!当然,我想念一些东西!这是我的过程:
这是服务电话:
var addedContent = '<script>var session={sessionId="UUID"}</script>';
return HtmlService.createTemplateFromFile... ...addedContent(addedContent);
我使用.addedContent()调用将UUID字符串附加为javascript变量,该变量是在成功登录时使用 Utilities.getUuid()生成的。
将调用google.script.run异步的函数示例:
function get_user(username){
...
var session = {username: username, sessionId: lastUUID};
// don't confuse the two username properties.
// the username for the authentication is inside the session object.
// the property 'username' of the data object is for the getUser function
// which will be called in the server script. Also the "getUser" is not
// the actual function name either: it will be switched with the real one.
var data = {
auth: session,
action: "getUser",
username: username
};
...
google.script.run
.withSuccessHandler(get_user_success)
.withFailureHandler(get_user_failure)
.switchboard(data);`
}
在服务器中:
function switchboard(data){
var result = {sessionId: false};
var action = data["action"];
//
var auth = authenticate(data["auth"]);
// authenticate returns the new uuid string upon match or
// deletes previous uuid and returns false
if (auth == false) return result;
switch(action){
...
case 'getUser': response = the_real_function_name(data); break;
...
}
result = { sessionId: auth, response: response };
return result;
// so, what the page gets back is and object with the new uuid string
// for the next call, and the actual requested data
}
成功后:
function get_user_success(data){
// data = {sessionId: "uuidstring", data: obj}
sessionId = data["sessionId"] // new uuid string for subsequent calls
...
$("some#element").val(data["data"]["address"]);
}
虽然我相信通过这个计划,我可以防止社区成员的愚蠢或好奇(毕竟他们是忙碌的牙医,他们需要这个工作!)我担心的是在网址泄漏的情况下的攻击。我考虑使用谷歌或Facebook连接API,但由于其他原因,它是不可行的。 HTTPS是否保证了该方案的安全性? 我的实施中是否存在巨大且令人尴尬的漏洞?
P.S。我试图在这里和其他地方搜索一个解决方案,但我能找到的却是相反的:谷歌应用程序脚本如何向第三台服务器进行身份验证 - 我无法找到一个解决方案,其中有人为具有匿名执行权的GAS Web应用程序提供服务和身份验证。