├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── bin └── build.js ├── composer.json ├── config └── check-ssl-widget.php ├── database ├── factories │ └── ModelFactory.php └── migrations │ └── create_check_ssl_widget_table.php.stub ├── postcss.config.cjs ├── resources ├── css │ └── index.css ├── dist │ └── .gitkeep ├── js │ └── index.js ├── lang │ ├── en │ │ └── default.php │ └── pt_BR │ │ └── default.php └── views │ ├── .gitkeep │ └── filament │ └── widgets │ └── check-ssl-widget.blade.php ├── src ├── Commands │ └── FilamentCheckSslWidgetCommand.php ├── Facades │ └── FilamentCheckSslWidget.php ├── FilamentCheckSslWidget.php ├── FilamentCheckSslWidgetPlugin.php ├── FilamentCheckSslWidgetServiceProvider.php ├── Testing │ └── TestsFilamentCheckSslWidget.php └── Widgets │ └── CheckSslWidget.php └── stubs └── .gitkeep /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `filament-check-ssl-widget` will be documented in this file. 4 | 5 | ## v1.0.3 - 2025-02-17 6 | 7 | ### What's Changed 8 | 9 | * Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/9 10 | * Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/10 11 | * Bump aglipanci/laravel-pint-action from 2.4 to 2.5 by @dependabot in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/11 12 | * Add pt_BR translations by @a21ns1g4ts in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/12 13 | 14 | ### New Contributors 15 | 16 | * @a21ns1g4ts made their first contribution in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/12 17 | 18 | **Full Changelog**: https://github.com/joaopaulolndev/filament-check-ssl-widget/compare/v1.0.2...v1.0.3 19 | 20 | ## v1.0.2 - 2024-06-27 21 | 22 | ### What's Changed 23 | 24 | * Update README.md by @jeffersonsimaogoncalves in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/7 25 | * Adicionando o cache de uma semana para não ficar todo momento buscando informações do certificado SSL. by @jeffersonsimaogoncalves in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/8 26 | 27 | **Full Changelog**: https://github.com/joaopaulolndev/filament-check-ssl-widget/compare/v1.0.1...v1.0.2 28 | 29 | ## v1.0.1 - 2024-06-27 30 | 31 | ### What's Changed 32 | 33 | * Adicionando verificação se dominio tem ssl e verificando se o dominio possui favicon by @jeffersonsimaogoncalves in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/3 34 | * Update README.md by @jeffersonsimaogoncalves in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/4 35 | * Adicionando verificação se domínio é válido. by @jeffersonsimaogoncalves in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/5 36 | * Update CheckSslWidget.php by @jeffersonsimaogoncalves in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/6 37 | 38 | ### New Contributors 39 | 40 | * @jeffersonsimaogoncalves made their first contribution in https://github.com/joaopaulolndev/filament-check-ssl-widget/pull/3 41 | 42 | **Full Changelog**: https://github.com/joaopaulolndev/filament-check-ssl-widget/compare/v1.0.0...v1.0.1 43 | 44 | ## v1.0.0 - 2024-06-27 45 | 46 | **Full Changelog**: https://github.com/joaopaulolndev/filament-check-ssl-widget/commits/v1.0.0 47 | 48 | ## 1.0.0 - 202X-XX-XX 49 | 50 | - initial release 51 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) joaopaulolndev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A filamentPHP widget to get details about ssl certificate 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/joaopaulolndev/filament-check-ssl-widget.svg?style=flat-square)](https://packagist.org/packages/joaopaulolndev/filament-check-ssl-widget) 4 | [![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/joaopaulolndev/filament-check-ssl-widget/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/joaopaulolndev/filament-check-ssl-widget/actions?query=workflow%3Arun-tests+branch%3Amain) 5 | [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/joaopaulolndev/filament-check-ssl-widget/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/joaopaulolndev/filament-check-ssl-widget/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/joaopaulolndev/filament-check-ssl-widget.svg?style=flat-square)](https://packagist.org/packages/joaopaulolndev/filament-check-ssl-widget) 7 | 8 | The Filament Check Ssl plugin widget designed to show the detail informations about the ssl certificate given domains. 9 | 10 |
11 | 12 | ![Screenshot of Application Feature](https://raw.githubusercontent.com/joaopaulolndev/filament-check-ssl-widget/main/art/joaopaulolndev-filament-check-ssl-widget.jpg) 13 | 14 |
15 | 16 | ## Installation 17 | 18 | You can install the package via composer: 19 | 20 | ```bash 21 | composer require joaopaulolndev/filament-check-ssl-widget 22 | ``` 23 | 24 | Optionally, you can publish the views using 25 | 26 | ```bash 27 | php artisan vendor:publish --tag="filament-check-ssl-widget-views" 28 | ``` 29 | 30 | Optionally, you can publish the translations using 31 | 32 | ```bash 33 | php artisan vendor:publish --tag="filament-check-ssl-widget-translations" 34 | ``` 35 | 36 | ## Usage 37 | Add in AdminPanelProvider.php 38 | 39 | ```php 40 | use Joaopaulolndev\FilamentCheckSslWidget\FilamentCheckSslWidgetPlugin; 41 | 42 | ->plugins([ 43 | FilamentCheckSslWidgetPlugin::make() 44 | ->domains([ 45 | 'laravel.com', 46 | 'filamentphp.com', 47 | 'github.com' 48 | ]) 49 | ]) 50 | ``` 51 | 52 | Optionally, you can add more configs as example below: 53 | 54 | ```php 55 | use Joaopaulolndev\FilamentCheckSslWidget\FilamentCheckSslWidgetPlugin; 56 | 57 | FilamentCheckSslWidgetPlugin::make() 58 | ->domains([ 59 | 'laravel.com', 60 | 'filamentphp.com', 61 | 'github.com' 62 | ]) 63 | ->shouldShowTitle(false) // Optional show title default is: true 64 | ->setTitle('Certificates') // Optional 65 | ->setDescription('SSL certificate detail') // Optional 66 | ->setQuantityPerRow(1) //Optional quantity per row default is: 1 67 | ->setColumnSpan('full') //Optional column span default is: '1/2' 68 | ->setSort(10) 69 | ``` 70 | 71 | ## Testing 72 | 73 | ```bash 74 | composer test 75 | ``` 76 | 77 | ## Changelog 78 | 79 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 80 | 81 | ## Contributing 82 | 83 | Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. 84 | 85 | ## Security Vulnerabilities 86 | 87 | Please review [our security policy](../../security/policy) on how to report security vulnerabilities. 88 | 89 | ## Credits 90 | 91 | - [João Paulo Leite Nascimento](https://github.com/joaopaulolndev) 92 | - [All Contributors](../../contributors) 93 | 94 | ## License 95 | 96 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 97 | -------------------------------------------------------------------------------- /bin/build.js: -------------------------------------------------------------------------------- 1 | import esbuild from 'esbuild' 2 | 3 | const isDev = process.argv.includes('--dev') 4 | 5 | async function compile(options) { 6 | const context = await esbuild.context(options) 7 | 8 | if (isDev) { 9 | await context.watch() 10 | } else { 11 | await context.rebuild() 12 | await context.dispose() 13 | } 14 | } 15 | 16 | const defaultOptions = { 17 | define: { 18 | 'process.env.NODE_ENV': isDev ? `'development'` : `'production'`, 19 | }, 20 | bundle: true, 21 | mainFields: ['module', 'main'], 22 | platform: 'neutral', 23 | sourcemap: isDev ? 'inline' : false, 24 | sourcesContent: isDev, 25 | treeShaking: true, 26 | target: ['es2020'], 27 | minify: !isDev, 28 | plugins: [{ 29 | name: 'watchPlugin', 30 | setup: function (build) { 31 | build.onStart(() => { 32 | console.log(`Build started at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`) 33 | }) 34 | 35 | build.onEnd((result) => { 36 | if (result.errors.length > 0) { 37 | console.log(`Build failed at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`, result.errors) 38 | } else { 39 | console.log(`Build finished at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`) 40 | } 41 | }) 42 | } 43 | }], 44 | } 45 | 46 | compile({ 47 | ...defaultOptions, 48 | entryPoints: ['./resources/js/index.js'], 49 | outfile: './resources/dist/filament-check-ssl-widget.js', 50 | }) 51 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "joaopaulolndev/filament-check-ssl-widget", 3 | "description": "A filamentPHP widget to get details about ssl certificate", 4 | "keywords": [ 5 | "joaopaulolndev", 6 | "laravel", 7 | "filament-check-ssl-widget" 8 | ], 9 | "homepage": "https://github.com/joaopaulolndev/filament-check-ssl-widget", 10 | "support": { 11 | "issues": "https://github.com/joaopaulolndev/filament-check-ssl-widget/issues", 12 | "source": "https://github.com/joaopaulolndev/filament-check-ssl-widget" 13 | }, 14 | "license": "MIT", 15 | "authors": [ 16 | { 17 | "name": "João Paulo Leite Nascimento", 18 | "email": "joaopauloln7@gmail.com", 19 | "role": "Developer" 20 | } 21 | ], 22 | "require": { 23 | "php": "^8.1", 24 | "ashallendesign/favicon-fetcher": "^3.5", 25 | "filament/filament": "^3.0", 26 | "spatie/laravel-package-tools": "^1.15.0", 27 | "spatie/ssl-certificate": "^2.6" 28 | }, 29 | "require-dev": { 30 | "laravel/pint": "^1.0", 31 | "nunomaduro/collision": "^7.9", 32 | "orchestra/testbench": "^8.0", 33 | "pestphp/pest": "^2.1", 34 | "pestphp/pest-plugin-arch": "^2.0", 35 | "pestphp/pest-plugin-laravel": "^2.0" 36 | }, 37 | "autoload": { 38 | "psr-4": { 39 | "Joaopaulolndev\\FilamentCheckSslWidget\\": "src/", 40 | "Joaopaulolndev\\FilamentCheckSslWidget\\Database\\Factories\\": "database/factories/" 41 | } 42 | }, 43 | "autoload-dev": { 44 | "psr-4": { 45 | "Joaopaulolndev\\FilamentCheckSslWidget\\Tests\\": "tests/" 46 | } 47 | }, 48 | "scripts": { 49 | "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", 50 | "test": "vendor/bin/pest", 51 | "test-coverage": "vendor/bin/pest --coverage", 52 | "format": "vendor/bin/pint" 53 | }, 54 | "config": { 55 | "sort-packages": true, 56 | "allow-plugins": { 57 | "pestphp/pest-plugin": true, 58 | "phpstan/extension-installer": true 59 | } 60 | }, 61 | "extra": { 62 | "laravel": { 63 | "providers": [ 64 | "Joaopaulolndev\\FilamentCheckSslWidget\\FilamentCheckSslWidgetServiceProvider" 65 | ], 66 | "aliases": { 67 | "FilamentCheckSslWidget": "Joaopaulolndev\\FilamentCheckSslWidget\\Facades\\FilamentCheckSslWidget" 68 | } 69 | } 70 | }, 71 | "minimum-stability": "dev", 72 | "prefer-stable": true 73 | } 74 | -------------------------------------------------------------------------------- /config/check-ssl-widget.php: -------------------------------------------------------------------------------- 1 | id(); 13 | 14 | // add fields 15 | 16 | $table->timestamps(); 17 | }); 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /postcss.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | "postcss-import": {}, 4 | "tailwindcss/nesting": {}, 5 | tailwindcss: {}, 6 | autoprefixer: {}, 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /resources/css/index.css: -------------------------------------------------------------------------------- 1 | @import '../../vendor/filament/filament/resources/css/theme.css'; 2 | -------------------------------------------------------------------------------- /resources/dist/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaopaulolndev/filament-check-ssl-widget/111c6d1c390ac65eeab4d795acee1e7b5aa6353b/resources/dist/.gitkeep -------------------------------------------------------------------------------- /resources/js/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaopaulolndev/filament-check-ssl-widget/111c6d1c390ac65eeab4d795acee1e7b5aa6353b/resources/js/index.js -------------------------------------------------------------------------------- /resources/lang/en/default.php: -------------------------------------------------------------------------------- 1 | 'SSL Certificates', 5 | 'description' => 'List of certificates to check details', 6 | ]; 7 | -------------------------------------------------------------------------------- /resources/lang/pt_BR/default.php: -------------------------------------------------------------------------------- 1 | 'Certificados SSL', 5 | 'description' => 'Lista de certificados', 6 | ]; 7 | -------------------------------------------------------------------------------- /resources/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaopaulolndev/filament-check-ssl-widget/111c6d1c390ac65eeab4d795acee1e7b5aa6353b/resources/views/.gitkeep -------------------------------------------------------------------------------- /resources/views/filament/widgets/check-ssl-widget.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | @if($shouldShowTitle) 4 |
5 |

6 | 7 | 8 | 9 | 10 | {{ is_null($title) ? __('filament-check-ssl-widget::default.title') : $title }} 11 |

12 |

13 | {{ is_null($description) ? __('filament-check-ssl-widget::default.description') : $description }} 14 |

15 |
16 | @endif 17 | 18 |
19 | @foreach ($certificates as $certificate) 20 |
21 | 22 | @if ($certificate['favicon']) 23 | 24 | @endif 25 | {{ $certificate['domain'] }} 26 | 27 | 28 | @if ($certificate['is_valid']) 29 |
  • Expiration: {{ $certificate['expiration_date']->diffForHumans() }} ({{ (int)abs($certificate['expiration_date_in_days']->diffInDays()) }} days)
  • 30 | 31 | 32 | 33 | @else 34 | 35 | 36 | 37 | 38 | @endif 39 |
    40 |
    41 | @endforeach 42 |
    43 |
    44 |
    45 | -------------------------------------------------------------------------------- /src/Commands/FilamentCheckSslWidgetCommand.php: -------------------------------------------------------------------------------- 1 | comment('All done'); 16 | 17 | return self::SUCCESS; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Facades/FilamentCheckSslWidget.php: -------------------------------------------------------------------------------- 1 | widgets([ 32 | Widgets\CheckSslWidget::class, 33 | ]); 34 | } 35 | 36 | public function boot(Panel $panel): void 37 | { 38 | // 39 | } 40 | 41 | public static function make(): static 42 | { 43 | return app(static::class); 44 | } 45 | 46 | public static function get(): static 47 | { 48 | /** @var static $plugin */ 49 | $plugin = filament(app(static::class)->getId()); 50 | 51 | return $plugin; 52 | } 53 | 54 | public function domains(array $domains = []): static 55 | { 56 | $this->domains = $domains; 57 | 58 | return $this; 59 | } 60 | 61 | public function getDomains(): ?array 62 | { 63 | return $this->evaluate($this->domains); 64 | } 65 | 66 | public function shouldShowTitle(Closure | bool $value = true): static 67 | { 68 | $this->shouldShowTitle = $value; 69 | 70 | return $this; 71 | } 72 | 73 | public function getShouldShowTitle(): bool 74 | { 75 | return $this->evaluate($this->shouldShowTitle); 76 | } 77 | 78 | public function setTitle(Closure | string $value = ''): static 79 | { 80 | $this->title = $value; 81 | 82 | return $this; 83 | } 84 | 85 | public function getTitle(): ?string 86 | { 87 | return ! empty($this->title) ? $this->evaluate($this->title) : null; 88 | } 89 | 90 | public function setDescription(Closure | string $value = ''): static 91 | { 92 | $this->description = $value; 93 | 94 | return $this; 95 | } 96 | 97 | public function getDescription(): ?string 98 | { 99 | return ! empty($this->description) ? $this->evaluate($this->description) : null; 100 | } 101 | 102 | public function setSort(Closure | int | null $value = null): static 103 | { 104 | $this->sort = $value; 105 | 106 | return $this; 107 | } 108 | 109 | public function getSort(): ?int 110 | { 111 | return $this->evaluate($this->sort); 112 | } 113 | 114 | public function setColumnSpan(int | string | array $value = '1/2'): static 115 | { 116 | $this->columnSpan = $value; 117 | 118 | return $this; 119 | } 120 | 121 | public function getColumnSpan(): int | string | array 122 | { 123 | return $this->evaluate($this->columnSpan); 124 | } 125 | 126 | public function setQuantityPerRow(Closure | int $value = 1): static 127 | { 128 | $this->quantityPerRow = $value; 129 | 130 | return $this; 131 | } 132 | 133 | public function getQuantityPerRow(): ?int 134 | { 135 | return $this->evaluate($this->quantityPerRow); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/FilamentCheckSslWidgetServiceProvider.php: -------------------------------------------------------------------------------- 1 | name(static::$name) 33 | ->hasCommands($this->getCommands()) 34 | ->hasInstallCommand(function (InstallCommand $command) { 35 | $command 36 | ->publishConfigFile() 37 | ->publishMigrations() 38 | ->askToRunMigrations() 39 | ->askToStarRepoOnGitHub('joaopaulolndev/filament-check-ssl-widget'); 40 | }); 41 | 42 | $configFileName = $package->shortName(); 43 | 44 | if (file_exists($package->basePath("/../config/{$configFileName}.php"))) { 45 | $package->hasConfigFile(); 46 | } 47 | 48 | if (file_exists($package->basePath('/../database/migrations'))) { 49 | $package->hasMigrations($this->getMigrations()); 50 | } 51 | 52 | if (file_exists($package->basePath('/../resources/lang'))) { 53 | $package->hasTranslations(); 54 | } 55 | 56 | if (file_exists($package->basePath('/../resources/views'))) { 57 | $package->hasViews(static::$viewNamespace); 58 | } 59 | } 60 | 61 | public function packageRegistered(): void {} 62 | 63 | public function packageBooted(): void 64 | { 65 | // Asset Registration 66 | // FilamentAsset::register( 67 | // $this->getAssets(), 68 | // $this->getAssetPackageName() 69 | // ); 70 | 71 | // FilamentAsset::registerScriptData( 72 | // $this->getScriptData(), 73 | // $this->getAssetPackageName() 74 | // ); 75 | 76 | // Icon Registration 77 | FilamentIcon::register($this->getIcons()); 78 | 79 | // Handle Stubs 80 | if (app()->runningInConsole()) { 81 | foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) { 82 | $this->publishes([ 83 | $file->getRealPath() => base_path("stubs/filament-check-ssl-widget/{$file->getFilename()}"), 84 | ], 'filament-check-ssl-widget-stubs'); 85 | } 86 | } 87 | 88 | // Testing 89 | Testable::mixin(new TestsFilamentCheckSslWidget); 90 | } 91 | 92 | protected function getAssetPackageName(): ?string 93 | { 94 | return 'joaopaulolndev/filament-check-ssl-widget'; 95 | } 96 | 97 | /** 98 | * @return array 99 | */ 100 | protected function getAssets(): array 101 | { 102 | return [ 103 | // AlpineComponent::make('filament-check-ssl-widget', __DIR__ . '/../resources/dist/components/filament-check-ssl-widget.js'), 104 | Css::make('filament-check-ssl-widget-styles', __DIR__ . '/../resources/dist/filament-check-ssl-widget.css'), 105 | Js::make('filament-check-ssl-widget-scripts', __DIR__ . '/../resources/dist/filament-check-ssl-widget.js'), 106 | ]; 107 | } 108 | 109 | /** 110 | * @return array 111 | */ 112 | protected function getCommands(): array 113 | { 114 | return [ 115 | FilamentCheckSslWidgetCommand::class, 116 | ]; 117 | } 118 | 119 | /** 120 | * @return array 121 | */ 122 | protected function getIcons(): array 123 | { 124 | return []; 125 | } 126 | 127 | /** 128 | * @return array 129 | */ 130 | protected function getRoutes(): array 131 | { 132 | return []; 133 | } 134 | 135 | /** 136 | * @return array 137 | */ 138 | protected function getScriptData(): array 139 | { 140 | return []; 141 | } 142 | 143 | /** 144 | * @return array 145 | */ 146 | protected function getMigrations(): array 147 | { 148 | return [ 149 | 'create_filament-check-ssl-widget_table', 150 | ]; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/Testing/TestsFilamentCheckSslWidget.php: -------------------------------------------------------------------------------- 1 | getPlugin('filament-check-ssl-widget'); 29 | 30 | if ($plugin->getDomains()) { 31 | $domains = $plugin->getDomains(); 32 | } 33 | 34 | foreach ($domains as $domain) { 35 | $this->certificates[] = Cache::remember("filament-check-ssl-widget-$domain", 604800, fn () => $this->getCertificate($domain)); 36 | } 37 | } 38 | 39 | private function getCertificate(string $domain): array 40 | { 41 | $invalidDomain = [ 42 | 'domain' => $domain, 43 | 'is_valid' => false, 44 | 'issuer' => null, 45 | 'expiration_date' => null, 46 | 'expiration_date_in_days' => null, 47 | 'favicon' => null, 48 | ]; 49 | 50 | if ($this->isValidDomain($domain)) { 51 | try { 52 | $certificate = SslCertificate::createForHostName($domain); 53 | } catch (Exception $ignored) { 54 | $invalidDomain['favicon'] = $this->getFaviconByDomain($domain); 55 | 56 | return $invalidDomain; 57 | } 58 | if ($certificate) { 59 | return [ 60 | 'domain' => $domain, 61 | 'is_valid' => $certificate->isValid(), 62 | 'issuer' => $certificate->getIssuer(), 63 | 'expiration_date' => $certificate->expirationDate(), 64 | 'expiration_date_in_days' => $certificate->expirationDate(), 65 | 'favicon' => $this->getFaviconByDomain($domain), 66 | ]; 67 | } 68 | } 69 | 70 | return $invalidDomain; 71 | } 72 | 73 | private function isValidDomain($domain): bool 74 | { 75 | return (bool) preg_match('/^(?:[a-z0-9](?:[a-z0-9-æøå]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/isu', $domain); 76 | } 77 | 78 | private function getFaviconByDomain(string $domain): ?string 79 | { 80 | if (! Str::contains($domain, ['http://', 'https://'])) { 81 | $domain = 'https://' . $domain; 82 | } 83 | 84 | try { 85 | return Favicon::fetch($domain)?->cache(now()->addDay())->getFaviconUrl() ?? null; 86 | } catch (Exception $ignored) { 87 | return null; 88 | } 89 | } 90 | 91 | public function shouldShowTitle(): bool 92 | { 93 | $plugin = Filament::getCurrentPanel()?->getPlugin('filament-check-ssl-widget'); 94 | 95 | return $plugin->getShouldShowTitle(); 96 | } 97 | 98 | public function title() 99 | { 100 | $plugin = Filament::getCurrentPanel()?->getPlugin('filament-check-ssl-widget'); 101 | 102 | return $plugin->getTitle(); 103 | } 104 | 105 | public function description() 106 | { 107 | $plugin = Filament::getCurrentPanel()?->getPlugin('filament-check-ssl-widget'); 108 | 109 | return $plugin->getDescription(); 110 | } 111 | 112 | public static function getSort(): int 113 | { 114 | $plugin = Filament::getCurrentPanel()?->getPlugin('filament-check-ssl-widget'); 115 | 116 | return $plugin->getSort() ?? -1; 117 | } 118 | 119 | public function getColumnSpan(): int | string | array 120 | { 121 | $plugin = Filament::getCurrentPanel()?->getPlugin('filament-check-ssl-widget'); 122 | 123 | return $plugin->getColumnSpan() ?? '1/2'; 124 | } 125 | 126 | public function quantityPerRow() 127 | { 128 | $plugin = Filament::getCurrentPanel()?->getPlugin('filament-check-ssl-widget'); 129 | 130 | return $plugin->getQuantityPerRow(); 131 | } 132 | 133 | public function render(): View 134 | { 135 | return view(static::$view, [ 136 | 'certificates' => $this->certificates, 137 | 'shouldShowTitle' => $this->shouldShowTitle(), 138 | 'title' => $this->title(), 139 | 'description' => $this->description(), 140 | 'quantityPerRow' => $this->quantityPerRow() ?? '1', 141 | ]); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /stubs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joaopaulolndev/filament-check-ssl-widget/111c6d1c390ac65eeab4d795acee1e7b5aa6353b/stubs/.gitkeep --------------------------------------------------------------------------------