Skip to content

Commit 0e8f657

Browse files
authored
Merge pull request #347 from dotkernel/issue-344
Issue #344: Major refactoring
2 parents ea2666c + 4d5e6b6 commit 0e8f657

289 files changed

Lines changed: 9387 additions & 4429 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
*.jpeg binary
55
*.svg binary
66
*.md diff=markdown
7+
*.ttf export-ignore
78
*.woff export-ignore
89
*.woff2 export-ignore

README.md

Lines changed: 57 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Documentation is available at: https://docs.dotkernel.org/admin-documentation/
3131

3232
## Tools
3333

34-
Dotkernel can be installed through a single command that utilizes [Composer](https://getcomposer.org/). Because of that,
35-
Composer is required to install Dotkernel `admin`.
34+
Dotkernel can be installed through a single command that utilizes [Composer](https://getcomposer.org/).
35+
Because of that, Composer is required to install Dotkernel Admin.
3636

3737
### Composer
3838

@@ -41,24 +41,23 @@ Installation instructions:
4141
- [Composer Installation - Linux/Unix/OSX](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
4242
- [Composer Installation - Windows](https://getcomposer.org/doc/00-intro.md#installation-windows)
4343

44-
>If you have never used composer before make sure you read
45-
>the [`Composer Basic Usage`](https://getcomposer.org/doc/01-basic-usage.md) section in Composer's documentation
44+
> If you have never used composer before make sure you read the [`Composer Basic Usage`](https://getcomposer.org/doc/01-basic-usage.md) section in Composer's documentation.
4645
47-
## Choosing an installation path for Dotkernel `admin`
46+
## Choosing an installation path for Dotkernel Admin
4847

4948
Example:
5049

5150
- absolute path `/var/www/dk-admin`
5251
- or relative path `dk-admin` (equivalent with `./dk-admin`)
5352

54-
## Installing Dotkernel `admin`
53+
## Installing Dotkernel Admin
5554

5655
After choosing the path for Dotkernel (`dk-admin` will be used for the remainder of this example) it must be installed.
5756
There are two installation methods.
5857

59-
### I. Installing Dotkernel `admin` using composer
58+
### I. Installing Dotkernel Admin using Composer
6059

61-
>please use the below CLI commands in terminal, do NOT use the PhpStorm buttons
60+
> please use the below CLI commands in terminal, do NOT use the PhpStorm buttons
6261
6362
The advantage of using this command is that it runs through the whole installation process. Run the following command:
6463

@@ -72,23 +71,24 @@ The setup script prompts for some configuration settings, for example the lines
7271

7372
```text
7473
Please select which config file you wish to inject 'Laminas\Diactoros\ConfigProvider' into:
75-
[0] Do not inject
76-
[1] config/config.php
77-
Make your selection (default is 1):
74+
[0] Do not inject
75+
[1] config/config.php
76+
Make your selection (default is 1):
7877
```
7978

80-
Simply select `[0] Do not inject`, because Dotkernel includes its own configProvider which already contains the prompted
81-
configurations.
79+
Simply select `[0] Do not inject`, because Dotkernel includes its own configProvider which already contains the prompted configurations.
8280

83-
If you choose `[1] config/config.php` Laminas's `ConfigProvider` from `session` will be injected.
81+
If you choose `[1] config/config.php` Laminas' `ConfigProvider` from `session` will be injected.
8482

8583
The next question is:
8684

87-
`Remember this option for other packages of the same type? (y/N)`
85+
```shell
86+
Remember this option for other packages of the same type? (y/N)
87+
```
8888

89-
Type `y` here, and hit `enter`
89+
Type `y` here, and hit `Enter`.
9090

91-
### II. Installing Dotkernel `admin` using git clone
91+
### II. Installing Dotkernel Admin using git clone
9292

9393
This method requires more manual input, but it ensures that the default branch is installed, even if it is not released.
9494
Run the following command:
@@ -103,85 +103,83 @@ The dependencies have to be installed separately, by running this command
103103
composer install
104104
```
105105

106-
Just like for `II Installing Dotkernel admin using composer` (see above), the setup asks for configuration settings
107-
regarding injections (type `0` and hit `enter`) and a confirmation to use this setting for other packages (type `y` and
108-
hit `enter`)
106+
Just like when [Installing Dotkernel admin using Composer](#i-installing-dotkernel-admin-using-composer), the setup asks for configuration settings regarding injections (type `0` and hit `enter`) and the confirmation to use this setting for other packages (type `y` and hit `Enter`).
109107

110108
## Configuration - First Run
111109

112110
- Remove the `.dist` extension from the files `config/autoload/local.php.dist`
113111
- Edit `config/autoload/local.php` according to your dev machine and fill in the `database` configuration
114112

113+
> Charset recommendation: utf8mb4_general_ci
114+
115115
Run the migrations and seeds with these commands:
116116

117117
```shell
118-
php bin/doctrine-migrations migrate
118+
php ./bin/doctrine-migrations migrate
119119
```
120120

121121
```shell
122-
php bin/doctrine fixtures:execute
122+
php ./bin/doctrine fixtures:execute
123123
```
124124

125-
- If you use `composer create-project`, the project will go into development mode automatically after installing. The
126-
development mode status can be checked and toggled by using these composer commands:
125+
- If you use `composer create-project`, the project will go into development mode automatically after installing.
127126

128-
You can check if you have development mode enabled by running:
127+
The development mode status can be checked and toggled by using the below Composer commands:
128+
129+
Check development status by running:
129130

130131
```shell
131132
composer development-status
132133
```
133134

134-
You can enable development mode by running:
135+
Enable development mode by running:
135136

136137
```shell
137138
composer development-enable
138139
```
139140

140-
You can disable development mode by running:
141+
Disable development mode by running:
141142

142143
```shell
143144
composer development-disable
144145
```
145146

146147
- If not already done on installation, remove the `.dist` extension from `config/autoload/development.global.php.dist`.
147-
This will enable dev mode by turning debug flag to `true` and turning configuration caching to `off`. It will also
148-
make sure that any existing config cache is cleared.
149148

150-
> Charset recommendation: utf8mb4_general_ci
149+
This will enable dev mode by turning debug flag to `true` and turning configuration caching to `off`.
150+
It will also make sure that any existing config cache is cleared.
151151

152152
## Manage GeoLite2 database
153153

154154
You can download/update a specific GeoLite2 database, by running the following command:
155155

156156
```shell
157-
php bin/cli.php geoip:synchronize -d {DATABASE}
157+
php ./bin/cli.php geoip:synchronize -d {DATABASE}
158158
```
159159

160160
Where _{DATABASE}_ takes one of the following values: `asn`, `city`, `country`.
161161

162162
You can download/update all GeoLite2 databases at once, by running the following command:
163163

164164
```shell
165-
php bin/cli.php geoip:synchronize
165+
php ./bin/cli.php geoip:synchronize
166166
```
167167

168-
The output should be similar to the below, displaying per
169-
row: `database identifier`: `previous build datetime` -> `current build datetime`.
168+
The output should be similar to the below, displaying per row:
170169

171-
> asn: n/a -> 2021-07-01 02:09:34
172-
>
173-
> city: n/a -> 2021-07-01 02:09:20
174-
>
175-
> country: n/a -> 2021-07-01 02:05:12
170+
```shell
171+
asn: n/a -> 2015-10-21 04:29:00
172+
city: n/a -> 2015-10-21 04:29:00
173+
country: n/a -> 2015-10-21 04:29:00
174+
```
176175

177176
Get help for this command by running:
178177

179178
```shell
180-
php bin/cli.php help geoip:synchronize
179+
php ./bin/cli.php help geoip:synchronize
181180
```
182181

183-
**Tip**: If you setup the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output
184-
data only if an error has occurred.
182+
> If you set up the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.
185183
186184
## NPM Commands
187185

@@ -191,8 +189,8 @@ To install dependencies into the `node_modules` directory run this command.
191189
npm install
192190
```
193191

194-
If `npm install` fails, this could be caused by user permissions of npm. Recommendation is to install npm
195-
through `Node Version Manager`.
192+
If `npm install` fails, this could be caused by user permissions of npm.
193+
Recommendation is to install npm through `Node Version Manager`.
196194

197195
The watch command compiles the components then watches the files and recompiles when one of them changes.
198196

@@ -208,15 +206,12 @@ npm run prod
208206

209207
## Authorization Guards
210208

211-
The packages responsible for restricting access to certain parts of the application
212-
are [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) and [dot-rbac](https://github.com/dotkernel/dot-rbac).
213-
These packages work together to create an infrastructure that is customizable and diversified to manage user access to
214-
the platform by specifying the type of role the user has.
209+
The packages responsible for restricting access to certain parts of the application are [dot-rbac-guard](https://github.com/dotkernel/dot-rbac-guard) and [dot-rbac](https://github.com/dotkernel/dot-rbac).
210+
These packages work together to create an infrastructure that is customizable and diversified to manage user access to the platform by specifying the type of role the user has.
215211

216-
The `authorization.global.php` file provides multiple configurations specifying multiple roles as well as the types of
217-
permissions to which these roles have access.
212+
The `authorization.global.php` file provides multiple configurations specifying multiple roles as well as the types of permissions to which these roles have access.
218213

219-
```text
214+
```php
220215
'roles' => [
221216
'superuser' => [
222217
'permissions' => [
@@ -235,11 +230,9 @@ permissions to which these roles have access.
235230
]
236231
```
237232

238-
The `authorization-guards.global.php` file provides configuration to restrict access to certain actions based on the
239-
permissions defined in `authorization.global.php` so basically we have to add the permissions in the dot-rbac
240-
configuration file first to specify the action restriction permissions.
233+
The `authorization-guards.global.php` file provides configuration to restrict access to certain actions based on the permissions defined in `authorization.global.php` so basically we have to add the permissions in the dot-rbac configuration file first to specify the action restriction permissions.
241234

242-
```text
235+
```php
243236
'rules' => [
244237
[
245238
'route' => 'account',
@@ -264,9 +257,9 @@ configuration file first to specify the action restriction permissions.
264257
]
265258
```
266259

267-
## Testing (Running)
260+
## Testing (Running) the application
268261

269-
Note: **Do not enable dev mode in production**
262+
> **Do not enable dev mode in production**
270263
271264
- Run the following command in your project's directory to start PHPs built-in server:
272265

@@ -280,31 +273,27 @@ php -S 0.0.0.0:8080 -t public
280273
`127.0.0.1` means that the server can only be accessed locally (localhost only)
281274
`8080` the port on which the server is started (the listening port for the server)
282275

283-
**NOTE:**
284-
If you are still getting exceptions or errors regarding some missing services, try running the following command
276+
> If you are still getting exceptions or errors regarding some missing services, try running the following command:
285277
286278
```shell
287-
php bin/clear-config-cache.php
279+
php ./bin/clear-config-cache.php
288280
```
289281

290-
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE`
291-
> in `config/autoload/mezzio.global.php`
282+
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE` in `config/autoload/mezzio.global.php`
292283
293284
- Open a web browser and visit `http://localhost:8080/`
294285

295286
You should see the `Dotkernel admin` login page.
296-
297287
If you ran the migrations you will have an admin user in the database with the following credentials:
298288

299289
- **User**: `admin`
300290
- **Password**: `dotadmin`
301291

302-
**NOTE:**
303-
304-
- **Production only**: Make sure you modify the default admin credentials.
305-
- **Development only**: `session.cookie_secure` does not work locally so make sure you modify your `local.php`, as per the following:
292+
> **Production only**: Make sure you modify the default admin credentials.
293+
>
294+
> **Development only**: `session.cookie_secure` does not work locally so make sure you modify your `local.php`, as per the following:
306295
307-
```text
296+
```php
308297
return [
309298
'session_config' => [
310299
'cookie_secure' => false,

SECURITY.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
## Supported Versions
44

5-
6-
| Version | Supported | PHP Version |
7-
| ------- | ------------------ |-------------|
8-
| 5.x | :white_check_mark: |![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/admin/5.0.x-dev)|
9-
| 4.x | :white_check_mark: |![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/admin/4.0.1)|
10-
| 3.x | :x: |![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/admin/3.0.x-dev)|
11-
| <= 2.0 | :x: | |
12-
5+
| Version | Supported |
6+
|---------|-------------------------------|
7+
| 6.x | :white_check_mark: |
8+
| 5.x | :white_check_mark: |
9+
| 4.x | :warning: (security-fix only) |
10+
| 3.x | :x: |
11+
| <= 2.0 | :x: |
1312

1413
## Reporting Potential Security Issues
1514

@@ -29,7 +28,6 @@ release prior to any public exposure; this helps protect the project's
2928
users, and provides them with a chance to upgrade and/or update in order to
3029
protect their applications.
3130

32-
3331
## Policy
3432

3533
If we verify a reported security vulnerability, our policy is:
@@ -39,4 +37,3 @@ If we verify a reported security vulnerability, our policy is:
3937

4038
- After patching the release branches, we will immediately issue new security
4139
fix releases for each patched release branch.
42-

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"laminas/laminas-i18n": "^2.26.0",
5050
"laminas/laminas-math": "^3.7.0",
5151
"mezzio/mezzio": "^3.18.0",
52+
"mezzio/mezzio-authentication-oauth2": "^2.11",
5253
"mezzio/mezzio-authorization-rbac": "^1.7.0",
5354
"mezzio/mezzio-cors": "^1.11.1",
5455
"mezzio/mezzio-fastroute": "^3.11.0",
@@ -70,13 +71,17 @@
7071
},
7172
"autoload": {
7273
"psr-4": {
73-
"Admin\\App\\": "src/App/src/",
7474
"Admin\\Admin\\": "src/Admin/src/",
75-
"Admin\\Page\\": "src/Page/src/",
75+
"Admin\\App\\": "src/App/src/",
7676
"Admin\\Dashboard\\": "src/Dashboard/src/",
77+
"Admin\\Page\\": "src/Page/src/",
7778
"Admin\\Setting\\": "src/Setting/src/",
79+
"Admin\\User\\": "src/User/src/",
80+
"Core\\Admin\\": "src/Core/src/Admin/src",
7881
"Core\\App\\": "src/Core/src/App/src",
79-
"Core\\Admin\\": "src/Core/src/Admin/src"
82+
"Core\\Security\\": "src/Core/src/Security/src",
83+
"Core\\Setting\\": "src/Core/src/Setting/src",
84+
"Core\\User\\": "src/Core/src/User/src"
8085
}
8186
},
8287
"autoload-dev": {

0 commit comments

Comments
 (0)