Skip to content

Commit

Permalink
Merge pull request #34 from dotkernel/master
Browse files Browse the repository at this point in the history
dev refresh
  • Loading branch information
gabidj authored Jun 11, 2018
2 parents f674f01 + 4feb048 commit f5ee785
Show file tree
Hide file tree
Showing 12 changed files with 589 additions and 121 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 1.0.0 - 2018-06-04

Migration to Zend-Expressive 3

### Changed
* Migrate middleware to PSR-15

### Added
* PSR-15 Middleware support

### Deprecated
* Nothing

### Removed
* Nothing

### Fixed
* Nothing


## 0.4.1 - 2017-06-01

### Changed
Expand Down
64 changes: 32 additions & 32 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,55 @@
"license": "MIT",
"authors": [
{
"name": "n3vrax",
"email": "tibi@apidemia.com"
"name": "DotKernel Team",
"email": "team@dotkernel.com"
}
],
"config": {
"sort-packages": true
},
"require": {
"php": "^7.1",
"dotkernel/dot-annotated-services": "^1.1",
"dotkernel/dot-authentication-service": "^0.2",
"dotkernel/dot-authentication-web": "^0.2",
"dotkernel/dot-cache": "^1.1",
"dotkernel/dot-annotated-services": "^1.1.1",
"dotkernel/dot-authentication-service": "^1.0",
"dotkernel/dot-authentication-web": "^1.0",
"dotkernel/dot-cache": "^1.1.1",
"dotkernel/dot-console": "^0.1",
"dotkernel/dot-controller": "^0.3",
"dotkernel/dot-controller-plugin-authentication": "^0.2",
"dotkernel/dot-controller-plugin-authorization": "^0.2",
"dotkernel/dot-controller-plugin-flashmessenger": "^0.2",
"dotkernel/dot-controller-plugin-forms": "^0.2",
"dotkernel/dot-controller-plugin-mail": "^0.1",
"dotkernel/dot-controller-plugin-session": "^0.2",
"dotkernel/dot-controller": "^1.0",
"dotkernel/dot-controller-plugin-authentication": "^1.0",
"dotkernel/dot-controller-plugin-authorization": "^1.0",
"dotkernel/dot-controller-plugin-flashmessenger": "^1.0",
"dotkernel/dot-controller-plugin-forms": "^1.0",
"dotkernel/dot-controller-plugin-mail": "^1.0",
"dotkernel/dot-controller-plugin-session": "^1.0",
"dotkernel/dot-event": "^0.2",
"dotkernel/dot-filter": "^1.1",
"dotkernel/dot-flashmessenger": "^0.2",
"dotkernel/dot-flashmessenger": "^1.0",
"dotkernel/dot-form": "^1.1",
"dotkernel/dot-helpers": "^0.2",
"dotkernel/dot-helpers": "^1.0",
"dotkernel/dot-hydrator": "^1.1",
"dotkernel/dot-inputfilter": "^1.1",
"dotkernel/dot-log": "^1.1",
"dotkernel/dot-mail": "^0.1",
"dotkernel/dot-mapper": "^0.4",
"dotkernel/dot-navigation": "^0.2",
"dotkernel/dot-mail": "^1.0",
"dotkernel/dot-mapper": "^1.0",
"dotkernel/dot-navigation": "^1.0",
"dotkernel/dot-paginator": "^1.1",
"dotkernel/dot-rbac": "^0.2",
"dotkernel/dot-rbac-guard": "^0.2",
"dotkernel/dot-session": "^2.0",
"dotkernel/dot-twigrenderer": "^0.2",
"dotkernel/dot-user": "^0.3",
"dotkernel/dot-validator": "^1.1",
"http-interop/http-middleware": "^0.4.1",
"dotkernel/dot-rbac": "^0.2.1",
"dotkernel/dot-rbac-guard": "^1.0",
"dotkernel/dot-session": "^3.0",
"dotkernel/dot-twigrenderer": "^1.0",
"dotkernel/dot-user": "^1.0",
"dotkernel/dot-validator": "^1.2.1",

"roave/security-advisories": "dev-master",
"zendframework/zend-captcha": "^2.6",
"zendframework/zend-component-installer": "^1.0 || ^0.7.0",
"zendframework/zend-component-installer": "^2.0",
"zendframework/zend-config": "^3.1",
"zendframework/zend-config-aggregator": "^0.2.0",
"zendframework/zend-db": "^2.8",
"zendframework/zend-expressive": "^2.0.2",
"zendframework/zend-expressive-fastroute": "^2.0",
"zendframework/zend-expressive-twigrenderer": "^1.4",
"zendframework/zend-expressive": "^3.0",
"zendframework/zend-expressive-fastroute": "^3.0",
"zendframework/zend-expressive-twigrenderer": "^2.0",
"zendframework/zend-i18n": "^2.7",
"zendframework/zend-i18n-resources": "^2.5",
"zendframework/zend-psr7bridge": "^0.2.2",
Expand All @@ -65,7 +65,7 @@
"require-dev": {
"phpunit/phpunit": "^6.0.8 || ^5.7.15",
"squizlabs/php_codesniffer": "^2.8.1",
"zendframework/zend-expressive-tooling": "^0.3.2",
"zendframework/zend-expressive-tooling": "^1.0",
"filp/whoops": "^2.1.7",
"zfcampus/zf-development-mode": "^3.1"
},
Expand Down Expand Up @@ -103,8 +103,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.4-dev",
"dev-develop": "0.5-dev"
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
}
}
13 changes: 13 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
'config_cache_path' => __DIR__ . '/../data/config-cache.php',
];
$aggregator = new ConfigAggregator([
// zend expressive & middleware factory
\Zend\Expressive\ConfigProvider::class,

// router config
\Zend\Expressive\Router\ConfigProvider::class,
\Zend\Expressive\Router\FastRouteRouter\ConfigProvider::class,

\Zend\Expressive\Twig\ConfigProvider::class,
\Zend\Expressive\Helper\ConfigProvider::class,

// handler runner
\Zend\HttpHandlerRunner\ConfigProvider::class,

// Include cache configuration
new ArrayProvider($cacheConfig),

Expand Down
83 changes: 46 additions & 37 deletions config/pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,68 @@
use Zend\Expressive\Middleware\NotFoundHandler;
use Zend\Stratigility\Middleware\ErrorHandler;

// new middleware
use Psr\Container\ContainerInterface;
use Zend\Expressive\Application;
use Zend\Expressive\MiddlewareFactory;
use Zend\Expressive\Router\Middleware\RouteMiddleware;
use Zend\Expressive\Router\Middleware\DispatchMiddleware;

/**
* Setup middleware pipeline:
*/

// The error handler should be the first (most outer) middleware to catch
// all Exceptions.
/** @var \Zend\Expressive\Application $app */
$app->pipe(ErrorHandler::class);
$app->pipe(ServerUrlMiddleware::class);
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
$app->pipe(ErrorHandler::class);
$app->pipe(ServerUrlMiddleware::class);

// starts the session and tracks session activity
$app->pipe(SessionMiddleware::class);
// starts the session and tracks session activity
$app->pipe(SessionMiddleware::class);

// automatically login the user if it has a valid remember token
$app->pipe(AutoLogin::class);
// automatically login the user if it has a valid remember token
$app->pipe(AutoLogin::class);

// Pipe more middleware here that you want to execute on every request:
// - bootstrapping
// - pre-conditions
// - modifications to outgoing responses
// Pipe more middleware here that you want to execute on every request:
// - bootstrapping
// - pre-conditions
// - modifications to outgoing responses

// Register the routing middleware in the middleware pipeline
$app->pipeRoutingMiddleware();
// Register the routing middleware in the middleware pipeline
$app->pipe(RouteMiddleware::class);

// zend expressive middleware
$app->pipe(ImplicitHeadMiddleware::class);
$app->pipe(ImplicitOptionsMiddleware::class);
$app->pipe(UrlHelperMiddleware::class);
// zend expressive middleware
$app->pipe(ImplicitHeadMiddleware::class);
$app->pipe(ImplicitOptionsMiddleware::class);
$app->pipe(UrlHelperMiddleware::class);

// authentication and authorization error handlers
// this is piped here to have access to the route result
// it should be ok, as these particular errors are generated from below middleware or routed middleware
$app->pipe(ForbiddenHandler::class);
$app->pipe(UnauthorizedHandler::class);
// authentication and authorization error handlers
// this is piped here to have access to the route result
// it should be ok, as these particular errors are generated from below middleware or routed middleware
$app->pipe(ForbiddenHandler::class);
$app->pipe(UnauthorizedHandler::class);

// Add more middleware here that needs to introspect the routing results; this
// ...
// Add more middleware here that needs to introspect the routing results; this
// ...

// this middleware redirects to login or dashboard, based on authentication status, if `/` path is accessed
// this is just to make the UI more friendly, by by-passing the rbac guards in this particular case
$app->pipe(AdminIndexMiddleware::class);
// this middleware redirects to login or dashboard, based on authentication status, if `/` path is accessed
// this is just to make the UI more friendly, by by-passing the rbac guards in this particular case
$app->pipe(AdminIndexMiddleware::class);

// navigation middleware makes sure the navigation service is injected the RouteResult
$app->pipe(NavigationMiddleware::class);
// navigation middleware makes sure the navigation service is injected the RouteResult
$app->pipe(NavigationMiddleware::class);

// the RBAC guards protect chunks of the application(routes or controllers or controller actions)
// the authorization service can be used together with the guards for maximum security and finer control
$app->pipe(RbacGuardMiddleware::class);
// the RBAC guards protect chunks of the application(routes or controllers or controller actions)
// the authorization service can be used together with the guards for maximum security and finer control
$app->pipe(RbacGuardMiddleware::class);

// Register the dispatch middleware in the middleware pipeline
$app->pipeDispatchMiddleware();
// Register the dispatch middleware in the middleware pipeline
$app->pipe(DispatchMiddleware::class);

// At this point, if no Response is return by any middleware, the
// NotFoundHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
$app->pipe(NotFoundHandler::class);
// At this point, if no Response is return by any middleware, the
// NotFoundHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
$app->pipe(NotFoundHandler::class);
};
85 changes: 47 additions & 38 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,53 @@
use Dot\Authentication\Web\Action\LogoutAction;
use Dot\User\Controller\UserController as UserController;

/**
* Setup routes with a single request method:
*
* $app->get('/', App\Action\HomePageAction::class, 'home');
* $app->post('/album', App\Action\AlbumCreateAction::class, 'album.create');
* $app->put('/album/:id', App\Action\AlbumUpdateAction::class, 'album.put');
* $app->patch('/album/:id', App\Action\AlbumUpdateAction::class, 'album.patch');
* $app->delete('/album/:id', App\Action\AlbumDeleteAction::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Action\ContactAction::class, ['GET', 'POST', ...], 'contact');
*
* Or handling all request methods:
*
* $app->route('/contact', App\Action\ContactAction::class)->setName('contact');
*
* or:
*
* $app->route(
* '/contact',
* App\Action\ContactAction::class,
* Zend\Expressive\Router\Route::HTTP_METHOD_ANY,
* 'contact'
* );
*/
// new middleware
use Psr\Container\ContainerInterface;
use Zend\Expressive\Application;
use Zend\Expressive\MiddlewareFactory;
use Zend\Expressive\Router\Middleware\RouteMiddleware;
use Zend\Expressive\Router\Middleware\DispatchMiddleware;

/** @var \Zend\Expressive\Application $app */
// Dashboard controller route
$app->route('/dashboard[/{action}]', DashboardController::class, ['GET', 'POST'], 'dashboard');
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
/**
* Setup routes with a single request method:
*
* $app->get('/', App\Action\HomePageAction::class, 'home');
* $app->post('/album', App\Action\AlbumCreateAction::class, 'album.create');
* $app->put('/album/:id', App\Action\AlbumUpdateAction::class, 'album.put');
* $app->patch('/album/:id', App\Action\AlbumUpdateAction::class, 'album.patch');
* $app->delete('/album/:id', App\Action\AlbumDeleteAction::class, 'album.delete');
*
* Or with multiple request methods:
*
* $app->route('/contact', App\Action\ContactAction::class, ['GET', 'POST', ...], 'contact');
*
* Or handling all request methods:
*
* $app->route('/contact', App\Action\ContactAction::class)->setName('contact');
*
* or:
*
* $app->route(
* '/contact',
* App\Action\ContactAction::class,
* Zend\Expressive\Router\Route::HTTP_METHOD_ANY,
* 'contact'
* );
*/

// following three routes are for user(in this case user refers to the admin user) authentication and management
$app->route('/admin/login', LoginAction::class, ['GET', 'POST'], 'login');
$app->route('/admin/logout', LogoutAction::class, ['GET'], 'logout');
$app->route('/admin[/{action}[/{id}]]', [AdminController::class, UserController::class], ['GET', 'POST'], 'user');
/** @var \Zend\Expressive\Application $app */
// Dashboard controller route
$app->route('/dashboard[/{action}]', DashboardController::class, ['GET', 'POST'], 'dashboard');

// this route is for the frontend user management(hence the f_ prefix)
// if this admin application is used without the frontend application(no frontend user management required)
// you can remove the Admin\User module together with any configuration related to it
// TODO: we'll offer the option to use admin package without frontend in future releases, as installation scripts
$app->route('/user[/{action}[/{id}]]', UserManagementController::class, ['GET', 'POST'], 'f_user');
// following three routes are for user(in this case user refers to the admin user) authentication and management
$app->route('/admin/login', LoginAction::class, ['GET', 'POST'], 'login');
$app->route('/admin/logout', LogoutAction::class, ['GET'], 'logout');
$app->route('/admin[/{action}[/{id}]]', [AdminController::class, UserController::class], ['GET', 'POST'], 'user');

// this route is for the frontend user management(hence the f_ prefix)
// if this admin application is used without the frontend application(no frontend user management required)
// you can remove the Admin\User module together with any configuration related to it
// TODO: we'll offer the option to use admin package without frontend in future releases, as installation scripts
$app->route('/user[/{action}[/{id}]]', UserManagementController::class, ['GET', 'POST'], 'f_user');
};
Loading

0 comments on commit f5ee785

Please sign in to comment.