私はZF2とbjyauthorizeを初めて使用するので、これが私の側のばかげた間違いであることを期待しています:D
ZF2スケルトンアプリとzfcUserを正常にセットアップし、bjyAuthorizeをミックスに追加しようとしています。また、mySQLへのZend / Db接続タイプを使用しています-DOCTRINE(:D)ではありません。私が使用しているバージョンは、PHP(5.5)、ZF2(2.3。*)、zfcUser(1.2.1)、bjyAuthorize(1.4.0)です。
GitHubReadmeのレターに記載されている指示に従いました。そこにある例の「bjyauthorize.global.php」ファイルには(例として)設定が多すぎて、「\ BjyAuthorize \ Provider \ Role \ ZendDb :: class」の下に誤ったフィールド参照があることに気付くのにそれほど時間はかかりませんでした。"(" role_id "s / b" roleid ")。
基本的に、構成ファイルでルートベースまたはコントローラーベースのガードのコメントを解除するとすぐに(両方を実行するつもりはありません-1つだけ機能させたい)、白い画面が表示されます-役立つエラーメッセージはありません-スケルトンアプリのホームページにアクセスします。したがって、これが私の側のPHP構文エラーであることが心配です。
ZendDeveloperToolsも含めましたが、このエラーが発生したときにフッターのツールバーも表示されません。
これが私の設定ファイルです:
<?php
return [
'bjyauthorize' => [
// set the 'guest' role as default (must be defined in a role provider)
'default_role' => 'guest',
/* this module uses a meta-role that inherits from any roles that should
* be applied to the active user. the identity provider tells us which
* roles the "identity role" should inherit from.
*
* for ZfcUser, this will be your default identity provider
*/
'identity_provider' => \BjyAuthorize\Provider\Identity\ZfcUserZendDb::class,
/* role providers simply provide a list of roles that should be inserted
* into the Zend\Acl instance. the module comes with two providers, one
* to specify roles in a config file and one to load roles using a
* Zend\Db adapter.
*/
'role_providers' => [
// this will load roles from the user_role table in a database
// format: user_role(role_id(varchar], parent(varchar))
\BjyAuthorize\Provider\Role\ZendDb::class => [
'table' => 'user_role',
'identifier_field_name' => 'id',
'role_id_field' => 'roleid',
'parent_role_field' => 'parent_id',
],
],
/* Currently, only controller and route guards exist
*
* Consider enabling either the controller or the route guard depending on your needs.
*/
'guards' => [
/* If this guard is specified here (i.e. it is enabled], it will block
* access to all controllers and actions unless they are specified here.
* You may omit the 'action' index to allow access to the entire controller
*/
// \BjyAuthorize\Guard\Controller::class => [
// ['controller' => 'zfcuser', 'roles' => ['guest']],
// ['controller' => ['Application\Controller\Index'], 'roles' => ['guest']],
// ],
// /* If this guard is specified here (i.e. it is enabled], it will block
// * access to all routes unless they are specified here.
// */
// \BjyAuthorize\Guard\Route::class => [
// ['route' => 'zfcuser', 'roles' => ['user']],
// ['route' => 'zfcuser/logout', 'roles' => ['user']],
// ['route' => 'zfcuser/login', 'roles' => ['guest']],
// ['route' => 'zfcuser/register', 'roles' => ['guest']],
// // Below is the default index action used by the ZendSkeletonApplication
// ['route' => 'home', 'roles' => ['guest', 'user']],
// ],
],
],
];
ガードなしで上記のコードに従って実行すると、site / user / loginからログインでき、Zend DevToolBarにそのユーザーの正しい役割が表示されます。少なくともそれはポジティブです。
さらに詳しい情報や設定を提供させていただきます-ただ学ぼうとしています。
OK、それで私は今かなりばかげていると感じます。
bjyauthorizeに同梱されているDBスキーマには、フィールド「roleId」があります。上記のコードでは、大文字と小文字の区別を考慮せず、「roleid」を使用していました。それを変更すると、すべてが完全に機能します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加