WFAuthorization

0 views
Skip to first unread message

rfallis

unread,
Jul 11, 2008, 5:36:27 PM7/11/08
to phocoa users, ct...@scratchspace.com
Welcome back, Alan.

Can you give/indicate an authorization/credential verification example
using WFAuthorization?

apinstein

unread,
Jul 16, 2008, 4:50:02 PM7/16/08
to phocoa users
Here's some code for you to chew on until I get a more complete
example finished. It should be enough to get you started, along with
the API docs.

Create your "login delegate class":

class admin_LoginDelegate
{
function login($username, $password, $passIsToken)
{
try {
$provider = ProviderPeer::retrieveByUsername($username);
if (!$provider) return NULL;

$cmpPass = ($passIsToken ? $password : md5($password));
if ($cmpPass == $provider->getPasswordMd5())
{
$authInfo = new WFAuthorizationInfo;
if ($provider->getUsername() == 'mysuperusername')
{
$authInfo->setIsSuperUser(true);
}
$authInfo->setUserid($provider->getProviderId());
return $authInfo;
}
} catch (Exception $e) {
throw($e);
}

return NULL;
}
}

And then, in MyWebApplicationDelegate::initialize(), put:

// set up authorization delegates
$ac = WFAuthorizationManager::sharedAuthorizationManager();
$ac->setDelegate(new admin_LoginDelegate);


That's it.

Of course, you'll have to adjust the logic code in the login delegate
to access your own data structures, but as you can see, it's quite
straightforward.

Alan
Reply all
Reply to author
Forward
0 new messages