Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/glocurrency/api-layer

Basic API layer.
https://github.com/glocurrency/api-layer

passport

Last synced: about 2 months ago
JSON representation

Basic API layer.

Awesome Lists containing this project

README

        

# Api Layer


Total Downloads
Latest Stable Version
License

## Installation

```
composer require glocurrency/api-layer
```

### Passport
This module use Laravel Passport heavily. In order to make it work properly, follow the steps:
1. Run
```
php artisan glo:apilayer:passport
```

This command will:
- generate the keys
- copy the migrations from passport
- replace both `client_id` and `user_id` columns in migrations with UUID.

2. Copy the passport middlewares to the `$routeMiddleware` in your `app/Http/Kernel.php` file:

```php
'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
```

3. Add the following code to the `boot` method of `AuthServiceProvider`:

```php
use Glocurrency\ApiLayer\ApiLayer;

public function boot()
{
$this->registerPolicies();

ApiLayer::passport();
}
```

4. Generate both Client and Personal grant tokens.

```
php artisan passport:client --client
php artisan passport:client --personal
```

After creating your personal access client, place the client's ID and plain-text secret value in your application's `.env` file:

```ini
PASSPORT_PERSONAL_ACCESS_CLIENT_ID=client-id-value
PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET=unhashed-client-secret-value
```

5. Use `UnauthenticatedTrait` in your `app/Exceptions/Handler.php` file:

```php
use Glocurrency\ApiLayer\Traits\UnauthenticatedTrait;

class Handler extends ExceptionHandler
{
use UnauthenticatedTrait;
```

## License

Glocurrency Api Layer is open-sourced software licensed under the [MIT license](LICENSE).

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fglocurrency%2Fapi-layer.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fglocurrency%2Fapi-layer?ref=badge_large)