Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from justcoded/develop
Browse files Browse the repository at this point in the history
Fixed adminlte dependency, clickjacking, new IDE helper file
  • Loading branch information
aprokopenko authored Feb 6, 2018
2 parents 128b75f + 56557c7 commit dc2d79d
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 92 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ CHANGELOG for Yii2 STARTER PROJECT TEMPLATE

*should be replaced with real project changelog later*


v0.8.5
---------------------
* Issue #19: Updated README about how to access the site
* Issue #20: Admin panel chrome console error: not working adminlte js
* Issue #21: Replace custom Application classes with simple IDE helper file with definitions
* Issue #22: "Clickjacking" attack fix

v0.8.4
---------------------
* Added prefer-stable directive to composer.json
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,16 @@ Now you should be able to access the application through the following URL, assu
directly under the Web root.

~~~
http://localhost/my-project/web/
http://localhost/my-project/public/
~~~

Admin panel can be accessible only after login. If you used fixtures to fill the database with dummy content,
then admin panel access will be:

http://localhost/my-project/public/admin/
User: [email protected]
Password: password_0

TESTING
-------

Expand Down
49 changes: 49 additions & 0 deletions app/Yii.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* IDE autocompletion for custom components!
* This file doesn't included anywhere inside the code!!!
*/

/**
* Yii bootstrap file.
* Used for enhanced IDE code autocompletion.
*/
class Yii extends \yii\BaseYii
{
/**
* @var BaseApplication|WebApplication|ConsoleApplication the application instance
*/
public static $app;
}

/**
* Class BaseApplication
* Used for properties that are identical for both WebApplication and ConsoleApplication
*
* @property \app\components\Settings $settings Configuration params
*/
abstract class BaseApplication extends \yii\base\Application
{
}

/**
* Class WebApplication
* Include only Web application related components here
*
* @property \app\i18n\Formatter $formatter The main formatter for app
* @method \app\i18n\Formatter getFormatter The main formatter for app
*/
class WebApplication extends \yii\web\Application
{
}

/**
* Class ConsoleApplication
* Include only Console application related components here
*
* @property \app\i18n\Formatter $formatter The main formatter for app
* @method \app\i18n\Formatter getFormatter The main formatter for app
*/
class ConsoleApplication extends \yii\console\Application
{
}
23 changes: 0 additions & 23 deletions app/console/Application.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/modules/admin/views/partials/nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<?= dmstr\widgets\Menu::widget(
[
'options' => ['class' => 'sidebar-menu'],
'options' => ['class' => 'sidebar-menu', 'data-widget' => 'tree',],
'items' => [
['label' => 'MAIN NAVIGATION', 'options' => ['class' => 'header']],
['label' => 'Dashboard', 'icon' => 'dashboard', 'url' => ['/admin/dashboard']],
Expand Down
3 changes: 3 additions & 0 deletions app/views/partials/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use justcoded\yii2\rbac\models\Item as RbacItem;

NavBar::begin([
'brandLabel' => 'My Company',
Expand All @@ -19,6 +20,8 @@
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],

['label' => 'Admin Panel', 'url' => ['/admin'], 'visible' => user()->can(RbacItem::PERMISSION_ADMINISTER)],
Yii::$app->user->isGuest ? (
['label' => 'Login', 'url' => ['/auth/login']]
) : (
Expand Down
24 changes: 0 additions & 24 deletions app/web/Application.php

This file was deleted.

31 changes: 0 additions & 31 deletions app/web/Yii.php

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"yiisoft/yii2-swiftmailer": "~2.0.0",
"yiisoft/yii2-faker": "~2.0.0",
"vlucas/phpdotenv": "~2.2",
"dmstr/yii2-adminlte-asset": "2.4.3",
"dmstr/yii2-adminlte-asset": "~2.6",
"justcoded/yii2-settings": "*",
"justcoded/yii2-rbac": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion config/app-console.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
'basePath' => dirname(__DIR__) . '/app',
'runtimePath' => dirname(__DIR__) . '/runtime',
'vendorPath' => dirname(__DIR__) . '/vendor',
'controllerNamespace' => 'app\\console\\controllers',
'bootstrap' => ['log', 'settings'],
'controllerNamespace' => 'app\console\controllers',
'aliases' => [
'@config'=> dirname(__DIR__) . '/config',
'@migrations' => dirname(__DIR__) . '/database/migrations',
Expand Down
1 change: 1 addition & 0 deletions config/app-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'basePath' => dirname(__DIR__) . '/app',
'runtimePath' => dirname(__DIR__) . '/runtime',
'vendorPath' => dirname(__DIR__) . '/vendor',
'controllerNamespace' => 'app\\web\\controllers',
'aliases' => [
'@config'=> '@app/../config',
'@bower' => '@vendor/bower-asset',
Expand Down
9 changes: 8 additions & 1 deletion config/app-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'basePath' => dirname(__DIR__) . '/app',
'runtimePath' => dirname(__DIR__) . '/runtime',
'vendorPath' => dirname(__DIR__) . '/vendor',
'controllerNamespace' => 'app\\web\\controllers',
'bootstrap' => ['log', 'settings'],
'aliases' => [
'@config'=> '@app/../config',
Expand All @@ -23,9 +24,15 @@
],
'components' => [
'request' => [
// TODO: move generator to console command
// TODO: move generator to console command.
'cookieValidationKey' => env('APP_KEY'),
],
'response' => [
// "Clickjacking" attack fix.
'on beforeSend' => function ($event) {
$event->sender->headers->add('X-Frame-Options', 'SAMEORIGIN');
},
],
'db' => $db,
'user' => [
'identityClass' => 'app\models\User',
Expand Down
8 changes: 4 additions & 4 deletions public/index-test.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

// NOTE: Make sure this file is not accessible when deployed to production
// NOTE: Make sure this file is not accessible when deployed to production.
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.');
die('You are not allowed to access this file.');
}

require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../app/bootstrap.php');
// support .env file
// support .env file.
dotenv(dirname(__DIR__))->load();

defined('YII_DEBUG') or define('YII_DEBUG', true);
Expand All @@ -17,4 +17,4 @@

$config = require(__DIR__ . '/../config/app-test.php');

(new \app\web\Application($config))->run();
(new yii\web\Application($config))->run();
7 changes: 3 additions & 4 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../app/bootstrap.php');
// support .env file
// support .env file.
dotenv(dirname(__DIR__))->load();

// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', env('APP_DEBUG', false));
defined('YII_ENV') or define('YII_ENV', env('APP_ENV', 'production'));

require(__DIR__ . '/../app/web/Yii.php');
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

$config = \yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../config/app-web.php'),
require(__DIR__ . '/../config/rbac.php')
);

(new \app\web\Application($config))->run();
(new yii\web\Application($config))->run();
2 changes: 1 addition & 1 deletion yii
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';

$config = require __DIR__ . '/config/app-console.php';

$application = new \app\console\Application($config);
$application = new \yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

0 comments on commit dc2d79d

Please sign in to comment.