Giter Site home page Giter Site logo

emreakay / codeigniter-aauth Goto Github PK

View Code? Open in Web Editor NEW
392.0 73.0 234.0 8.64 MB

Authorization, Authentication and User Management library for Codeigniter 2.x and 3.x to make easy user management and permission operations

Home Page: http://emreakay.com

License: GNU Lesser General Public License v3.0

PHP 100.00%
php login-ddos-protection aauth codeigniter codeigniter3 user-ban user-management user-auth authentication codeigniter-library

codeigniter-aauth's Introduction

Hi there πŸ‘‹

I was just testing this new cool feature and i like it

codeigniter-aauth's People

Contributors

alfonsor avatar anasthh avatar c2pdev avatar cekdahl avatar chland avatar code2prog avatar codelingobot avatar emreakay avatar emulsion-io avatar greenjackal avatar iecoding avatar jacobtomlinson avatar korllan avatar manukieli avatar mavisland avatar mirivlad avatar omkartapale avatar paulcanning avatar perenstrom avatar rejack avatar scombat avatar siarlex avatar suhindra avatar tobiasfichtner avatar totoprayogo1916 avatar tswagger avatar vipinks avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-aauth's Issues

SQL error: Column count doesn't match value count at row 1

On importing the Aauth_v2.sql I got the error that the column count doesn't match the value count. This is because at line 129, it ready

INSERT INTO `aauth_users` VALUES ('1', '[email protected]', 'dd5073c93fb477a167fd69072e95455834acd93df8fed41a2c468c45b394bfe3', 'Admin', '0', null, null, null, null, null, null, null, null, '0');

so the "ip_address" column isn't accounted for.

I'm new to github so I don't really know how to contribute patches. This worked for me:

--- Aauth_v2.sql    2015-08-13 14:51:14.682800397 +0200
+++ Aauth_v2.1.sql  2015-08-13 14:52:08.034799843 +0200
@@ -126,7 +126,7 @@
 -- ----------------------------
 -- Records of aauth_users
 -- ----------------------------
-INSERT INTO `aauth_users` VALUES ('1', '[email protected]', 'dd5073c93fb477a167fd69072e95455834acd93df8fed41a2c468c45b394bfe3', 'Admin', '0', null, null, null, null, null, null, null, null, '0');
+INSERT INTO `aauth_users` VALUES ('1', '[email protected]', 'dd5073c93fb477a167fd69072e95455834acd93df8fed41a2c468c45b394bfe3', 'Admin', '0', null, null, null, null, null, null, null, null, '127.0.0.1', '0');
 
 -- ----------------------------
 -- Table structure for `aauth_user_to_group`

Login Attempts

Why does login_attempts is updated even if login was successfully?

Logo for Aauth

I've been working on a simple logo for Aauth.

aauth

And the banner form.
banner

Any suggestions?

Do you have any Demand for Version2.

Hi Aauth users.
Aauth v2 will be relased in upcoming days with some new fetures.

If you have any idea or something you want to see in V2, you can write here.

Your opinions is valuable for me :)

db_prefix enhancement

I love your auth library.
I need some enhancement And i did it for me. I can not publish at the moment. But you can.

At the moment you need to change your default db connection profile prefix to aauth for your library.
But in fact it could be added on config variable as 'db_profile' and you can add Aauth library class a new variable aauth_db and if you call database connection after config variable and like this.
config > aauth.php

