Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michalsn/codeigniter-auth0
Basic integration for Auth0 authentication
https://github.com/michalsn/codeigniter-auth0
auth0 authentication codeigniter codeigniter4 php php8 sso-authentication
Last synced: 4 months ago
JSON representation
Basic integration for Auth0 authentication
- Host: GitHub
- URL: https://github.com/michalsn/codeigniter-auth0
- Owner: michalsn
- License: mit
- Created: 2023-07-27T11:30:29.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2024-02-06T00:00:36.000Z (about 1 year ago)
- Last Synced: 2024-10-02T08:09:19.085Z (4 months ago)
- Topics: auth0, authentication, codeigniter, codeigniter4, php, php8, sso-authentication
- Language: PHP
- Homepage:
- Size: 49.8 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CodeIgniter Auth0
Basic integration for [Auth0](https://auth0.com/) authentication.
[![PHPStan](https://github.com/michalsn/codeigniter-auth0/actions/workflows/phpstan.yml/badge.svg)](https://github.com/michalsn/codeigniter-auth0/actions/workflows/phpstan.yml)
[![PHPCPD](https://github.com/michalsn/codeigniter-auth0/actions/workflows/phpcpd.yml/badge.svg)](https://github.com/michalsn/codeigniter-auth0/actions/workflows/phpcpd.yml)
[![Psalm](https://github.com/michalsn/codeigniter-auth0/actions/workflows/psalm.yml/badge.svg)](https://github.com/michalsn/codeigniter-auth0/actions/workflows/psalm.yml)
[![Rector](https://github.com/michalsn/codeigniter-auth0/actions/workflows/rector.yml/badge.svg)](https://github.com/michalsn/codeigniter-auth0/actions/workflows/rector.yml)
[![Deptrac](https://github.com/michalsn/codeigniter-auth0/actions/workflows/deptrac.yml/badge.svg)](https://github.com/michalsn/codeigniter-auth0/actions/workflows/deptrac.yml)![PHP](https://img.shields.io/badge/PHP-%5E8.0-blue)
![CodeIgniter](https://img.shields.io/badge/CodeIgniter-%5E4.3-blue)### Installation
#### Composer
composer require michalsn/codeigniter-auth0
composer require guzzlehttp/guzzle guzzlehttp/psr7 http-interop/http-factory-guzzle
#### Manually
In the example below we will assume, that files from this project will be located in `app/ThirdParty/auth0` directory.
Download this project and then enable it by editing the `app/Config/Autoload.php` file and adding the `Michalsn\CodeIgniterAuth0` namespace to the `$psr4` array, like in the below example:
```php
APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
'Michalsn\CodeIgniterAuth0' => APPPATH . 'ThirdParty/auth0/src',
];// ...
```
Also add the required helper to the same file under `$files` array:```php
// ...
public $files = [
APPPATH . 'ThirdParty/auth0/src/Common.php',
];// ...
```You will still need to install some dependencies:
composer require guzzlehttp/guzzle guzzlehttp/psr7 http-interop/http-factory-guzzle
### Database
php spark migrate --all
### Config
See what configuration variables can be set by looking at the `src/Config/Auth0.php` file and use the `.env` file to set them.
See the [getting started](https://auth0.com/docs/libraries/auth0-php) article for reference.
### Routes
- `login`
- `logout`
- `callback`### Filters
- `auth0Stateful`
### Commands
To copy config file to the application namespace.
php spark auth0:publish
### Helper functions
- `authenticated()` will check if current user is authenticated
- `user_id()` will return current user ID (database)
- `user()` will return current user info (database)
- `auth0_user()` will return the Auth0 user array or `null`### Example
```php
isAuthenticated()) {
return $this->response->setHeader(401)->setBody('401 Unauthorized');
}return view('home/index', $data);
}
}
```