2017 © Pedro Peláez
 

library fauth-php

Authentication User Framgia

image

framgia/fauth-php

Authentication User Framgia

  • Thursday, September 21, 2017
  • by tungpro
  • Repository
  • 27 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

FAuth (Framgia Authentication)

Installation

To get started with FramgiaAuth, use Composer to add the package to your project's dependencies:, (*1)

composer require framgia/fauth-php, (*2)

Run the following command:, (*3)

composer update, (*4)

Configuration

After installing the Fauth library, register the Framgia\Fauth\FAuthServiceProvider in your config/app.php configuration file: Framgia\Fauth\FAuthServiceProvider::class,, (*5)

Also, add the Fauth facade to the aliases array in your app configuration file: 'Fauth' => Framgia\Fauth\Facades\Fauth::class,, (*6)

You will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/services.php configuration file, and should use the key framgia for the framgia provider. For example:, (*7)

'framgia' => [
    'client_id' => 'your-auth-framgia-app-id',
    'client_secret' => 'your-auth-framgia-app-secret',
    'base_url' => 'http://domain-auth-server',
    'redirect' => 'http://your-callback-url',
],

Add the following to your composer.json (autoload-dev -> psr-4) "Framgia\\Fauth\\": "vendor/framgia/fauth/", (*8)

Run below command: composer dump-autoload, (*9)

Basic Usage

Next, you are ready to authenticate users! You will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the callback from the provider after authentication. We will access Fauth using the Fauth facade:, (*10)

<?php

namespace App\Http\Controllers\Auth;

use Fauth;

class LoginController extends Controller
{
    /**
     * Redirect the user to the Auth-Framgia authentication page.
     *
     * @return Response
     */
    public function redirectToProvider()
    {
        return Fauth::driver('framgia')->redirect();
    }

    /**
     * Obtain the user information from Auth-Framgia.
     *
     * @return Response
     */
    public function handleProviderCallback()
    {
        $user = Fauth::driver('framgia')->user();
    }
}

Of course, you will need to define routes to your controller methods:, (*11)

Route::get('login/framgia', 'Auth\LoginController@redirectToProvider');
Route::get('login/framgia/callback', 'Auth\LoginController@handleProviderCallback');

Once you have a user instance, you can grab a few more details about the user:, (*12)

$user = Fauth::driver('framgia')->user();
$token = $user->token;
$refreshToken = $user->refreshToken; // not always provided
$expiresIn = $user->expiresIn;

If you already have a valid access token for a user, you can retrieve their details using the userFromToken method:, (*13)

$user = Fauth::driver('framgia')->userFromToken($token);, (*14)

Pull requests are welcome.

The Versions

21/09 2017

dev-develop

dev-develop

Authentication User Framgia

  Sources   Download

Framgia

The Development Requires

by Tran Dinh Vi

laravel authentication oauth

07/08 2017

dev-master

9999999-dev

Authentication User Framgia

  Sources   Download

Framgia

The Development Requires

by Tran Dinh Vi

laravel authentication oauth

07/08 2017

1.0.0

1.0.0.0

Authentication User Framgia

  Sources   Download

Framgia

The Development Requires

by Tran Dinh Vi

laravel authentication oauth