$config['aauth'] = array(
    'db_profile' => 'aauth', // aauth library use different dp_profile

add new public variable to Library class
libraries > Aauth.php

/**
     * The CodeIgniter object variable
     * @var object
     */
    public $aauth_db;

in constructor of libraries > Aauth.php call new db

         $this->CI->config->load('aauth');
         $this->config_vars = $this->CI->config->item('aauth');

         $this->aauth_db = $this->CI->load->database($this->config_vars['db_profile'],TRUE); 

and replace all "CI->db" with "aauth_db" in libraries > Aauth.php

and in database configuration you can add new database configuration profile
config > database.php

$db['aauth']['hostname'] = 'localhost';
$db['aauth']['username'] = 'username';
$db['aauth']['password'] = 'password';
$db['aauth']['database'] = 'username';
$db['aauth']['dbdriver'] = 'mysqli';
$db['aauth']['dbprefix'] = 'aauth_';
$db['aauth']['pconnect'] = TRUE;

is_allowed() bug

Say you wanna find out if a user (other than the currently logged in user) has a permission. You call is_allowed($perm_par, $user_id).

Then is_allowed() does the following:

  • Checks for matching rows in perm_to_user table. If found, returns true.
  • If not found, it will call is_group_allowed($perm_id) to see if the user's groups have the perm, without the second parameter.

But is_group_allowed($perm_id, false) checks for the currently logged in user's permission, this is not the expected behaviour.

I suggest to perform a different check arround line 1366:

if( $query->num_rows() > 0){
    return TRUE;
       } else {

        if( $user_id===FALSE){
            return $this->is_group_allowed($perm_id);
        } else {
            $g_allowed=FALSE;
            foreach( $this->get_user_groups($user_id) as $key=>$group ){
                if ( $this->is_group_allowed($perm_id, $group->id) ){
                    $g_allowed=TRUE;
                }
            }

            return $g_allowed;
        }
    }

Typos in function names.

The following functions are misspelled:
user_exsist_by_name()
user_exsist_by_email()

I'll create a PR with the appropriate fixes.

set_user_var() BUG

$this->aauth->unset_user_var( "possible_accounts" );
$this->aauth->set_user_var( "possible_accounts", 0 );

$possible = (int) $this->aauth->get_user_var( "possible_accounts" ) + 3;
$this->aauth->set_user_var( "possible_accounts", $possible );

the code above should end with only one record in database with value 3, but for some reason in database are two separate records with the key"possible_accounts" assigned to the same user with value 0 and 3. For some reason update is not working properly. I tried to find error there but I couldn't find it.

set_system_var bug

As with set_user_var there is the same bug with set_system_var where it will allow duplicate keys to be written to the system_variables table.

Simple fix on line 2039 change to:

if ($this->get_system_var($key)===false ) {

Invalid new config file

Wrong format:

['no_permission'] = FALSE,
['admin_group'] = 'admin',
...
...

Right format:

'no_permission' => FALSE,
'admin_group' => 'admin',
...
...

First wrong format may be true on PHP 5.6 but this is so unnecessary. I'm using PHP 5.4 and it doest work!

You must use the "set" method to update an entry.

While updating user record, encountered this problem.

You must use the "set" method to update an entry.
Filename: libraries/Aauth.php
Line Number: 831

But after settings db_debug to false in config/database.php file works fine.

Captcha

Someone working on an implementation Captcha in Aauth?

problem while using session driver as "database" and "use_cookies" true in aauth config

I encountered a problem while using session driver as "database" in CI config file and "use_cookies" to true in aauth config file but leaving "recaptcha_active" to false. It throws error while logging in and that is "Sorry, the reCAPTCHA text entered was incorrect."
As recaptcha_active is false, it must not do a check for that in login function. When session driver is set to "files", it works fine. Or is it not of any use in that that combination?

allow_user and allow_group problem

I found problem when not existing permission is defined as $perm_par parameter inside allow_user function. get_perm_id returns FALSE if permission is not defined in DB, and you forgot to check it inside allow_user function. After I run allow_user( "user_id", "dummy_per" ), perm_to_user table contains data with perm_id=0 value. allow_group has same problem, so would you like to check it please?

Bug on line 1256 in Aauth.php

on Line 1256 it is written:

$group_pars = $this->list_groups( $this->CI->session->userdata('id') );

which should be

$group_pars = $this->get_user_groups();

as groups of logged in user are required

Web Site for Aauth

Hi Aauth comunity.
I want to create a webpage for aauth. Actualy i t can be simple.
We can have Default page for introducing Aauth, Wiki page, Contribitiors page and success history to write who used Aauth with which project

I can buy domain.
Who can give support for hosting?
And who can design and manage the website?

Is this come with auto ban user??

Hi,
I just want to know , is this possible to ban a user after some login failed ???

Because when i m trying to login with wrong login details, its not changing the status of banned flag in database

Change licence?

Have you considered changing the licence to MIT, or dual licence - to bring it inline with codeigniter 3's licence.

GPL and derivatives scare off a log of people who might use the library, and the more people who use it - the more are likely to contribute back.

Cookie expires not working

How to make email based usernames?

I want to use email as username and name column as users Firs and Last name? Is it possible withouth a lot of changes or just simply to use user variables?

A problem with get_(errors|infos)_array

In the constructor of the library file there is this line:

    $this->errors = $this->CI->session->flashdata('errors');
    $this->infos = $this->CI->session->flashdata('infos');

The problem with this is that that if errors and infos do not exist, the flashdata returns FALSE. So later in the get_(errors|infos)_array functions that look like this

public function get_infos_array()
{
    if (!count($this->infos)==0)
    {
        return $this->infos;
    }
    else
    {
        return array();
    }
}

it doesn't end up right. When the argument of count is not an array or an object implemented with the Countable interface, count returns 1. So actually the above function returns FALSE when no messages have been specified, instead of an empty array. This became a problem for me, so I've temporarily fixed it like this:

    $this->errors = $this->CI->session->flashdata('errors') ?: array();
    $this->infos = $this->CI->session->flashdata('infos') ?: array();

And I also believe that you could write the above function like this:

public function get_infos_array()
{
    return $this->infos;
}

Login method always returns false

Hi!

I initiate myself to codeigniter and i downloaded CodeIgniter-Aauth library for authentication of users in my project. I followed all the steps needed to install the library but when i want to use the "login" method in a controller, this method always returns false. For example, when i want to check if the entered values in the login form are present in database...

Please help me

Bug in public function delete_perm($perm_par)

on Line 1177 and 1181 it is written:

$this->CI->db->where('pern_id', $perm_id);

Here spellings of column are incorrect which does not allow to delete permission. It should be 'perm_id' instead of 'pern_id' as mentioned below

$this->CI->db->where('perm_id', $perm_id);

Bug in update_user()

The variable $valid is not initialized. So if you are not validation error, the function don't find $valid.

Admin Super user for only current company

Hello,

I have an application where there 3 different users. Admin, Manager, Agent.

The problem is I see Admin has access to EVERYTHING, and i want to have access to everything but ONLY in his company and not able to see other customers data.

Example. There are 2 companies.

Coca-Cola and Pepsi.

Admin from coca cola should see EVERYTHING from Coca-Cola but he cant see anything from Pepsi.

how to you recommend me to handle this function with CI Aauth?

Fatal error: has_userdata is not defined.

I'm getting this error message:

PHP Fatal error: Call to undefined method CI_Session::has_userdata() in /path/to/codeigniter/application/libraries/Aauth.php on line 400

I have checked the session library in Codeigniter 2.2.3 and there is indeed no such function. There is a forum thread which indicates that it was deprecated a while ago.

Undefined method CI_Session::tempdata()

I get this error:

PHP Fatal error: Call to undefined method CI_Session::tempdata() in /path/to/codeigniter/application/libraries/Aauth.php on line 225

because tempdata only exists in CodeIgniter 3, not 2.x.

This issue is related to #58 which is about another function that is only available in Codeigniter 3.

is_group_allowed will always be the true value.

i like Aauth. i love Aauth...
But I request to you.
This will be true for this function is allowed and is_group_allowed.
It is very dangerous code when admin permissions and group permissions check.
I request to the code Delete or Change.

$group_pars = $this->list_groups();
foreach ($group_pars as $g ){
if($this->is_group_allowed($perm_id, $g->id)){
return true;
}
}

i try admin or admingroup checking code:

if(!$this->aauth->is_group_allowed(1)):
$this->session->flashdata('message','νšŒμ›λ‹˜μ€ κ΄€λ¦¬μžκ°€ μ•„λ‹™λ‹ˆλ‹€. μ§€μ†μ μœΌλ‘œ 접속 μ‹œλ„ν• μ‹œμ— μžλ™μœΌλ‘œ μ •μ§€μ²˜λ¦¬ λ©λ‹ˆλ‹€.');
redirect('/');
endif;

But this code always return true...
I request to the code Delete or Change.

Enchantment on is_allowed() function

This is current is_allowed() function

public function is_allowed($perm_par, $user_id=FALSE)
{
    $perm_id = $this->get_perm_id($perm_par);
    if( $user_id == FALSE){
        $user_id = $this->CI->session->userdata('id');
    }

    .
    .
    .
}

I think this should be like:

public function is_allowed($perm_par, $user_id=FALSE)
{
    if( $user_id == FALSE)
    {
        $user_id = $this->CI->session->userdata('id');
    }

    if($this->is_admin($user_id))
    {
        return true;
    }

    $perm_id = $this->get_perm_id($perm_par);

    .
    .
    .
}

I think is_admin() condition is first of all. Right? Admin is super user and it does not affect whether have permit.

User Variables

So I have just updated to Aauth 2.0 and I am trying to use User Variables.

They are working just fine except for when I create one and then try to update it. Rather than updating, it creates a new one for the same user. So then you end up with multiple variables of the same thing because it creates a new row in the database each time.

Is anyone else having this issue or is it just me? I have uploaded a screenshot of the function in my controller if that helps at all...

Well, It seems to only do it with nuerical values (1-9) because the other variable I have set up for a business name works just fine.

screen shot 2014-08-20 at 9 13 19 pm

Database relations?

Can i create relations between tables? Which fields i need to put in relation?

Tank_auth to Aauth

Hello!

Is there a way to migrate the users with same hashes in use on my application to Aauth?

Thanks.

Updating user doesn't work, library raises warnings

Hi, thanks for this great library!

I ran into some issue now, it's strange, this was working before. When I call:

$this->aauth->update_user("6", false, false, "New name");

The user is never updated and I receive the following warnings:

Message: Undefined variable: valid
Filename: libraries/Aauth.php
Line Number: 714

Message: Invalid argument supplied for foreach()
Filename: libraries/Aauth.php
Line Number: 1774

version 2.0

Bug / Feature Lacking in function delete_perm() and delete_group()

Hello,

I found the following some problem as described below:
Please take a look

public function delete_perm($perm_par) {
     ...........
     // deletes from perm_to_user table
     $this->aauth_db->where('perm_id', $perm_id);
     $this->aauth_db->delete($this->config_vars['perm_to_group']);
     .........
}

should be

public function delete_perm($perm_par) {
     ...........
     // deletes from perm_to_user table
     $this->aauth_db->where('perm_id', $perm_id);
     $this->aauth_db->delete($this->config_vars['perm_to_user']);
     .........
}

and in the another delete_group function(), we should add delete perms from perm_to_group table

public function delete_group($group_par) {
     // now users are deleted from user_to_group table
     $this->aauth_db->where('group_id', $group_id);
     $this->aauth_db->delete($this->config_vars['user_to_group']);

     // delete permission from perm_to_group table 
     // STARTS
     // now perms are deleted from perm_to_group table
     $this->aauth_db->where('group_id', $group_id);
     $this->aauth_db->delete($this->config_vars['perm_to_group']);
     // ENDS

     $this->aauth_db->where('id', $group_id);
     return $this->aauth_db->delete($this->config_vars['groups']);
}

Thank you !!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.