Coder Social home page Coder Social logo

dotkernel / admin Goto Github PK

View Code? Open in Web Editor NEW
19.0 8.0 5.0 9.4 MB

DotKernel Admin Application. DotKernel Frontend Application. Based on Zend namespace for branch 1. Based on Laminas and Mezzio for branch 2 and above.

Home Page: https://admin4.dotkernel.net

License: MIT License

PHP 16.77% JavaScript 15.05% SCSS 8.61% Twig 3.27% CSS 56.30%
psr-7 middleware jquery bootstrap3 php80 php81 bootstrap4

admin's Introduction

admin

DotKernel web starter package suitable for admin applications.

OSS Lifecycle PHP from Packagist (specify version)

GitHub issues GitHub forks GitHub stars GitHub license

Build Static Build Static codecov

SymfonyInsight

Installing DotKernel admin

Tools

DotKernel can be installed through a single command that utilizes Composer. Because of that, Composer is required to install DotKernel admin.

Composer

Installation instructions:

If you have never used composer before make sure you read the Composer Basic Usage section in Composer's documentation

Choosing an installation path for DotKernel admin

Example:

  • absolute path /var/www/dk-admin
  • or relative path dk-admin (equivalent with ./dk-admin)

Installing DotKernel admin

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

I. Installing DotKernel admin using composer

The advantage of using this command is that it runs through the whole installation process. Run the following command:

composer create-project dotkernel/admin -s dev dk

The above command downloads the admin package, then downloads and installs the dependencies.

The setup script prompts for some configuration settings, for example the lines below:

Please select which config file you wish to inject 'Laminas\Diactoros\ConfigProvider' into:
  [0] Do not inject
  [1] config/config.php
  Make your selection (default is 0):

Simply select [0] Do not inject, because DotKernel includes its own configProvider which already contains the prompted configurations. If you choose [1] config/config.php Laminas's ConfigProvider from session will be injected.

The next question is:

Remember this option for other packages of the same type? (y/N)

Type y here, and hit enter

II. Installing DotKernel admin using git clone

This method requires more manual input, but it ensures that the default branch is installed, even if it is not released. Run the following command:

git clone https://github.com/dotkernel/admin.git .

The dependencies have to be installed separately, by running this command

composer install

Just like for II Installing DotKernel admin using composer (see above), the setup asks for configuration settings regarding injections (type 0 and hit enter) and a confirmation to use this setting for other packages (type y and hit enter)

Configuration - First Run

  • Remove the .dist extension from the files config/autoload/local.php.dist
  • Edit config/autoload/local.php according to your dev machine and fill in the database configuration

Run the migrations and seeds with these commands:

  php bin/doctrine-migrations migrate
  php bin/doctrine fixtures:execute
  • If you use composer create-project, the project will go into development mode automatically after installing. The development mode status can be checked and toggled by using these composer commands:
  composer development-status
  composer development-enable
  composer development-disable
  • If not already done on installation, remove the .dist extension from config/autoload/development.global.php.dist. This will enable dev mode by turning debug flag to true and turning configuration caching to off. It will also make sure that any existing config cache is cleared.

Charset recommendation: utf8mb4_general_ci

Manage GeoLite2 database

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

php bin/cli.php geoip:synchronize -d {DATABASE}

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

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

php bin/cli.php geoip:synchronize

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

asn: n/a -> 2021-07-01 02:09:34

city: n/a -> 2021-07-01 02:09:20

country: n/a -> 2021-07-01 02:05:12

Get help for this command by running:

php bin/cli.php help geoip:synchronize

Tip: If you setup the synchronizer command as a cronjob, you can add the -q|--quiet option, and it will output data only if an error has occurred.

NPM Commands

To install dependencies into the node_modules directory run this command.

npm install

If npm install fails, this could be caused by user permissions of npm. Recommendation is to install npm through Node Version Manager.

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

npm run watch

After all updates are done, this command compiles the assets locally, minifies them and makes them ready for production.

npm run prod

Authorization Guards

The packages responsible for restricting access to certain parts of the application are dot-rbac-guard and dot-rbac. 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.

The authorization.global.php file provides multiple configurations specifying multiple roles as well as the types of permissions to which these roles have access.

//example of a flat RBAC model that specifies two types of roles as well as their permission
    'roles' => [
        'superuser' => [
            'permissions' => [
                'authenticated',
                'edit',
                'delete',
                //etc..
            ]
        ],
        'admin' => [
            'permissions' => [
                'authenticated',
                //etc..
            ]
        ]
    ]

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.

//example of configuration example to restrict certain actions of some routes based on the permissions specified in the dot-rbac configuration file
    'rules' => [
        [
            'route' => 'account',
            'actions' => [//list of actions to apply , or empty array for all actions
                'unregister',
                'avatar',
                'details',
                'changePassword'
            ],
            'permissions' => ['authenticated']
        ],
        [
            'route' => 'admin',
            'actions' => [
                'deleteAccount'
            ],
             'permissions' => [
                'delete'
                //list of roles to allow
            ]
        ]
    ]

