summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Eefting <edwin@datux.nl>2012-02-23 21:32:19 (GMT)
committer Edwin Eefting <edwin@datux.nl>2012-02-23 21:32:19 (GMT)
commitdf788cf4df9ef9b565e41b45b6fa75968a7e59e1 (patch)
tree688bc23b079a8e65eea84b5b81ed371c994e028b
parent1d002052acffe69e8d1381ff6103b7cf7316012f (diff)
bare basics of authentication works
-rw-r--r--libs/csharedobject.h4
-rw-r--r--modules/paper.module/cpaperclient.cpp12
-rw-r--r--modules/paper.module/cpaperobject.cpp2
-rw-r--r--modules/paper.module/module.cpp12
-rw-r--r--wwwdir/paper/paper.js126
5 files changed, 75 insertions, 81 deletions
diff --git a/libs/csharedobject.h b/libs/csharedobject.h
index 807c7b4..91b503e 100644
--- a/libs/csharedobject.h
+++ b/libs/csharedobject.h
@@ -142,14 +142,14 @@ namespace synapse
{
clientMap[id].id=id;
- //tell everyone a new client has joined
+ //tell the client about the new object they've joined.
Cmsg out;
out.event="object_Joined";
out.dst=id;
getInfo(out);
out.send();
- //send the other clients an update about this new client.
+ //tell everyone about the new client that just joined
sendClientUpdate(id);
}
else
diff --git a/modules/paper.module/cpaperclient.cpp b/modules/paper.module/cpaperclient.cpp
index 1d20942..04a222c 100644
--- a/modules/paper.module/cpaperclient.cpp
+++ b/modules/paper.module/cpaperclient.cpp
@@ -33,12 +33,12 @@ namespace paper
mAuthChat=rights["chat"];
mDescription=rights["description"].str();
- //inform the client of its new rights
- Cmsg out;
- out.event="paper_Authorized";
- out.dst=id;
- out.map()=rights;
- out.send();
+// //inform the client of its new rights
+// Cmsg out;
+// out.event="paper_Authorized";
+// out.dst=id;
+// out.map()=rights;
+// out.send();
}
diff --git a/modules/paper.module/cpaperobject.cpp b/modules/paper.module/cpaperobject.cpp
index 83612af..eb26660 100644
--- a/modules/paper.module/cpaperobject.cpp
+++ b/modules/paper.module/cpaperobject.cpp
@@ -315,6 +315,8 @@ namespace paper
//if the key exists, add and authorize the client
synapse::CsharedObject<CpaperClient>::addClient(clientId);
getClient(clientId).authorize(mDrawing["auth"][key]);
+
+ //inform all clients about the new credentials
sendClientUpdate(clientId);
}
diff --git a/modules/paper.module/module.cpp b/modules/paper.module/module.cpp
index eadd73f..79a60d6 100644
--- a/modules/paper.module/module.cpp
+++ b/modules/paper.module/module.cpp
@@ -173,12 +173,12 @@ namespace paper
gObjectMan.getObject(objectId).addClient(msg.src);
}
- //give the creator temporary owner rights.
- //The client show add its own key and rights, otherwise the drawing will be inaccessible after leaving it.
+ //give the creator temporary owner rights and inform the others about it
+ //The client should add a key and rights as soon as possible, otherwise the drawing will be inaccessible after leaving it!
Cvar rights;
rights["owner"]=1;
gObjectMan.getObject(objectId).getClient(msg.src).authorize(rights);
-
+ gObjectMan.getObject(objectId).sendClientUpdate(msg.src);
}
/** Clients wants to delete a paper
@@ -195,6 +195,10 @@ namespace paper
* Can also be used to reauthenticate.
* \P objectId The paper to login to.
* \P key The key to authenticate with.
+ *
+ * \SEND object_Joined
+ * Send to client to indicate they have joined a new object.
+ * Filled with parameters from \ref CpaperObject::getInfo
*
* \SEND object_Client
* When authentication succeeded.
@@ -212,6 +216,8 @@ namespace paper
/** Change authentication and authorisation info
* \P key The key to change or add. Specify an empty key to set the default rights.
* \P rights See \ref CpaperClient::getInfo
+ *
+ * You need owner rights to do this.
*/
SYNAPSE_REGISTER(paper_ChangeAuth)
{
diff --git a/wwwdir/paper/paper.js b/wwwdir/paper/paper.js
index 21a4eef..015e9c8 100644
--- a/wwwdir/paper/paper.js
+++ b/wwwdir/paper/paper.js
@@ -54,7 +54,7 @@ var loading=true;
var chatLastClientName="";
var chatTypeHere="Type hier je bericht...";
-//current autentorisation info
+//current rights
var authorized;
@@ -1001,9 +1001,9 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
'Inloggen als gast': function()
{
$('#authKey').val("");
- send(paperModId,"paper_Authenticate",{
- key:""
- });
+// send(paperModId,"paper_Authenticate",{
+// key:""
+// });
}
},
'close': function ()
@@ -1018,9 +1018,9 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
{
if ($('#authKey').val()!="")
{
- send(paperModId,"paper_Authenticate",{
- key:$('#authKey').val()
- });
+// send(paperModId,"paper_Authenticate",{
+// key:$('#authKey').val()
+// });
}
$('#authMsg').html("");
});
@@ -1037,37 +1037,6 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
$('#authMsg').html("Wachtwoord ongeldig (blijft u typen)");
});
- //our authorisation changed
- synapse_register("paper_Authorized",function(msg_src, msg_dst, msg_event, msg)
- {
- $('#authForm').dialog("destroy");
-
- authorized=msg;
- updateAuthorisation();
-
- //we now may view, reload the drawing
- if (authorized["view"])
- {
- sendDraw({
- 'cmd':'reload'
- });
- }
-
- if (authorized["cursor"])
- {
- //tell people who we are and set random mouse position
- sendDraw({
- 'cursor':{
- 'clientName':$("#chatClientName").val(),
- 'x':Math.round(9000*Math.random())+1000,
- 'y':Math.round(9000*Math.random())+1000
- }
- });
- }
-
- });
-
-
//we also receive this if somebody else requested the save!
@@ -1176,9 +1145,11 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
/// start mouse update engine
window.setInterval(function() { mouseMove(false) }, mouseInterval);
- //join the specified paper
- send(0,"paper_Join", {
- "objectId":getUrlId()
+ //finally!...
+ //join the specified paper!
+ send(0,"paper_Login", {
+ "objectId":getUrlId(),
+ "key": ""
});
@@ -1190,38 +1161,53 @@ synapse_register("module_SessionStart",function(msg_src, msg_dst, msg_event, msg
}, false);
+ //update client rights and other info..
+ synapse_register("object_Client",function(msg_src, msg_dst, msg_event, msg)
+ {
+ //its our own info, update the widgets to match the state of autorisation!
+ if (msg_dst==msg["clientId"])
+ {
+ //store rights in global array for easy access
+ authorized=msg["rights"];
+ // if (authorized["cursor"])
+ // {
+ // //tell people who we are and set random mouse position
+ // sendDraw({
+ // 'cursor':{
+ // 'clientName':$("#chatClientName").val(),
+ // 'x':Math.round(9000*Math.random())+1000,
+ // 'y':Math.round(9000*Math.random())+1000
+ // }
+ // });
+ // }
+ //
+ // });
+
+ }
-});
-
-//update all the widgets to match the current autorisation
-function updateAuthorisation()
-{
+ //TODO:update client list
+ });
-}
-
-
-
-//we've joined a object
-synapse_register("object_Joined",function(msg_src, msg_dst, msg_event, msg)
-{
- //doesnt the url id match?
- if (getUrlId()!=msg["objectId"])
- document.location=msg["htmlPath"]+document.location.hash;
+ //we've joined a object
+ synapse_register("object_Joined",function(msg_src, msg_dst, msg_event, msg)
+ {
+ //doesnt the url id match?
+ //FIXME: push history
+ // if (getUrlId()!=msg["objectId"])
+ // document.location=msg["htmlPath"]+document.location.hash;
+
+ //we've joined a object, remeber the ids
+ currentObjectId=msg["objectId"];
+ paperModId=msg_src;
+ $("#objectId").html(msg["objectId"]);
- //we've joined a object, remeber the ids
- currentObjectId=msg["objectId"];
- paperModId=msg_src;
- $("#objectId").html(msg["objectId"]);
-
- //we're not yet authorized to do anything if we just joined.
- authorized=new Array();
- updateAuthorisation();
+ //since we've joined, ask for a complete reload of the drawing
+ sendDraw({
+ 'cmd':'reload'
+ });
- //authenticate using specified key
- send(paperModId,"paper_Authenticate",{
- key:document.location.hash.substr(1)
+
+ document.location.hash="";
});
-
- document.location.hash="";
-});
+});