How can i using login callback?

52 views
Skip to first unread message

Vince zer0

unread,
Feb 12, 2021, 5:51:01 AM2/12/21
to SimpleSAMLphp
Hello,
I try to use a callback when logging in, but I get an exception.

here is my code :
<?php
session_start();

require_once(dirname(__FILE__).'/../simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('example-sql');

function LoginCallback()
{
    echo "Callback !!!!!!!!!!!!!!!!!";
}

$as->requireAuth([
    'ReturnCallback' => 'LoginCallback',
    ]);

$attributes = $as->getAttributes();
SimpleSAML_Session::getSessionFromRequest()->cleanup();

print_r($attributes);
?>

here is the exception :

SimpleSAML\Error\Error: UNHANDLEDEXCEPTION

Backtrace: 1 www\_include.php:20 (SimpleSAML_exception_handler) 0 [builtin] (N/A) Caused by: TypeError: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members Backtrace: 7 lib\SimpleSAML\Auth\Source.php:250 (call_user_func) 6 lib\SimpleSAML\Auth\Source.php:250 (SimpleSAML\Auth\Source::loginCompleted) 5 [builtin] (call_user_func) 4 lib\SimpleSAML\Auth\Source.php:161 (SimpleSAML\Auth\Source::completeAuth) 3 modules\core\lib\Auth\UserPassBase.php:331 (SimpleSAML\Module\core\Auth\UserPassBase::handleLogin) 2 modules\core\www\loginuserpass.php:84 (require) 1 lib\SimpleSAML\Module.php:266 (SimpleSAML\Module::process) 0 www\module.php:10 (N/A)

without the callback it works fine.
do you have an idea?

pat...@cirrusidentity.com

unread,
Feb 16, 2021, 1:38:19 PM2/16/21
to SimpleSAMLphp
 I think 'ReturnCallback'  is suppose to be an array. If your function is static then first array element is the class name and 2nd is function name. I'm not sure about using instance objects in the callback, since state gets serialized as part of redirecting the user to a IdP or login page.

- Patrick

Reply all
Reply to author
Forward
0 new messages