Testing (Running)

Note: Do not enable dev mode in production

  • Run the following command in your project's directory to start PHPs built-in server:
  php -S 0.0.0.0:8080 -t public

Running command composer serve will do the exact same, but the above is faster.

0.0.0.0 means that the server is open to all incoming connections 127.0.0.1 means that the server can only be accessed locally (localhost only) 8080 the port on which the server is started (the listening port for the server)

NOTE: If you are still getting exceptions or errors regarding some missing services, try running the following command

php bin/clear-config-cache.php

If config-cache.php is present that config will be loaded regardless of the ConfigAggregator::ENABLE_CACHE in config/autoload/mezzio.global.php

  • Open a web browser and visit http://localhost:8080/

You should see the DotKernel admin login page.

If you ran the migrations you will have an admin user in the database with the following credentials:

  • User: admin
  • Password: dotadmin

NOTE:

  • Production only: Make sure you modify the default admin credentials.
  • Development only: session.cookie_secure does not work locally so make sure you modify your local.php, as per the following:
# other code

return [
    # other configurations...
    'session_config' => [
        'cookie_secure' => false,
    ],
];

Do not change this in local.php.dist as well because this value should remain true on production.

admin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

admin's Issues

replace bootbox nmp with something else

https://js.libhunt.com/bootbox-alternatives

Cross-Site Scripting in bootbox

All version of bootbox are vulnerable to Cross-Site Scripting. The package does not sanitize user input in the provided dialog boxes, allowing attackers to inject HTML code and execute arbitrary JavaScript.
Recommendation

Sanitize user input being passed to bootbox or consider using an alternative package.

Error log filename not correct

As it was pointed out by @d3aq in this issue

Because writer stream is specified in ./config/autoload/error-handling.global.php
sprintf('%s/../../log/error-log-%s.log', __DIR__, date('Y-m-d'))
it will be cached in ./data/cache/config-cache.php and the date() in filename it will remain the date when config-cache.php was created.

This issue needs to be fixed in DK3 Admin as well.

User/admin management UI problem

Steps to re-create problem in admin UI

  • open modal form like add admin/user etc.
  • submit form with errors(submit it empty)
  • the form will re-appear with errors, but it seems there is a doubled backdrop
  • if closing the form, one backdrop remains, making the UI unaccesible

laminas form

  1. check if the package laminas/laminas-form is required
  2. if can be removed from composer, remove it
  3. make a new release with the updated composer.json file
  4. trebe sa dam la baietii noul composer sa stie gen

update composer

remove packages from root composer.json if they are are already required by other packages

Admin menu

Small issues with the menu(or feature??)

When hovering over the menu items, it seems that the icon covers the anchor link. This leads to this behavior, which to me seems a bit inconsistent: clicking when active it will go to the page, clicking on the icon will expand the menu. Is this the desired behavior?

I would suggest we find a consistent way for the menu to work

  1. the expand button is good
  2. when clicking on a menu item with subitems, expanding is good
  3. what should happen(always) when clicking on a menu item without sub-items?? Go to the page directly(user won't see the item label, and the icon could not be always enough to describe the actions, unless they expand from the button) OR always expand(it will require 2 clicks, though)

Log admin logins

Using the geoip and user-agent packages, we should log every time an admin:

  1. login
  2. failed logins
    Record the IP , user agent, date

missing variable in local.php

in config/autoload/local.php (also local.php.dist) the variable $app is used, but not defined
what structure should it have, besides $app['name']?
or could it be simply replaced with a string?

new release to V4

please make a release , after you remove php 7.4 from admin

after is closed #126

release 4.0.1
which include data-fixtures

User list pagination issue

The total count found in background call /user/list/ is always equal to 1, no matter how many items are there to be displayed. Because of this, bootstrap displays only one page of items and no links for the rest of the pages.
{"total":**1**,"rows":[...]}

improve error pages

As requested for frontend, modify error pages in DK3 Admin as well to look like the attached image:
59369097-52556280-8d48-11e9-94e3-1e373503d6f4

check npm packages

update the package.json file in order to have an up to date version of all packages

check for abandonned packages
for security issues
etc

uuid related: Could not convert database value to Doctrine Type uuid_binary_ordered_time.

Current ramsey/uuid:4.1.0 ERROR
"message":"An exception has been thrown during the rendering of a template ("Could not convert database value "11eadd26-efe4-58ba-b..." to Doctrine Type uuid_binary_ordered_time. Expected format: UuidV1").","extra":{"\u0000Twig\Error\Error\u0000lineno":57,"\u0000Twig\Error\Error\u0000name":"@partial/account-menu.html.twig",

Temporary solution :
composer require ramsey/uuid:4.0.1

Article Dotkernel admin v 4.0

on dotkernel.com

what is admin
An application based on Mezzio , with the main purpose of displaying tabular data from one or many databases
components
provided by which package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.