You are here: Re: how to pass authorization to another application « PHP Programming Language « IT news, forums, messages
Re: how to pass authorization to another application

Posted by Colin McKinnon on 08/03/06 21:18

Taylor wrote:

> They are not on the same server. There is no shared internal method of
> communicating, so they can only interact via get/post, and cookies.
> The host application will authenticate the user, and then it needs to
> pass the username and something that proves they've been authenticated
> by the host app to my sub-app.

The best solution depends on how the user moves from site to the other,
whether HTTPS is involved and whether they have same FQDN. But lets take
the simplest case - where there is none of that:

on server A:

function getToken($username, $encryption_key)
{
$token=base64_encode(encrypt($username . "|" . time()));
return($token);
}

and add the token into the URL you are linking with or as a hidden field in
any forms being submitted to the other server. The at the other end:

function check_auth($token, $encryption_key)
{
$token=base64_decode($token);
$token=decrypt($token);
list($username, $timestamp)=explode('|',$token);
if (abs(time()-$timestamp)>60) { // more than 60 seconds apart
return(false);
} else {
return($username);
}
}

Obviously this is not going to prevent replay attacks - really you should be
using a challenge based mechanism.

The most efficient solution is to push the encryption and validation down to
the transport layer using a VPN though.

C.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация