2017 © Pedro Peláez
 

library doctrine-oauth2

Doctrine and Laravel OAuth2 Integration

image

krak/doctrine-oauth2

Doctrine and Laravel OAuth2 Integration

  • Saturday, March 17, 2018
  • by ragboyjr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 45 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Doctrine OAuth2

This library provides OAuth2 integration for Doctrine and Laravel. It uses the league/oauth2-server package for all of the heavy lifting and the Doctrine ORM for the backend., (*1)

Installation

Install with composer at krak/doctrine-oauth2, (*2)

Laravel Usage

<?php

$app = new Laravel\Lumen\Application(__DIR__ . '/..');

$app->register(LaravelDoctrine\ORM\DoctrineServiceProvider::class);
$app->register(LaravelDoctrine\Migrations\MigrationsServiceProvider::class);
$app->register(Krak\DoctrineOAuth2\OAuth2ServiceProvider::class);

$app['oauth2.seeds']->push(function($em, $logger) {
    $scopes = [
        new Scope('basic', 'Basic', 'Allows basic access to the API.'),
        new Scope('user', 'User', 'Allows user access to the API.'),
    ];

    $logger->info("Creating local client");
    $client = new Client('local', 'local', 'local123', '', $scopes);
    $em->persist($client);
    foreach ($scopes as $scope) {
        $logger->info("Creating scope: ". json_encode($scope, JSON_PRETTY_PRINT));
        $em->persist($scope);
    }
});

$app->router->group(['middleware' => 'oauth2'], function($router) {
    $router->get('/', function(Illuminate\Http\Request $req) {
        return $req->attributes->all();
    });
});
<?php

// config/oauth2.php

return [
    'grants' => [
        'refresh_token',
        'password',
        'client_credentials',
        'authorization_code',
        'implicit'
    ],
    'client_credentials' => [
        'access_token_ttl' => new DateInterval('P1Y'),
    ],
    'access_token_ttl' => new DateInterval('PT2H'),
    'refresh_token_ttl' => new DateInterval('P2Y'),
    'private_key' => resource_path('oauth-private.key'),
    'public_key' => resource_path('oauth-public.key'),
];

You need to run ./artisan oauth2:generate-keys to create the oauth keys. You can optionally run ./artisan oauth2:seed to run any seeds you may have defined for the oauth2 package., (*3)

The Versions

17/03 2018

dev-master

9999999-dev

Doctrine and Laravel OAuth2 Integration

  Sources   Download

MIT

The Requires

 

laravel doctrine oauth2

17/03 2018

v0.1.2

0.1.2.0

Doctrine and Laravel OAuth2 Integration

  Sources   Download

MIT

The Requires

 

laravel doctrine oauth2

22/02 2018

v0.1.1

0.1.1.0

Doctrine and Laravel OAuth2 Integration

  Sources   Download

MIT

The Requires

 

laravel doctrine oauth2

13/02 2018

v0.1.0

0.1.0.0

Doctrine and Laravel OAuth2 Integration

  Sources   Download

MIT

laravel doctrine oauth2