Open mhoffmann75 opened 6 years ago
It has something todo with the code in BootstrapClass.php never running as it should:
commenting out
# $app->on(Application::EVENT_BEFORE_REQUEST, function () {
thus running the initialisation directly solved the error.
However still it does not work properly:
Second: BaseObject.php workaround for php 7.2 does not work correctly, had to change \yii\base\BaseObject in your BaseObject.php.
Any ideas how to get this properly running with latest php and latest yii2 ?
Forgot to mention: Login via /saml works of course.
Forgot to mention: Login via /saml works of course.
@mhoffmann75 thats the only intended purpose of the component.
You will have the data(whatever data received by the SAML payload) now in the call back, you can do whatever is your logic to integrate. For example, you may use in session, drive your UI logic etc.
public function actionIndex()
{
var_dump(Yii::$app->user);
}
If you don't see anything there, you need to see if the IDP is sending you anything. Use a SAML plugin on your browser and check the actual incoming payload.
If needed change the id attribute as in the README.
The strange thing is that working with /saml alone (test mode of simplesamlphp) returns all attributes from identity provider as expected. As said before, Yii::$app->user dumped from site/index does NOT contain any of these attributes or id.
However if if add this dumper in your _SamlController.php right before the $this->goBack(); its attributes and id are all visible in Yii::$app->user. So it seems as if the redirect to site/index starts a new session killing all settings. But i don't get why. Although the redirect is wrong as it should redirect to to the about page where i came from originally.
Any idea?
See in the Readme - Step 2. You need to know which attribute you should assign to yii. You need to specifically assign the attribute.
Seems i had some quirks in RBAC logic.
However your code does not work out of the box, as the bootstrap code which should init everything is never executed because of the EVENT_BEFORE_REQUEST.
After changing your BootstrapClass.php as follows the Error "ReflectionException: Class samlsettings does not exist in ..." went away:
class BootstrapClass implements BootstrapInterface
{
public function bootstrap($app)
{
// $app->on(Application::EVENT_BEFORE_REQUEST, function () {
//creating a controller for the login route
Yii::$app->controllerMap['_saml'] = '\lucidprogrammer\simplesamlphp\_SamlController';
//a globally accessible instance of saml
Yii::$container->set('saml',new Saml());
Yii::$container->set('samlsettings',new SamlSettings());
// TODO possibly check if the user has enabled /saml alias.
// });
}
}
Maybe you have an idea why this not working or you might check your code?
After enabling extension to the user class its broken:
I get the following error:
So what am i missing here?
yii2 Version: 2.0.15.1 php 7.2.8