You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
5.4 KiB

12 years ago
***
10 years ago
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.
12 years ago
**This is Quick Start page. You can also take a look at the [detailed Documentation Wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages) to learn about other great Features**
12 years ago
12 years ago
### Features
12 years ago
***
* 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)
12 years ago
* 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
12 years ago
* Langugage and config file support
* Flexible implementation
12 years ago
11 years ago
### What is new in Version 2
***
* User Permissions
* User and System Variables
* Login DDoS Protection
* Updated functions (check documentation for details)
* Bugs fixes
* TOTP (Time-based One-time Password)
11 years ago
### Migration
***
* If you are currently using Version 1, take a look at the [v1 to v2 migration page.](https://github.com/emreakay/CodeIgniter-Aauth/wiki/1%29-Migration-from-V1).
11 years ago
12 years ago
### Quick Start
12 years ago
***
Let's get started :)
First, we will load the Aauth Library into the system
12 years ago
```php
$this->load->library("Aauth");
```
That was easy!
Now let's create two new users, `Frodo` and `Legolas`.
12 years ago
```php
$this->aauth->create_user('frodo@example.com','frodopass','Frodo Baggins');
$this->aauth->create_user('legolas@example.com','legolaspass','Legolas');
12 years ago
```
We now we have two users.
12 years ago
OK, now we can create two groups, `hobbits` and `elves`.
12 years ago
```php
$this->aauth->create_group('hobbits');
$this->aauth->create_group('elves');
12 years ago
```
Now, let's create a user with power, Gandalf (for our example, let's assume he was given the `id` of 12).
11 years ago
```php
$this->aauth->create_user('gandalf@example.com', 'gandalfpass', 'Gandalf the Gray');
11 years ago
```
OK, now we have two groups and three users.
12 years ago
Let's create two permissions `walk_unseen` and `immortality`
12 years ago
```php
$this->aauth->create_perm('walk_unseen');
$this->aauth->create_perm('immortality');
12 years ago
```
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.
12 years ago
```php
$this->aauth->allow_group('hobbits','walk_unseen');
$this->aauth->allow_group('elves','immortality');
12 years ago
$this->aauth->allow_group('hobbits','immortality');
12 years ago
```
Wait a minute! Hobbits should not have `immortality`. We need to fix this, we can use `deny()` to remove the permission.
12 years ago
```php
$this->aauth->deny('hobbits','immortality');
12 years ago
```
Gandalf can also live forever.
11 years ago
```php
$this->aauth->allow_user(12,'immortality');
11 years ago
```
Ok now let's check if Hobbits have `immortality`.
12 years ago
```php
if($this->aauth->is_group_allowed('hobbits','immortality')){
echo "Hobbits are immortal";
12 years ago
} else {
echo "Hobbits are NOT immortal";
12 years ago
}
```
Results:
```
Hobbits are NOT immortal
```
12 years ago
Does Gandalf have the ability to live forever?
12 years ago
```php
if($this->aauth->is_allowed(12,'immortality')){
echo "Gandalf is immortal";
11 years ago
} else {
echo "Gandalf is NOT immortal";
11 years ago
}
12 years ago
```
Results:
```
Gandalf is immortal
```
12 years ago
Since we don't accually live in Middle Earth, we are not aware of actual immortality. Alas, we must delete the permission.
12 years ago
11 years ago
```php
$this->aauth->delete_perm('immortality');
11 years ago
```
It is gone.
#### Un-authenticated Users
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`.
11 years ago
```php
$this->aauth->allow_group('public','travel');
```
#### Admin Users
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.
12 years ago
#### User Parameters/Variables
For each user, variables can be defined as individual key/value pairs.
11 years ago
```php
$this->aauth->set_user_var("key","value");
```
For example, if you want to store a user's phone number.
11 years ago
```php
$this->aauth->set_user_var("phone","1-507-555-1234");
11 years ago
```
To retreive value you will use `get_user_var()`:
11 years ago
```php
11 years ago
$this->aauth->get_user_var("key");
11 years ago
```
Aauth also permits you to define System Variables. These can be which can be accesed by all users in the system.
11 years ago
```php
$this->aauth->set_system_var("key","value");
11 years ago
$this->aauth->get_system_var("key");
11 years ago
```
#### Private Messages
OK, let's look at private messages. Frodo (`id` = 3) will send a PM to Legolas (`id` = 4);
12 years ago
```php
$this->aauth->send_pm(3,4,'New cloaks','These new cloaks are fantastic!')
12 years ago
```
#### Banning users
10 years ago
Frodo has broke the rules and will now need to be banned from the system.
12 years ago
```php
$this->aauth->ban_user(3);
```
You have reached the end of the Quick Start Guide, but please take a look at the [detailed Documentation Wiki](https://github.com/emreakay/CodeIgniter-Aauth/wiki/_pages) for additional information.
Don't forget to keep and eye on Aauth, we are constantly improving the system.
You can also contribute and help me out. :)