Add oauth support
- Support azure, bitbucket, github, gitlab, google providers - Add authentication page to settings Co-authored-by: Suraj Kumar <srjkmr1024@gmail.com> Co-authored-by: Michael Castanieto <mcastanieto@gmail.com> Co-authored-by: Mike Kim <m.kim4247@gmail.com>
This commit is contained in:
26
bootstrap/helpers/socialite.php
Normal file
26
bootstrap/helpers/socialite.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\Models\OauthSetting;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
|
||||
function get_socialite_provider(string $provider)
|
||||
{
|
||||
$oauth_setting = OauthSetting::firstWhere('provider', $provider);
|
||||
$config = [
|
||||
'client_id' => $oauth_setting->client_id,
|
||||
'client_secret' => $oauth_setting->client_secret,
|
||||
'redirect' => $oauth_setting->redirect_uri,
|
||||
'tenant' => $oauth_setting->tenant,
|
||||
];
|
||||
$provider_class_map = [
|
||||
'azure' => \SocialiteProviders\Azure\Provider::class,
|
||||
'bitbucket' => \Laravel\Socialite\Two\BitbucketProvider::class,
|
||||
'github' => \Laravel\Socialite\Two\GithubProvider::class,
|
||||
'gitlab' => \Laravel\Socialite\Two\GitlabProvider::class,
|
||||
'google' => \Laravel\Socialite\Two\GoogleProvider::class,
|
||||
];
|
||||
return Socialite::buildProvider(
|
||||
$provider_class_map[$provider],
|
||||
$config
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user