macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript
view
download
Abstract
Internetapplications where users have to loged in to be allowed to do operations,
have to be secured against not authorized persons.
Therefore the server have to examine wether a client is authorized before the
execution of the query.
Who a SSL server has available has finally no problem, which concerns security.
Whole server client communication is coded and safe.
In contrast to it the unencrypted transferred signed operations those stand only
guarantee that the operation could only from an authorized client executed.
These are to be supposed to be introduced here.
Safety aspects
SELECT * FROM `$dbTable`
WHERE MD5(CONCAT(`$dbColUser`, `$dbColPassword`, '$operationKey',
'$callString')) = '$checksumClient'Posted by hOk at December 27, 2003 05:35 PM
Comments (12)
Great example, thanks for posting ... MD5 hashing is a good way to introduce security into Flash Remoting projects.
You might also consider SHA1 160-bit hashing which would give even greater security, though for most projects MD5 does the trick.
Posted by Peter Elst at December 27, 2003 08:17 PM
Thanks, i have just seen that since PHP 4.3.0
there is also an sha1-Implementation(http://de3.php.net/sha1)
and Brandon Hall(http://www.waxpraxis.org) convertet
it for actionscript, so we can easily switch.
Posted by hOk at December 27, 2003 08:53 PM
Hehe Peter,
i have just seen that you also have written
an sha1-implementation for PHP, thanks for
that good work.
Posted by hOk at December 27, 2003 09:01 PM
Thanks, I ported it from Branden's ActionScript version but its currently still in beta so no promises that it is 100% accurate (haven't had any problems so far) ;)
Posted by Peter Elst at December 27, 2003 10:20 PM
I don't get exactly how you transfer your operation key. Usually in crypto, you'd use an asymmetric algo (private and public key to transfer a session key, and then use symmetric encryption to do the rest of the operations. You do that because asymmetric encryption is much slower than symmetric encryption. Is that what you're using to transfer your operation key?
Also your signature protocol seems weird. On page 103 of "Practical Cryptography" (B. Schneier & N. Ferguson), you have a good description of Message Authentication Codes (MACs).
Posted by Jean-François Bastien at December 29, 2003 06:52 AM
Thanks for the Comment.
The Operation-Key is tranfered by the following Webservice-Method:
function getOperationKey ()
{
// start a session with the user
session_start();
// store the operation-key for the
// next operation
$_SESSION["OPERATION_KEY"] = md5(microtime() * 1234567);
return $_SESSION["OPERATION_KEY"];
}
I use the Operation-Key for md5-hashing on Client-Side:
md5(username + password + message + operationKey).
This md5-Hash and the orginal message(Method-Call)
will transfered to the server.
The server know needs to check the Authenticity of
the Message, so he builds his own md5-hash with
the transfered message and in the stored username
and password and the operation-Key from the current
session.
Now he can compare boths md5-hashs to check Authenticity.
The only Problem that i can see is that the message
will transfered in clear language, so anybody can
read it. But for many Admin-Operations as Deleting
Files or Database etc. this would be enough security.
If we need more security we have to use an SSL-Server.
I think the Flash-Player is to slow to calculate
encryption with 128-bit or more.
Posted by hOk at December 29, 2003 12:59 PM
Hi hOk,
Thanks for the example - I implemented a version of your downloads on my own server testing against MySQL for authentication and it works well! However - I'm not quite following the procedure when calling other methods - should each method call be accompanied by a getLogin() to authenticate? Can you give an example of another signed operation call? For example - a user logs in (getLogin()) and then attempts to delete a record using another method (deleteRecordAt(record_id)) with a 'record_id' parameter. How would you handle this?
Thanks!
Stefan
Posted by Stefan at May 4, 2004 01:40 AM
Hi Stefan,
each service-method should implemented like the login method, but can have additional parameters.
Example:
function deleteRecord($checksumClient, $recordId)
{
$callString = "deleteRecord(";
// Add the additional arguments to the callstring,
// so if did the same thing in Flash we could be
// shure the don't deal with manipulated values.
//
// ::ATTENTION::
// Maybe the string representation in flash is
// an other one then in PHP, so we have to take
// care of this code-part.
for ($i = 1; $i checkAllowed($checksumClient, $callString))
{
trigger_error("Operation not allowed for the current user!", E_USER_ERROR);
return;
}
// record deleting code...
return true;
}
Inside the Flash-Document, you dublicate
the button code and replace, getLogin by
deleteRecord. Then you have to configure the
callString-Variable from 'deleteRecord()' to 'deleteRecord(42)'.
regards, Holger
Posted by hOk at May 4, 2004 02:37 AM
Thanks Holger!
I suspected it might be like that but wasn't confident enough to go ahead and implement everywhere.
regards
Stefan
Posted by Stefan at May 4, 2004 04:57 AM
Yes, the documentation and the interface could
be better.
Just a tip, you could return the operation-key
from any service-method, this would make the
code on flashside easier.
regards, Holger
Posted by hOk at May 4, 2004 10:48 AM
Ah, so, store the initial authentication and re-use it for subsequent method calls? I did wonder whether you actually ever remotely called your destroySession() method as it is never called internally in the getOperationKey() method - is that an omission or was it a conscious decision to make the above suggestion possible?
Posted by Stefan at May 5, 2004 02:18 AM
I don't understand exactly what you mean.
You could call getOperationKey as Service
from flashside before calling an other Servic-Methods.
Thats exactly what the login-Script on flashside
does.
But if your service-method returns the next operation-key,
you got it on flashside, so you don't need to
call getOperationKey before calling the next
service-method.
Posted by hOk at May 5, 2004 01:16 PM
|
You can use <code>code that should be highlightned</code> to highlight code! Optionally you can use the attribut language="php|perl|java" within the code tag, otherwise actionscript-highlightning will be used. |
