Atomik Framework Forum

Discussions about Atomik Framework

You are not logged in.

#1 2010-02-12 16:38:12

Flashball
Member
From: Toulouse, France
Registered: 2010-02-08
Posts: 10
Website

Auth Plugin

Hi,

Thanks for your help for the backend plugin: I've got difficulties to configure properly the CRUD for my 2 tables linked with i18n properties, and I'm not sure it worth the price only for this 2 tables.

I think to create manually a little list + edition form for my needs, it could be a good start for this first project...

So, here what I hope to do: use the plugin Auth to login and manage authorization for the admin actions, let the plugin manage the 'adminuser' CRUD and add a personnal action to CRUD my 'News' logics.

Here's some configs:

config.php

Code:

Atomik::set('plugins', array(
    'Db' => array(
           'dsn'         => 'mysql:host=localhost;dbname=dbname',
           'username'    => 'root',
           'password'    => 'root'
    ),
    'Auth' => array(
            'route'        => 'backoffice/*',
            'model'             => 'Adminuser',
            'users'        => array(),
            'user_locator'    => null,
            'roles'         => array(),
            'resources'     => array(),
            'guest_roles'     => array(),
            'forbidden_action'     => 'auth/login',
            'backends'         => array()
        ),
));

boostrap.php

Code:

Atomik::set(
    'app/routes', array(
        'actualite/:lang/:id' => array(
            '@name' => 'news',
            'action' => 'news',
            'lang' => 'fr_FR',
            'id' => 'last'
        ),
        'backoffice/home' => array(
            '@name' => 'admin_home',
            'action' => 'backend/index',
        )
    )
);

login.post.php

Code:

// tries to authentify the user
if (Atomik_Auth::login($data['username'], md5($data['password']))) {
    // success, redirecting
    // Atomik::redirect(Atomik::get('request/from', Atomik::appUrl('/')), false);
    Atomik::redirect(Atomik::url('@admin_home'), false);
}

My first results:
After login, I've got "Atomik_Exception: Missing route named admin_home" (it's ok if I use the URL '/backoffice/index').
After that, I've got problem with i18n functions not loaded (__()) and finally a 'Fatal error: Class 'Atomik_Backend' not found'.
I've created an 'overrides/Auth' directory to manage my backend functionnalities (but I failed when trying to use the subdirectory 'backend'...).

What's the best way to use only the 'Auth' plugin and create my own backend?
Thanks a lot!

Offline

 

#2 2010-02-12 18:17:36

maxime
Administrator
From: Paris
Registered: 2009-01-02
Posts: 219
Website

Re: Auth Plugin

Ok you got me thinking for a bit before finding what was the problem! The thing is, the app configuration key (and all its sub keys) is reseted when a pluggable application is dispatched. Thus, when the Auth pluggable app kicks in, the app/routes is reseted and your route doesn't exist when you want to use it.

Do you know you can simply override the login.phtml view (overrides/Auth/views/login.phtml) to create your own form and do not touch the login.post.php file to keep the original logic. You can specify where to go once the login is completed by specifying the "from" parameter in the url (or in an hidden field in the form). Don't forget to use Atomik::appUrl() when you want to reference your application from a pluggable app (if not, the url will be relative to the plugg app).

For the __ function, this is weird. The backend is the only other plugin using it and it should not produce an error if the function isn't loaded. If you want to use it outside of the backend you should get the Lang plugin.

For the moment the Auth plugin is far from being complete and a lot of things are missing. Unfortunately you'll have to wait for the next version for a stable and complete release.

Hope it helps.

Offline

 

#3 2010-02-12 18:24:06

maxime
Administrator
From: Paris
Registered: 2009-01-02
Posts: 219
Website

Re: Auth Plugin

Also if you want to manage access rights, you can use the resources array (or the permissions page from the Users section in the backend).

Code:

Atomik::set('plugins/Auth/resources', array(
   'backend/Auth/*' => 'superadmin'
   'user/*' => array('admin', 'superadmin', 'user')
));

Offline

 

Board footer

Powered by FluxBB