Welcome Guest, Not a member yet? Register   Sign In
DX Auth 1.0.6 (Authentication library)

[eluser]dexcell[/eluser]
[quote author="humugus" date="1229458415"]thank you very much for a great library, which by the way was implemented very easily to my project although i'm a newbie in CI and PHP programming Smile[/quote]

Well, glad to help.

[eluser]dexcell[/eluser]
[quote author="Berserk" date="1229436390"]greats !!! Smile

can you zip your document ? i want to download to view offline like CI's doc Big Grin[/quote]

Thanks, i thought no one would like the offline docs Tongue ,
so i remove it to save bandwidth.
For mean time you can download it from

http://dexcell.shinsengumiteam.com/dx_au..._guide.zip

[eluser]Iverson[/eluser]
[quote author="dexcell" date="1229461487"]Thanks Iverson,

In my opinion, i think it's better creating a parser function to parse DX Auth config file,
then display it to GUI page.
Then if you save it you can create new config file, overwrite the old config.

The benefit if you are creating the parser you can parse practically any static config (not only DX Auth),
and display it to your GUI page.

This way also you don't need to edit DX_Auth core.[/quote]

True, but I'm not a fan of parser functions. Files can get cached, then you have to worry about picking up the changes i.e. refreshing, etc.

[eluser]Typeslowly[/eluser]
Dexcell this is great, exactly what I needed, is fast, secure, and easy to integrate into my own project.

:coolsmile:

many thanks

[eluser]Johan André[/eluser]
I have a question regarding expanding the functionality of this library:

Is it possible to extend it from MY_DX_Auth to inherit the method and goodness from DX_Auth but in the extending library write my new functionality?

Would be great! Then I could expand it without worring (not so much anyway) about upgrading.

[eluser]dexcell[/eluser]
^
It's possible, but unfortunately it was written for compatibility,
Actually some function and variable should be declared as protected, but it was declared using private because of the limitation in php4, so you might not able to access it.

[eluser]sofbas[/eluser]
Looks like an excellent auth library. I haven't really used it, but after looking at all the auth libraries I will be settling with this one.

A question, why didn't you put your plugin in application/plugins directory?

[eluser]dexcell[/eluser]
[quote author="sofbas" date="1229504376"]Looks like an excellent auth library. I haven't really used it, but after looking at all the auth libraries I will be settling with this one.

A question, why didn't you put your plugin in application/plugins directory?[/quote]

Thanks, will put it there later,
I thought it was not possible since there is no plugins directory in application directory.

[eluser]dexcell[/eluser]
[quote author="Typeslowly" date="1229483391"]Dexcell this is great, exactly what I needed, is fast, secure, and easy to integrate into my own project.

:coolsmile:

many thanks[/quote]

:coolsmile:

[eluser]Paul Apostol[/eluser]
Hello,
Because the holidays are near us and I will take a break for the next 15 days I will expose some of my ideas (I need them in a project of mine).
The base idea is that when I'm checking the URI I need to have an extra value in return. Also I've tried to adapt it to single or multiple roles.
I'm waiting for your comments and ideas to improve it Wink
<b>WARNING: not tested, not optimized, with some problems in the logic, work in progress, for 1.0.2</b>
First of all the database additions:
Code:
CREATE TABLE `app_controllers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
INSERT INTO `app_controllers` VALUES (1,'backend');

CREATE TABLE `app_controllers_methods` (
  `controller_id` int(11) DEFAULT NULL,
  `method_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `app_controllers_methods` VALUES (1,1);
INSERT INTO `app_controllers_methods` VALUES (1,2);
INSERT INTO `app_controllers_methods` VALUES (1,3);

CREATE TABLE `app_levels` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
INSERT INTO `app_levels` VALUES (1,'not allowed');
INSERT INTO `app_levels` VALUES (2,'worker');
INSERT INTO `app_levels` VALUES (3,'supervisor');
INSERT INTO `app_levels` VALUES (4,'manager');

CREATE TABLE `app_methods` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `app_methods` VALUES (1,'index');
INSERT INTO `app_methods` VALUES (2,'uri_permissions');
INSERT INTO `app_methods` VALUES (3,'custom_permissions');

CREATE TABLE `app_modules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
INSERT INTO `app_modules` VALUES (1,'module1');
INSERT INTO `app_modules` VALUES (2,'module2');

CREATE TABLE `app_modules_controllers` (
  `module_id` int(11) DEFAULT NULL,
  `controller_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `app_modules_controllers` VALUES (1,1);

CREATE TABLE `users_roles` (
  `role_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

In dx config file:
Code:
$config['DX_module_name'] = 'module1';
$config['DX_module_role'] = 'single';

In Roles model:
Code:
function get_roles($user_id)
{
    $this->db->where('user_id', $user_id);
    $_table = $this->_prefix.$this->config->item('DX_roles_users');
    return $this->db->get($_table);
}

In "backend" you have to replace all "DX_Auth" with "DX_Auth_Ext" and "dx_auth" with "dx_auth_ext".

You have to add a new model:
Code:
class Application extends Model
{
    function Application()
    {
        parent::Model();
        
        // Other stuff
        $this->_prefix = $this->config->item('DX_table_prefix');
        $this->_modules = 'app_modules';
        $this->_controllers = 'app_controllers';
        $this->_methods = 'app_methods';
        //$this->_table = $this->_prefix.$this->config->item('DX_roles_table');
    }
    
    function get_modules()
    {
        $this->db->order_by('id', 'asc');
        return $this->db->get($this->_modules);
    }
    
    function get_modules_by_id($mod_id)
    {
        $this->db->order_by('id', 'asc');
        $this->db->where('id', $mod_id);
        return $this->db->get($this->_modules);
    }
    
    function get_controllers($module_id)
    {
        $this->db->select('*');
        $this->db->from($this->_controllers);
        $this->db->join('app_modules_controllers', 'app_controllers.id = app_modules_controllers.controller_id');
        $this->db->where('module_id', $module_id);
        return $this->db->get();
    }
    function get_methods($controller_id)
    {
        $this->db->select('*');
        $this->db->from($this->_methods);
        $this->db->join('app_controllers_methods', 'app_methods.id = app_controllers_methods.method_id');
        $this->db->where('controller_id', $controller_id);
        return $this->db->get();
    }
    
    function get_levels()
    {
        $this->db->order_by('id', 'asc');
        return $this->db->get('app_levels');
    }
}

Functions to add in backend:
Code:
function cleanup_module($current, $parent)
{
    foreach($current as $crt_k=>$crt_v)
    {
        if($crt_v == 0)
        {
            if($parent[$crt_k] == 'n')
            {
                unset($current[$crt_k]);
            }
        }
    }
    return $current;
}

Oops, the second function for backend will be in the next post.




Theme © iAndrew 2016 - Forum software by © MyBB