philiplb / CRUDlexUser

CRUDlexUser is a library offering an user provider for symfony/security.
https://philiplb.de/crudlex/
MIT License
2 stars 0 forks source link

how to register the SecurityServiceProvider? #2

Closed gitdiz closed 8 years ago

gitdiz commented 8 years ago

Hello, I (sorry, newbie) want to use crudlexuser, coming from crudlex sample (lib and book). Following the doc I could get it working, until coming to the point "Simply instantiate and add it to your symfony/security configuration". Until here it works (crud operation and views are ok, including adding and deleting users and roles): $userProvider = new CRUDUserProvider($app['crud']->getData('user'), $app['crud']->getData('userRole')); At the point to register the SecurityServiceProvider (like this: [http://silex.sensiolabs.org/doc/providers/security.html#registering]) $app->register(new Provider\SecurityServiceProvider()); or $app->register(new Silex\Provider\SecurityServiceProvider()); the page stays blank, no error, nothing. How can I figure out, if the symfony/security it at the right place ((re)install it with php composer.phar require symfony/security ends with:

    Problem 1
    - philiplb/crudlexuser 0.9.9 requires symfony/security ~2.8 -> satisfiable by symfony/security[2.8.x-dev, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6] but these conflict with your requirements or minimum-stability  )

so I guess, it should work already from the CRUDlexUser module . Is somewhere an example sample project with working user authentification (and password reset feature)? Thank you very much, dirk

germain-italic commented 8 years ago

Would it help?

/*========================================
=            philiplb-crudlex            =
========================================*/

$app->register(new Silex\Provider\DoctrineServiceProvider(), $dboptions);

$dataFactory = new CRUDlex\MySQLDataFactory($app['db']);
$app->register(new CRUDlex\ServiceProvider(), array(
    'crud.file' => __DIR__ . '/../config/mysite.yml',
    'crud.datafactory' => $dataFactory,
    'crud.manageI18n' => false
));

/*============================================
=            philiplb/CRUDlexUser            =
============================================*/

$crudUserSetup = new CRUDlex\UserSetup();
$crudUserSetup->addEvents($app['crud']->getData('user'));
$userProvider = new CRUDlex\UserProvider($app['crud']->getData('user'), $app['crud']->getData('userRole'));

$app->register(new Silex\Provider\SecurityServiceProvider(), array(
    'security.firewalls' => array(
        'crud' => array(
            'pattern' => '^/crud/',
            'http' => true,
            'users' => array(
                'admin' => array('ROLE_ADMIN', 'xxx'),
            ),
            'users' => $userProvider,
            'logout' => array('logout_path' => '/user/logout', 'invalidate_session' => true)
        )
    )
));

return $app;
philiplb commented 8 years ago

Hi,

in general: If the page stays blank without error, check your webservers error log. PHP will print any serious error into it.

You might use CRUDlex 0.9.x-dev.

The rest just popped up as comment from @Germain-Italic . :)

At some point, I might extend the sample project with a login, user management and password reset functionality. Up until then this said: You have to implement the email sending currently on your own. And at some point, I might extend this package with some kind of default email functionality.

Let me know if you have any further questions.

gitdiz commented 8 years ago

Thank you, I will check your recommendations. I dont think that I use the dev-tree (not 100%sure) as my composer.json (in crudlex_sample_0.99 )says:

{
    "require": {
        "philiplb/crudlex": "0.9.9",
        "philiplb/crudlexuser": "0.9.9",
        "silex/web-profiler": "1.0.8"
    }
}

What works is this:

$userSetup = new CRUDUserSetup();
$userSetup->addEvents($app['crud']->getData('user'));
$userProvider = new CRUDUserProvider($app['crud']->getData('user'), $app['crud']->getData('userRole'));

Thanks for the tip with the php logfile, will check that later and come back. d.

philiplb commented 8 years ago

@gitdiz Good to hear that it is working now for you. :)

Here is how to switch to the latest dev-tree:

{
    "require": {
        "philiplb/crudlex": "0.9.x-dev",
        "philiplb/crudlexuser": "0.9.x-dev",
        "silex/web-profiler": "1.0.8"
    }
}

and then a

composer update