From 47e2cf4cd904ec1f4d492bdd21a50262674bd872 Mon Sep 17 00:00:00 2001 From: Igor Tsapiro Date: Fri, 22 Nov 2019 13:59:06 +0200 Subject: [PATCH] update readme file, fix some little things --- .env.example | 10 ++++++++++ README.md | 22 +++++++++++++++++++++- src/GateServiceProvider.php | 7 ++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ea6bcc9 --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +GATE_ENABLED=true +GATE_URL="https://gate.example.com/" +GATE_CLIENT_ID=3 +GATE_CLIENT_SECRET=client_secret +GATE_KEY= +GATE_REDIRECT_URL="http://localhost/auth/callback" +GATE_AUTHORIZE_URL="http://localhost:8000/oauth/authorize" +GATE_TOKEN_URL="http://localhost:8000/oauth/token" +GATE_USER_URL="http://localhost:8000/api/user" + diff --git a/README.md b/README.md index eebb0de..ad4cc76 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,28 @@ composer require looxis/gate ## Usage + +To register your provider, add it to the array into `config/app.php` file: +```php +'providers' => [ + // Other Service Providers + + \Looxis\Gate\GateServiceProvider::class +], +``` + + +Add some properties to your `.env` file (see .env.example) +```php +GATE_ENABLED=true +GATE_URL="https://gate.example.com/" +GATE_CLIENT_ID=3 +GATE_CLIENT_SECRET=client_secret +``` + +Also you can publish the config file with this artisan command: ``` php -// Usage description here +php artisan vendor:publish --tag=gate-config ``` ### Testing diff --git a/src/GateServiceProvider.php b/src/GateServiceProvider.php index fdb6a3b..fc1dddd 100644 --- a/src/GateServiceProvider.php +++ b/src/GateServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Support\ServiceProvider; use Laravel\Socialite\Contracts\Factory; +use Laravel\Socialite\Facades\Socialite; class GateServiceProvider extends ServiceProvider @@ -56,11 +57,15 @@ public function register() $this->mergeConfigFrom(__DIR__.'/../config/gate.php', 'gate'); // Register the main class to use with the facade + $this->app->bind('gate', function () { + return Socialite::driver('gate'); + }); + $this->app->resolving(Factory::class, function ($socialite) { $socialite->extend( 'gate', function ($app) use ($socialite) { - $config = config_path('gate.php'); + $config = config('gate'); return $socialite->buildProvider(GateProvider::class, $config); } );