Skip to content

Commit f08120d

Browse files
committed
Merge branch 'release/1.2.0'
2 parents 16340f4 + 01f6bd3 commit f08120d

7 files changed

Lines changed: 56 additions & 18 deletions

File tree

Plugin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
1414
use System\Classes\PluginBase;
1515
use Vdlp\BasicAuthentication\Classes\Helper\AuthorizationHelper;
16+
use Vdlp\BasicAuthentication\Console\CreateCredentialsCommand;
1617
use Vdlp\BasicAuthentication\Models\Credential;
1718
use Vdlp\BasicAuthentication\ServiceProviders\BasicAuthenticationServiceProvider;
1819

@@ -42,6 +43,8 @@ public function pluginDetails(): array
4243
public function register(): void
4344
{
4445
$this->app->register(BasicAuthenticationServiceProvider::class);
46+
47+
$this->registerConsoleCommand(CreateCredentialsCommand::class, CreateCredentialsCommand::class);
4548
}
4649

4750
/**

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ Allows users to manage Basic Authentication credentials for multiple hostnames a
88

99
## Installation
1010

11-
*CLI:*
12-
1311
```
14-
php artisan plugin:install Vdlp.BasicAuthentication
12+
composer require vdlp/oc-basicauthentication-plugin
1513
```
1614

17-
*October CMS:*
15+
Or:
1816

19-
Go to Settings > Updates & Plugins > Install plugins and search for 'BasicAuthentication'.
17+
```
18+
php artisan plugin:install Vdlp.BasicAuthentication
19+
```
2020

2121
## Configuration
2222

@@ -26,12 +26,11 @@ To configure this plugin execute the following command:
2626
php artisan vendor:publish --provider="Vdlp\BasicAuthentication\ServiceProviders\BasicAuthenticationServiceProvider" --tag="config"
2727
```
2828

29-
This will create a `config/basicauthentication.php` file in your app where you can modify the configuration if you don't
30-
want to use .env variables.
29+
This will create a `config/basicauthentication.php` file in your app where you can modify the configuration if you don't want to use .env variables.
3130

3231
## Enable / disable plugin
3332

34-
By default basic authentication is disabled.
33+
By default basic authentication is disabled.
3534

3635
To enable basic authentication, you have to set the env variable to `BASIC_AUTHENTICATION_ENABLED` to `true` in your `.env` file or edit the published config file.
3736

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"email": "octobercms@vdlp.nl"
1010
}
1111
],
12+
"support": {
13+
"email": "octobercms@vdlp.nl"
14+
},
1215
"require": {
1316
"php": "^7.1||^8.0",
1417
"composer/installers": "^1.0"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Vdlp\BasicAuthentication\Console;
6+
7+
use Illuminate\Console\Command;
8+
use Throwable;
9+
use Vdlp\BasicAuthentication\Models\Credential;
10+
11+
final class CreateCredentialsCommand extends Command
12+
{
13+
public function __construct()
14+
{
15+
$this->signature = 'vdlp:basicauthentication:create-credentials {hostname} {realm} {username} {password}';
16+
$this->description = 'Create Basic Authentication credentials.';
17+
18+
parent::__construct();
19+
}
20+
21+
public function handle(): void
22+
{
23+
try {
24+
Credential::query()
25+
->updateOrInsert([
26+
'hostname' => $this->argument('hostname'),
27+
], [
28+
'realm' => $this->argument('realm'),
29+
'username' => $this->argument('username'),
30+
'password' => $this->argument('password'),
31+
'is_enabled' => true,
32+
'updated_at' => now(),
33+
'created_at' => now(),
34+
]);
35+
36+
$this->info('Basic Authentication credentials have been added to the database.');
37+
} catch (Throwable $e) {
38+
$this->error('Could not create Basic Authentication credentials: ' . $e->getMessage());
39+
}
40+
}
41+
}

models/Credential.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
namespace Vdlp\BasicAuthentication\Models;
66

7-
use Eloquent;
87
use October\Rain\Database\Model;
98

10-
/** @noinspection ClassOverridesFieldOfSuperClassInspection */
11-
/** @noinspection LongInheritanceChainInspection */
12-
139
/**
1410
* Class Credential
1511
*
1612
* @package Vdlp\BasicAuthentication\Models
17-
* @mixin Eloquent
1813
*/
1914
class Credential extends Model
2015
{

models/ExcludedUrl.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
namespace Vdlp\BasicAuthentication\Models;
66

7-
use Eloquent;
87
use October\Rain\Database\Model;
98

10-
/** @noinspection ClassOverridesFieldOfSuperClassInspection */
11-
/** @noinspection LongInheritanceChainInspection */
12-
139
/**
1410
* Class ExcludedUrl
1511
*
1612
* @package Vdlp\BasicAuthentication\Models
17-
* @mixin Eloquent
1813
*/
1914
class ExcludedUrl extends Model
2015
{

updates/version.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
- 20190123_000001_create_tables.php
44
1.1.0:
55
- Add notification to settings view when basic authentication is disabled
6+
1.2.0:
7+
- Add console command for adding credentials

0 commit comments

Comments
 (0)