Skip to content

Commit

Permalink
feat: azure/entra oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberdev-tech committed Feb 7, 2025
1 parent 9ec2f6e commit 0f15c89
Show file tree
Hide file tree
Showing 4 changed files with 690 additions and 547 deletions.
85 changes: 85 additions & 0 deletions app/Extensions/OAuth/Providers/AzureProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace App\Extensions\OAuth\Providers;

use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\TextInput;
use SocialiteProviders\Azure\Provider;



final class AzureProvider extends OAuthProvider
{
public function getId(): string
{
return 'azure';
}

public function getProviderClass(): string
{
return Provider::class;
}

public function getServiceConfig(): array
{
return [
'redirect' => env('OAUTH_AZURE_REDIRECT_URI'),
'client_id' => env('OAUTH_AZURE_CLIENT_ID'),
'client_secret' => env('OAUTH_AZURE_CLIENT_SECRET'),
'tenant' => env('OAUTH_AZURE_TENANT_ID'),
];
}
public function getSettingsForm(): array
{
return array_merge(parent::getSettingsForm(), [
TextInput::make('OAUTH_AZURE_REDIRECT_URI')
->label('Redirect URL')
->placeholder('Redirect URL')
->columnSpan(2)
->required()
->url()
->autocomplete(false)
->default(env('OAUTH_AZURE_REDIRECT_URI')),
TextInput::make('OAUTH_AZURE_DISPLAY_NAME')
->label('Display Name')
->placeholder('Display Name')
->autocomplete(false)
->default(env('OAUTH_AZURE_DISPLAY_NAME', 'Azure')),
ColorPicker::make('OAUTH_AZURE_DISPLAY_COLOR')
->label('Display Color')
->placeholder('#fd4b2d')
->default(env('OAUTH_AZURE_DISPLAY_COLOR', '#03c6fc'))
->required()
->hex(),
TextInput::make("OAUTH_AZURE_TENANT_ID")
->label('Tentant ID')
->placeholder('Tentant ID')
->columnSpan(2)
->required()
->password()
->revealable()
->autocomplete(false)
->default(env("OAUTH_AZURE_TENANT_ID")),
]);
}

public function getName(): string
{
return env('OAUTH_AZURE_DISPLAY_NAME') ?? 'Azure';
}

public function getIcon(): string
{
return 'tabler-brand-azure';
}

public function getHexColor(): string
{
return env('OAUTH_AZURE_DISPLAY_COLOR') ?? '#03c6fc';
}

public static function register(): self
{
return new self();
}
}
2 changes: 2 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Extensions\OAuth\Providers\DiscordProvider;
use App\Extensions\OAuth\Providers\GithubProvider;
use App\Extensions\OAuth\Providers\SteamProvider;
use App\Extensions\OAuth\Providers\AzureProvider;
use App\Models;
use App\Models\ApiKey;
use App\Models\Node;
Expand Down Expand Up @@ -96,6 +97,7 @@ public function boot(Application $app, SoftwareVersionService $versionService):
CommonProvider::register('slack', null, 'tabler-brand-slack', '#6ecadc');

// Additional OAuth providers from socialiteproviders.com
AzureProvider::register();
AuthentikProvider::register();
DiscordProvider::register();
SteamProvider::register();
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"secondnetwork/blade-tabler-icons": "^3.26",
"socialiteproviders/authentik": "^5.2",
"socialiteproviders/discord": "^4.2",
"socialiteproviders/microsoft-azure": "^5.2",
"socialiteproviders/steam": "^4.2",
"spatie/laravel-fractal": "^6.2",
"spatie/laravel-health": "^1.30",
Expand Down
Loading

0 comments on commit 0f15c89

Please sign in to comment.