[Extension] Auth

Hi All

This is my config file

Using YiiBorilerplate + YiiStrap last version.





'components.user' => array(

		'class' => 'common.modules.auth.components.AuthWebUser',

		'allowAutoLogin' => true,

		'loginUrl' => array('/user/login'),

		'behaviors' => array(

                  	'auth' => array(

                      	'class' => 'common.modules.auth.components.AuthBehavior',

                        	'admins' => array('admin'), // users with full access

                    	),

                	),

     ),


	 'components.auth' => array(

			'class' => 'CDbAuthManager',

			'connectionID' => 'db',

			'assignmentTable'=>'authassignment', // Linux Case Sensitive Tables (Fix)

			'itemTable'=>'authitem',

			'itemChildTable'=>'authitemchild',

	 		'behaviors' => array(

				'auth' => array(

					'class' => 'common.modules.auth.components.AuthBehavior',

					'admins' => array('admin'),

				),

			),

	    ),

		'modules.auth' => array(

	 		'class'=>'common.modules.auth.AuthModule', 

			'strictMode' => true, 

			'userClass' => 'User', 

			'userIdColumn' => 'id', 

			'userNameColumn' => 'username', 

			'viewDir' => null, 

	 		'defaultLayout' => 'webroot.themes.abound.views.layouts.column2',

			'appLayout' => 'webroot.themes.abound.views.layouts.column2',

	      ),

	



Minor changes on views

//‘type’ => ‘striped hover’,

//‘type’=>TbHtml::FORM_INLINE,

//‘style’=>TbHtml::STYLE_PRIMARY,

//‘style’=>TbHtml::STYLE_LINK,

But two things that I would like to know

1 - would be great if this extension as rights ext, have the same function to generate all items.

that took me time to understand how to generate the naming policy for the controller authorization items.

2 - I have this operations / task and, created a role assigned to user.

Auth.Assignment.*

	Auth.AuthItem.*


	User.Admin.*


	User.User.*

But still can’t access the specific modules. I can only work with normal Controller/actions. but not for modules.

Results:

Error 403

You are not authorized to perform this action.

How it would be.

Sorry my English.

Hi,

How can I use this module with this module : http://www.yiiframework.com/extension/account-module/

the table :


CREATE TABLE `account` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `email` varchar(128) NOT NULL,

  `password` varchar(128) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

Main config file


	'modules'=>array(

		'auth'=> array(

					'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.

					//'userClass' => 'User', // the name of the user model class.

					'userClass' => 'Account', // the name of the user model class.

					'userIdColumn' => 'id', // the name of the user id column.

					'userNameColumn' => 'email', // the name of the user name column.

					'defaultLayout' => 'application.views.layouts.main', // the layout used by the module.

					//'appLayout' => 'webroot.themes.bootstrap.views.layouts.main', // the layout used by the module.//good working??!

					'viewDir' => null, // the path to view files to use with this module.

  		),

		'account'=>array(

            	'defaultController'=>'account',

            ),

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'gii',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

			'generatorPaths' => array(

				'bootstrap.gii'

          		),

		),

		'Category',

	),



Thanks in advance.

Hi!

Is there any version of Auth ready to use with Yiistrap?

latest version works with Yiistrap

How can I do this:

Guest Role - can read any article, ads

Auth Role - can read & comment , edit own comment, edit his profile (user model)

Article Role - Can manage articles

Admin - All above … site admin role …

Thanks

Tks!

I don’t get this installed. I tried with wamp, xamp en different php versions, but no luck.

Every time the same error

I’m using this tutorial and get the error when I want to open “your-app/index.php/rights/install” in my case your-app is rjtest.

Hopefully someone can give me some help on this.

In the Attachment the page I get.

Please add ability to use this ext. without bootstrap. thnx.

Hello Chris,

I want to thank you for all the work that you have done with yii, I am every new to yii and I see your name all over the site and other forums and I know that you have put much time into the system. I loaded your rights module today and played with a little, but decided to switch to the Auth module because it seems like this is where you are focused now. I also have yiistrap and yiiwheels, so this also fits in well with what I am doing.

Installing the Auth module from yii/extensions, I was able to get it running after a little fine turning and modifying it for yiistrap. I read the post stating that it was compatible with yiistrap already so I decided to download it for GitHub. After tuning this one, i ran into some problems.

1) AuthBehavior is missing  	public $admins = array('admin');


2) Then I received this error: CachedDbAuthManager and its behaviors do not have a method or closure named "getItemsPermissions"


		I commented out the cache lines in my main/config


3) and the received this error: CDbAuthManager and its behaviors do not have a method or closure named "getItemsPermissions"

I have stopped at this point and will look at it again in the morning. All the files from GitHub are dated September 8, 2013, but the system says it was updated 3 months ago, maybe there is a problem there I don’t know.

Thank you again for all your hard work and I am looking forward to any new projects that you are planning. Congratulations on the birth of your second son :)

@rjdevries

Rights and Auth are two different modules. Try getting iii-users running first and then come back and install the Auth module following the readme doc.

Compatibility between yii-auth and yiistrap has now been fixed. Please update both extensions.

https://github.com/Crisu83/yii-auth/tree/1.7.0

I think you don’t have Controller component. You should double check if you have it in your ../components/controller.php

Hello, everyone, do not speak English, I use a translator :).

I’m trying to work with this extension.

Examined the information in this topic and on the page of the expansion

