yii2-starter icon indicating copy to clipboard operation
yii2-starter copied to clipboard

Permission deny for master after migration

Open zainiafzan opened this issue 7 years ago • 13 comments

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.

zainiafzan avatar Apr 16 '18 17:04 zainiafzan

Hi zainiafzan,

Did you assign master role to some user?

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

aprokopenko avatar Apr 16 '18 17:04 aprokopenko

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..

zainiafzan avatar Apr 16 '18 17:04 zainiafzan

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 avatar Apr 16 '18 17:04 aprokopenko

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

aprokopenko avatar Apr 16 '18 17:04 aprokopenko

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

aprokopenko avatar Apr 16 '18 17:04 aprokopenko

yes i logged in, using master [email protected]

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

zainiafzan avatar Apr 16 '18 17:04 zainiafzan

More info from Zain:

Happens on:

  • Windows 10
  • PHP 7.0.10

Re-tested by me and was fine on:

  • Mac OSX / Ubuntu 16.04 servers
  • PHP 7.1

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

aprokopenko avatar Apr 16 '18 17:04 aprokopenko

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 avatar Apr 16 '18 18:04 aprokopenko

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).

aprokopenko avatar Apr 17 '18 08:04 aprokopenko

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

alejosv avatar Aug 13 '18 15:08 alejosv

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.

aprokopenko avatar Aug 13 '18 15:08 aprokopenko

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.

alejosv avatar Aug 13 '18 16:08 alejosv

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?

aprokopenko avatar Aug 13 '18 16:08 aprokopenko