PHPackages                             dnj/laravel-aaa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dnj/laravel-aaa

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dnj/laravel-aaa
===============

Authentication + Authorization + Accounting For Your Next Laravel Project!

v1.1.2(1y ago)02431[1 issues](https://github.com/dnj/laravel-aaa/issues)3MITPHPPHP ^8.1

Since Apr 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dnj/laravel-aaa)[ Packagist](https://packagist.org/packages/dnj/laravel-aaa)[ RSS](/packages/dnj-laravel-aaa/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (7)Versions (7)Used By (3)

[![](docs/static/images/aaa.webp)](docs/static/images/aaa.webp)

**Laravel-AAA**, a customizable and modern package for Authentication + Authorization + Accounting for your laravel project

####  [Discussions](https://github.com/dnj/laravel-aaa/discussions) • [Documentation](https://github.com/dnj/laravel-aaa)

[](#----discussions--------documentation)

[![LICENSE](https://camo.githubusercontent.com/0e66d52fc368b59aa4a47cee195ad29e3bb7eb6adaa6d91b8060f0406593f8fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646e6a2f6c61726176656c2d6161612e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/blob/master/LICENSE)[![Download Counts](https://camo.githubusercontent.com/6f3218adcb341d1c8726413f9e16a3f355f2ddbc5547f191b8d5d25d7f16e20d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f646e6a2f6c61726176656c2d6161612f746f74616c2e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/releases)[![Stars Count](https://camo.githubusercontent.com/be2b7753114229d693c342411ad05fdbcc8a5d6969789f86481bfe07eb21406f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f646e6a2f6c61726176656c2d6161612e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/stargazers)[![Forks Count](https://camo.githubusercontent.com/189c849567215c7e4cac875ece7f250650245e447bbe902faf3614ac43ad1135/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f646e6a2f6c61726176656c2d6161612e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/network/members)[![Watchers Count](https://camo.githubusercontent.com/138e178e78dbbd2e5dcfc5cb94bbb0c635bb543fe98e7726e4716ce291361abc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f77617463686572732f646e6a2f6c61726176656c2d6161612e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/watchers)[![Issues Count](https://camo.githubusercontent.com/4d5ba823a3f57df44d3e1ae139a0b42b5ef24cd4ff59dcd10342ef847c4b7a51/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f646e6a2f6c61726176656c2d6161612e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/issues)[![Pull Request Count](https://camo.githubusercontent.com/6722df370722852d82c8a756f0b457fefa6963c27f2c4fc2c510370679fba0bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f646e6a2f6c61726176656c2d6161612e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/dnj/laravel-aaa/pulls)[![Follow](https://camo.githubusercontent.com/da1392d237bc58e57217bcc4b5e72a38488c23593b6efea2a203cfb8e90de90a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f6c6c6f776572732f646e6a2e7376673f7374796c653d666f722d7468652d6261646765266c6162656c3d466f6c6c6f77266d61784167653d32353932303030)](https://github.com/dnj)

---

What is Laravel-AAA?
====================

[](#what-is-laravel-aaa)

Authentication is one of web applications most critical and essential features. Web frameworks like Laravel provide many ways for users to authenticate.
You can implement Laravel authentication features quickly and securely. However, implementing these authentication features poorly can be risky, as malicious parties can exploit them.
But, we built a fully customizable package from ground-up to solve this!

Some Laravel-AAA's features in summary are:

- Secure!
- Easy to use.
- Fully customizable.
- Best practices applied.
- Latest versions of PHP and PHPUnit
- Most importantly, It's an Free Open Source Software (FOSS)!

Laravel-AAA is currently under heavy development. You can give your suggestions and feedback on our [Discussions](https://github.com/dnj/laravel-aaa/discussions/) page.

How to start
------------

[](#how-to-start)

First of all, you need a laravel installation, You can start a laravel project by running command:

```
composer create-project laravel/laravel my-awesome-laravel-app
```

Or if you already have Laravel, install laravel-aaa in your project by running:

```
composer require dnj/laravel-aaa
```

Then, publish configs using this command:

```
php artisan vendor:publish --tag=config
```

This will results:

```
INFO  Publishing [config] assets.

Copying file [vendor/dnj/laravel-aaa/config/aaa.php] to [config/aaa.php] .................................................................... DONE
Copying file [vendor/dnj/laravel-user-logger/config/user-logger.php] to [config/user-logger.php] ............................................ DONE

```

As you see, there are a [aaa.php](https://github.com/dnj/laravel-aaa/blob/master/config/aaa.php) config file that we use it later.

Concepts
--------

[](#concepts)

We deal with some concepts, like: `Type`, `TypeAbility`, `TypeLocalizedDetails`, `User` and `Username`

### Type

[](#type)

We define some `Type`s in our app, consider a `Type` is a user level that defines user has access to which fetures of your app. The `Type` has an id, a localized nameds that can be defined for any languages, maybe a parent, paybe some child, and some abilities.

### TypeAbility

[](#typeability)

Consider this as a permission for user, each ability is belong to a `Type`.

### User

[](#user)

Each user is has a Type and the Type define that this user has access to which fetures of your app.

### Username

[](#username)

Each user may have some usernames, username can be anything, like: email, cellphone, telegram id, ....

aaa.php
-------

[](#aaaphp)

In this file, you can define the guest type, if user not exists in you app (or not logged in), the app will use this type for check permissions. define the ID of the guest type in `aaa.php` in `guestType` property.

```
[
    'guestType' => 2, // The id of guest type
];
```

Policies
--------

[](#policies)

Laravel-AAA provides support for [polices](https://laravel.com/docs/10.x/authorization#creating-policies)You can define a [polices](https://laravel.com/docs/10.x/authorization#creating-policies) by runnig command:

```
php artisan make:policy:aaa
```

Then, add your policies to `AuthServiceProvider`:

```
