+
+
+ +
Aauth is a User Authorization Library for CodeIgniter 2.x and 3.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite its ease of use, it has also very advanced features like private messages, groupping, access management, and public access.
-Codeigniter-aauth
-Authorization, authentication and User Management library for Codeigniter 2.x to make easy user management and permission operations
-Aauth is a User Authorization Library for CodeIgniter 2.x, which aims to make easy some essential jobs such as login, permissions and access operations. Despite ease of use, it has also very advanced features like private messages, groupping, access management, public access etc..
- -After Quick Start, Take a look detailed Documentation from wiki
+This is Quick Start page. You can also take a look at the detailed Documentation Wiki to learn about other great Features
-Features
- --
-
- User Management and Operations (login, logout, register, vertification via e-mail, forgoten password, ban management, login ddos protection) -
- Group Operations (Creaing, deleting groups, membership management) -
- Admin and Public Group support (Public permissions) -Permission Management (creating,deleting permissons, allow, deny groups, public permissions, permission checking) -
- Group Permissions -
- User Permissions (new) -
- User and System Variables (new) -
- Login Ddos Protection (new) -
- Private Messages (pm between users) -
- Error Mesages and Validations + Features + +
- User Management and Operations (login, logout, register, verification via e-mail, forgotten password, user ban, login DDoS protection) +
- Group Operations (creating/deleting groups, membership management) +
- Admin and Public Group support (Public permissions) +
- Permission Management (creating/deleting permissions, allow/deny groups, public permissions, permission checking) +
- Group Permissions +
- User Permissions +
- User and System Variables +
- Login DDoS Protection +
- Private Messages (between users) +
- Error Messages and Validations
- Langugage and config file support -
- Flexible -
- Flexible implementation +
+ +
-
+
-What is new in Version 2
++
+ + What is new in Version 2-
-
+
- User Permissions
- User and System Variables -
- Login Ddos Protection -
- Some functions has changed -
- Some bugs fixed -
- Login DDoS Protection +
- Updated functions (check documentation for details) +
- Bugs fixes +
- TOTP (Time-based One-time Password) +
-Migration
+-
-
- if you have been using Version 1 before, take a look at Migration Page -
-Quick Start
++
+ + Migration-
Let's start :)
-Firstly we will load Aauth Library to system
-
+
- If you are currently using Version 1, take a look at the v1 to v2 migration page.. +
$this->load->library("Aauth");
-
+
- Quick Startthats OK.
+-
Now we will create 2 new users, Ali and John
+Let's get started :) +First, we will load the Aauth Library into the system
-$this->aauth->create_user('ali@ali.com','alispass','Ali Akay');
-$this->aauth->create_user('john@john.com','johnspass','John Button');
-
$this->load->library("Aauth");
thats it. now we have two users.
+That was easy!
-Lets Create two group governors and commons :)
+Now let's create two new users, Frodo
and Legolas
.
$this->aauth->create_group('governors');
-$this->aauth->create_group('commons');
-
$this->aauth->create_user('frodo@example.com','frodopass','Frodo Baggins');
+$this->aauth->create_user('legolas@example.com','legolaspass','Legolas');
Then, Lets Create a User with power whic is Obama (having id=12)
+We now we have two users.
-$this->aauth->create_user('obama@usa.gov', 'pass-cia-fbi', 'Barrack Obama');
-
OK, now we can create two groups, hobbits
and elves
.
ok now we have two groups and one user.
+$this->aauth->create_group('hobbits');
+$this->aauth->create_group('elves');
Lets create a permissions 'incrase_tax' and 'change_government'
+Now, let's create a user with power, Gandalf (for our example, let's assume he was given the id
of 12).
$this->aauth->create_perm('increase_tax');
-$this->aauth->create_perm('change_government');
-
$this->aauth->create_user('gandalf@example.com', 'gandalfpass', 'Gandalf the Gray');
Ok, now lets give accesses. logically 'governors' will have 'increase_tax' permission and 'commons' will have 'change_government' access.
-ok lets give proper access with alow_group() function
OK, now we have two groups and three users.
-$this->aauth->allow_group('governors','increase_tax');
-$this->aauth->allow_group('commons','change_government');
+Let's create two permissions walk_unseen
and immortality
+$this->aauth->create_perm('walk_unseen');
+$this->aauth->create_perm('immortality');
-$this->aauth->allow_group('commons','increase_tax');
-
Ok, now let's give accesses to our groups. The Hobbits seem to have ability to walk unseen, so we will assign that privilage to them. The Elves have imortality, so we will assign that privilage to them.
+We will assign access with allow_group()
function.
Ops wait a minute. commons cannot 'increase_tax'. we need to fix it, we will use deny() to take back permission.
+$this->aauth->allow_group('hobbits','walk_unseen');
+$this->aauth->allow_group('elves','immortality');
+
+
+$this->aauth->allow_group('hobbits','immortality');
$this->aauth->deny('commons','increase_tax');
-
Wait a minute! Hobbits should not have immortality
. We need to fix this, we can use deny()
to remove the permission.
Obama also can increse tax ha?
+$this->aauth->deny('hobbits','immortality');
$this->aauth->allow_user(12,'increase_tax');
-
Gandalf can also live forever.
-Ok now lets check if commons can 'increase_tax'
+$this->aauth->allow_user(12,'immortality');
if($this->aauth->is_group_allowed('commons','increase_tax')){
- // i dont think so
-} else {
- // do sth in the middle
-}
-
Ok now let's check if Hobbits have immortality
.
Can Obama increase_tax ? Let's check it.
+if($this->aauth->is_group_allowed('hobbits','immortality')){
+ echo "Hobbits are immortal";
+} else {
+ echo "Hobbits are NOT immortal";
+}
if($this->aauth->is_allowed(15,'increase_tax')){
- // i guess so
-} else {
- // piece of code
-}
-
Results:
-i think 'increse_tax' must have never been created. just delete it
+Hobbits are NOT immortal
+
-$this->aauth->delete_perm('increase_tax');
-
Does Gandalf have the ability to live forever?
-now better.
+if($this->aauth->is_allowed(12,'immortality')){
+ echo "Gandalf is immortal";
+} else {
+ echo "Gandalf is NOT immortal";
+}
So what about public people? (public means not logged users). Can public people travel? Lets assume we have permissions namely 'travel' , of course.
+Results:
-$this->aauth->allow_group('public','travel');
-
Gandalf is immortal
+
-So Admin? what can he do? He can access everthing, You dont need to give permiision ( using allow_group() or allow_user() ) him, he already has.
+Since we don't accually live in Middle Earth, we are not aware of actual immortality. Alas, we must delete the permission.
-What about User Variables? -for every individual user, variables can be defined as key-value.
+$this->aauth->delete_perm('immortality');
this is a simple example to set a variable.
+It is gone.
-$this->aauth->set_user_var("key","value");
-
+
- Un-authenticated UsersFor example if you want to keep users phones
+So, how about un-authenticated users? In Aauth they are part of the public
group. Let's give them permissions to travel
.
+We will assume we already have a permission set up named travel
.
$this->aauth->set_user_var("phone","0216 313 23 33");
-
$this->aauth->allow_group('public','travel');
to get the variable
++
- Admin Users$this->aauth->set_user_var("key");
-
What about the Admin users? The Admin
user and any member of the Admin
group is a superuser who had access everthing, There is no need to grant additional permissions.
Aauth also permits you to define System Variables which can be accesed by every user in the system.
++
- User Parameters/Variables$this->aauth->set_system_var("key","Value");
-$this->aauth->set_system_var("key");
-
For each user, variables can be defined as individual key/value pairs.
-ok lets look at private messages. John (his id=3) will send pm to Ali(id=4)
+$this->aauth->set_user_var("key","value");
$this->aauth->send_pm(3,4,'Hi bro. i need you',' can you gimme your credit card?')
-
For example, if you want to store a user's phone number.
-sorry John you will be banned :(
+$this->aauth->set_user_var("phone","1-507-555-1234");
$this->aauth->ban_user(3);
-
To retreive value you will use get_user_var()
:
Quick Start is done but thats not the end
-Take a look detailed Documentation from wiki
$this->aauth->get_user_var("key");
Dont forget to watch Aauth.
-You can also contribute and help me :)