jirkavrba / cvut-socialite-provider
A socialite provider for the authentication server of the FIT CTU in Prague
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 3
Type:project
Requires
- ext-json: *
- laravel/socialite: ^4.3
This package is auto-updated.
Last update: 2024-04-29 21:43:26 UTC
README
This is a custom Laravel Socialite provider for the authentication server of the FIT CTU in Prague.
The authentication server can be found here.
Installation
To install this package simply add jirkavrba/cvut-socialite-provider
to your composer.json
file.
This can be also done via the composer command
composer require jirkavrba/cvut-socialite-provider
Then, add your credentials to the .env
CVUT_CLIENT_ID="" CVUT_CLIENT_SECRET="" CVUT_CALLBACK_URL=""
and config/services.php
return [ // Other services 'cvut' => [ 'client_id' => env('CVUT_CLIENT_ID'), 'client_secret' => env('CVUT_CLIENT_SECRET'), 'redirect' => env('CVUT_CALLBACK_URL'), ], ];
You also need to extend the socialite service within a service provider, this
can be done eg. in the AppServiceProvider
by creating a private method
private function bootCvutSocialiteProvider() { $socialite = $this->app->make('Laravel\Socialite\Contracts\Factory'); $socialite->extend( 'cvut', function ($app) use ($socialite) { $config = $app['config']['services.cvut']; return $socialite->buildProvider(CvutProvider::class, $config); } ); }
and then call this method from within the boot()
method.
This should be all you need to do, then you can simply use the provider within your controllers like:
public function redirectToProvider(): RedirectResponse { return Socialite::with('cvut')->redirect(); }