It turned out all customized with the user in the config ‘admin’

Created for the user and he created the role with the operation test.* For the test controller with a view index.

there is a filter according to the instructions

pass by reference /test/index

Error 401

Access denied.

Yii user this has no effect, it was before it

and i try yii-auth 1.6 and 1.7

please! help!

this my config file main.php


<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',




	// preloading 'log' component

	'preload'=>array(

        'log',

        'bootstrap',

    ),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

        'application.extensions.*',


        'application.modules.user.models.*',

        'application.modules.user.components.*',

        'application.modules.auth.*',

        'application.modules.auth.components.*',

    ),


    'modules' => array(

        //phs//yii-user module

        'user' => array(

            # encrypting method (php hash function)

            'hash' => 'md5',

            # send activation email

            'sendActivationMail' => true,

            # allow access for non-activated users

            'loginNotActiv' => false,

            # activate user on registration (only sendActivationMail = false)

            'activeAfterRegister' => false,

            # automatically login from registration

            'autoLogin' => true,

            # registration path

            'registrationUrl' => array('/user/registration'),

            # recovery password path

            'recoveryUrl' => array('/user/recovery'),

            # login form path

            'loginUrl' => array('/user/login'),

            # page after login

            'returnUrl' => array('/user/profile'),

            # page after logout

            'returnLogoutUrl' => array('/user/login'),


            'tableUsers' => 'users',

            'tableProfiles' => 'profiles',

            'tableProfileFields' => 'profiles_fields',

        ),


		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'123',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),


        'auth' => array(

            'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.

            'userClass' => 'User', // the name of the user model class.

            'userIdColumn' => 'id', // the name of the user id column.

            'userNameColumn' => 'username', // the name of the user name column.

            'appLayout' => 'application.views.layouts.main', // the layout used by the module.

            'viewDir' => null, // the path to view files to use with this module.

        ),


	),


	// application components

	'components'=>array(




        //'user'=>array(

			// enable cookie-based authentication

			//'allowAutoLogin'=>true,

		//),

		// uncomment the following to enable URLs in path-format


		'urlManager'=>array(

			'urlFormat'=>'path',

            'showScriptName'=>false,

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),


		'db'=>array(

			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		),

		// uncomment the following to use a MySQL database


		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=tag',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

		),


		'errorHandler'=>array(

			// use 'site/error' action to display errors

			'errorAction'=>'site/error',

		),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),


        'authManager' => array(

            //'class' => 'auth.components.CDbAuthManager',

            'class' => 'auth.components.CachedDbAuthManager',

            'cachingDuration' => 3600,

            'behaviors' => array(

                'auth' => array(

                    'class' => 'auth.components.AuthBehavior',

                    /**

                     * The 'admin', 'demo' are the usernames of superuser.

                     * These usernames must be the same as your login username.

                     * For example, if your login username does not need email, then these username does not need email.

                     */

                    'admins' => array('admin'), // users with full access

                ),

            ),

        ),


        'user' => array(

            'class' => 'WebUser',

            //'class' => 'auth.components.AuthWebUser',

            //'admins' => array('demo'), // users with full access

            'loginUrl' => array('/user/login'),


        ),


        'bootstrap' => array(

            'class' => 'application.yiibooster.components.Bootstrap',

        ),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);

I updated to 1.7 for compatibility w/ yiistrap, and the TABS (submenu) disappeared…

When inspecting the generated HTML code, I noticed that a div was missing:

<div class="auth-module">

I think the main layout was not being used…

So, I fixed it like this (not sure if it is the proper way):

In components/AuthController.php init(): $this->layout = ‘main’;


public function init()

    {

        parent::init();

        $this->layout = 'main';

        $this->menu = $this->getSubMenu();

    }

In views/layouts/main.php, I added:

before the div:


<?php $this->beginContent($this->module->defaultLayout); ?>

after the div:


<?php $this->endContent(); ?>

Seems to be working, although I didn’t test it thoroughly.

Regards,

1st time doing auth on Yii.

I downloaded module, unzipped it in modules dir and modified my main config file and imported db dcheme file into database.

Now, when i what to access my site, i get this error:

Now i’m guessing reason is there is no user created or something like that, but i have no idea how to do that. Is there tutorial somewhere for 100% noobs?

Hey guys,

Anyone know why an operation with a system name of auth.* won’t allow access to the module?

I also can’t seem to get roles working, but I can get tasks to work is assigned to a user.

Any ideas?

I had the same issue with 1.7 but my AuthController.php init() looked like this




 public function init()

    {

        parent::init();

        $this->layout = $this->module->defaultLayout;

        $this->menu = $this->getSubMenu();

    }



so I did the changes you suggested and it worked! Thanks!




 public function init()

    {

        parent::init();

        $this->layout = 'main'; //$this->module->defaultLayout;

        $this->menu = $this->getSubMenu();

    }



I just started using the extension and am unable to figure out How do I associate the tasks/operations with bizrules using the UI?

Could you help?

Thank you very much.

Hi all, I’m really new to Yii and I like this Auth module. Thanks Chris.

I tried the demo and it looks slick! I’m trying to get it working on my system however and I encountered a few errors, most of which I have since been able to solve, except this one:

CDbAuthManager and its behaviors do not have a method or closure named "getAncestors".

It occurs, after trying create a role. It redirects to:

/index.php?r=auth/role/view&name=editvideo

and spawns the error above.

Any idea why this is happening?

Thanks!