mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 11:06:51 +01:00 
			
		
		
		
	* rework oauth provider creation & lodaing * add separate setup form * use wizard for setup * add provider class for discord * cleanup and fixes * don't throw exception when creating duplicate provider * update profile and login pages * did not mean to remove the whole else, oops * use import
		
			
				
	
	
		
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Extensions\OAuth\Providers;
 | 
						|
 | 
						|
use Filament\Forms\Components\Placeholder;
 | 
						|
use Filament\Forms\Components\TextInput;
 | 
						|
use Filament\Forms\Components\Wizard\Step;
 | 
						|
use Illuminate\Support\HtmlString;
 | 
						|
use SocialiteProviders\Steam\Provider;
 | 
						|
 | 
						|
final class SteamProvider extends OAuthProvider
 | 
						|
{
 | 
						|
    public function getId(): string
 | 
						|
    {
 | 
						|
        return 'steam';
 | 
						|
    }
 | 
						|
 | 
						|
    public function getProviderClass(): string
 | 
						|
    {
 | 
						|
        return Provider::class;
 | 
						|
    }
 | 
						|
 | 
						|
    public function getServiceConfig(): array
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            'client_id' => null,
 | 
						|
            'client_secret' => env('OAUTH_STEAM_CLIENT_SECRET'),
 | 
						|
            'allowed_hosts' => [
 | 
						|
                str_replace(['http://', 'https://'], '', env('APP_URL')),
 | 
						|
            ],
 | 
						|
        ];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getSettingsForm(): array
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            TextInput::make('OAUTH_STEAM_CLIENT_SECRET')
 | 
						|
                ->label('Web API Key')
 | 
						|
                ->placeholder('Web API Key')
 | 
						|
                ->columnSpan(4)
 | 
						|
                ->required()
 | 
						|
                ->password()
 | 
						|
                ->revealable()
 | 
						|
                ->autocomplete(false)
 | 
						|
                ->default(env('OAUTH_STEAM_CLIENT_SECRET')),
 | 
						|
        ];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getSetupSteps(): array
 | 
						|
    {
 | 
						|
        return array_merge([
 | 
						|
            Step::make('Create API Key')
 | 
						|
                ->schema([
 | 
						|
                    Placeholder::make('')
 | 
						|
                        ->content(new HtmlString('Visit <u><a href="https://steamcommunity.com/dev/apikey" target="_blank">https://steamcommunity.com/dev/apikey</a></u> to generate an API key.')),
 | 
						|
                ]),
 | 
						|
        ], parent::getSetupSteps());
 | 
						|
    }
 | 
						|
 | 
						|
    public function getIcon(): string
 | 
						|
    {
 | 
						|
        return 'tabler-brand-steam-f';
 | 
						|
    }
 | 
						|
 | 
						|
    public function getHexColor(): string
 | 
						|
    {
 | 
						|
        return '#00adee';
 | 
						|
    }
 | 
						|
 | 
						|
    public static function register(): self
 | 
						|
    {
 | 
						|
        return new self();
 | 
						|
    }
 | 
						|
}
 |