File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313use Symfony \Component \HttpFoundation \Exception \SuspiciousOperationException ;
1414use System \Classes \PluginBase ;
1515use Vdlp \BasicAuthentication \Classes \Helper \AuthorizationHelper ;
16+ use Vdlp \BasicAuthentication \Console \CreateCredentialsCommand ;
1617use Vdlp \BasicAuthentication \Models \Credential ;
1718use 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 /**
Original file line number Diff line number Diff 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:
2626php 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
3635To 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
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 44
55namespace Vdlp \BasicAuthentication \Models ;
66
7- use Eloquent ;
87use 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 */
1914class Credential extends Model
2015{
Original file line number Diff line number Diff line change 44
55namespace Vdlp \BasicAuthentication \Models ;
66
7- use Eloquent ;
87use 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 */
1914class ExcludedUrl extends Model
2015{
Original file line number Diff line number Diff line change 33 - 20190123_000001_create_tables.php
441.1.0 :
55 - Add notification to settings view when basic authentication is disabled
6+ 1.2.0 :
7+ - Add console command for adding credentials
You can’t perform that action at this time.
0 commit comments