Skip to content

Commit

Permalink
Merge pull request coollabsio#1883 from procchio6/fix/oauth
Browse files Browse the repository at this point in the history
Fix azure oauth not recognizing tenant ID
  • Loading branch information
andrasbacsai authored Mar 25, 2024
2 parents 90fad52 + cae9ae5 commit 8d856b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bootstrap/helpers/socialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@
function get_socialite_provider(string $provider)
{
$oauth_setting = OauthSetting::firstWhere('provider', $provider);

if ($provider == 'azure') {
$azure_config = new \SocialiteProviders\Manager\Config(
$oauth_setting->client_id,
$oauth_setting->client_secret,
$oauth_setting->redirect_uri,
['tenant' => $oauth_setting->tenant],
);
return Socialite::driver('azure')->setConfig($azure_config);
}

$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
Expand Down
8 changes: 8 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],

'azure' => [
'client_id' => env('AZURE_CLIENT_ID'),
'client_secret' => env('AZURE_CLIENT_SECRET'),
'redirect' => env('AZURE_REDIRECT_URI'),
'tenant' => env('AZURE_TENANT_ID'),
'proxy' => env('AZURE_PROXY'),
],
];

0 comments on commit 8d856b0

Please sign in to comment.