justcoded / yii2-starter

Yii2 JustCoded Project Template
Other
41 stars 19 forks source link

Permission deny for master after migration #35

Open zainiafzan opened 6 years ago

zainiafzan commented 6 years ago

After installation and migration RBAC using this command php yii rbac/scan -p='@vendor/justcoded/yii2-rbac/' -b='admin/rbac/' Master have error cannot access dashboard..

Temporary fix is manually change params in justcoded\yii2\rbac\commands\RbacController

line 22 and line 33.

aprokopenko commented 6 years ago

Hi zainiafzan,

Did you assign master role to some user?

The line you mentioned scan only rbac module to allow access to permissions management.

zainiafzan commented 6 years ago

no...its first master after installation.

imho, yii command didnt read params that i pass to it.. thats why i change it directly to the code..

aprokopenko commented 6 years ago

I will check this assumption of course, but this line only scan permission controllers, not the main admin controllers, which should be scanned by default.

Could you access the dashboard index page?

aprokopenko commented 6 years ago

(you should login to access admin pages, if you're not logged in - admin will show you 404 page)

aprokopenko commented 6 years ago

Would be great if you can ping me in Skype: ab.prokopenko, it will be easier to communicate

zainiafzan commented 6 years ago

yes i logged in, using master admin@domain.com

after manually change and run rbac again.. master can access dashboard.. and successfully scan other route using scan route permission...

aprokopenko commented 6 years ago

More info from Zain:

Happens on:


Re-tested by me and was fine on:

Maybe there is a problem with Windows paths or Windows PHP build

aprokopenko commented 6 years ago

The bug is confirmed, Windows OS doesn't pass console command options to the controller correctly. A research has shown that this is a core problem (yii core files doesn't have $params variable inside runAction()), so we can't do anything here.

aprokopenko commented 6 years ago

After further investigation Zain found out, that Windows do not parse command options correctly and leave quotes. That's why scan was not successful.

Project readme is updated to run command without quotes (it's good that we don't have spaces there).

alejosv commented 6 years ago

I have the same issue

$php -v
PHP 7.2.8-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jul 25 2018 10:52:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.8-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
$ mysql --version
mysql  Ver 15.1 Distrib 10.2.16-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic

imagen

aprokopenko commented 6 years ago

It's not clear what URL you're trying to access from your screenshot.

Would be great to have also screens from running rbac commands (on fresh install):

php yii rbac/init php yii rbac/assign-master 1 php yii rbac/scan php yii rbac/scan --path=@vendor/justcoded/yii2-rbac/ --routesBase=admin/rbac/

I didn't test this on PHP 7.2 yet.

alejosv commented 6 years ago

Ok, this is the issue, I run exactly those commands in the console. The first time, when I try acces I get the error 403, but when a run to second time the same commands the error disappear. Now I can access the URL localhost/admin/rbac/permissions. Is some kind weird.

aprokopenko commented 6 years ago

Could you try to run full installation from scratch and make screenshots of a console where you launch rbac commands. It should print info about what's happening. The issue Zain had - permissions weren't imported in any command run. In your case it works for a second time. Maybe you forgot to run the last command?