Skip to main content

Authava Laravel Client

The Authava Laravel client provides seamless integration with Laravel applications, making it easy to add authentication to your PHP applications.

GitHub Repository

The Laravel client is available on GitHub at:

https://github.com/authava/laravel

Installation

Install the Authava Laravel client using Composer:

composer require authava/laravel

Publish the configuration file:

php artisan vendor:publish --provider="Authava\Laravel\AuthavaServiceProvider"

Configuration

Configure the Authava Laravel client in your .env file:

AUTHAVA_DOMAIN=auth.yourdomain.com
AUTHAVA_CLIENT_ID=your-client-id
AUTHAVA_CLIENT_SECRET=your-client-secret
AUTHAVA_REDIRECT_URI=https://your-app.com/callback

Update your config/auth.php file to use Authava as the authentication guard:

'guards' => [
'web' => [
'driver' => 'authava',
'provider' => 'users',
],
],

Basic Usage

Use the Authava authentication in your routes:

// routes/web.php
Route::get('/', function () {
return view('welcome');
});

Route::get('/dashboard', function () {
return view('dashboard');
})->middleware('auth');

Route::get('/login', function () {
return app('authava')->login();
})->name('login');

Route::get('/logout', function () {
return app('authava')->logout();
})->name('logout');

Route::get('/callback', function () {
return app('authava')->handleCallback();
})->name('callback');

Access the authenticated user in your views:

@if (auth()->check())
<p>Welcome, {{ auth()->user()->name }}</p>
<a href="{{ route('logout') }}">Logout</a>
@else
<a href="{{ route('login') }}">Login</a>
@endif

Features

  • Laravel Auth Integration: Seamless integration with Laravel's authentication system
  • Middleware: Ready-to-use middleware for protecting routes
  • Blade Directives: Convenient Blade directives for authentication checks
  • Artisan Commands: Helpful Artisan commands for setup and management
  • User Provider: Custom user provider for Laravel Auth

Advanced Configuration

For more advanced configuration options and detailed documentation, please refer to the GitHub repository.