Yii Framework Forum: [Extension] Auth - Yii Framework Forum

Jump to content

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] Auth A modern and reponsive user interface for CAuthManager Rate Topic: ***** 2 Votes

#41 User is offline   kashani 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-September 12

Posted 24 March 2013 - 02:08 PM

Hello chris!
Many Thanks For Your auth Module. This Is Very Useful. But There is a great lack :(
I Need To Use bizRule! I add bizRule Manualy To DataBase. I had to manually do it. But it does not work!
bizRule need $params parameters But There is no solution for it here.
if ($user->checkAccess($itemName, $this->params)) 

When This Code Execute In "AuthFilter" second parameters of checkAccess is empty! :(
How do I find the Appropriate object and put That Into $params array?
0

#42 User is offline   toph 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 21-June 11

Posted 01 April 2013 - 05:25 AM

I have an app with several modules. Each module has its own controllers. I tried using setting up operations using
moduleId.*
but users assigned that operation are still denied access. If I use
moduleId/controllerId.*
no such issues arise. Do I have to create operations for all the controllers?
0

#43 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 01 April 2013 - 06:49 AM

View Postflaho, on 22 March 2013 - 09:32 AM, said:

I just installed and updated some files.
When I try ?r=auth I get an error:
Error 500
Property "AuthModule.appLayout" is not defined.
Copyright © 2013 by My Company.
All Rights Reserved.

Any idea ?
thanks


I guess, for example:
'modules' => array(
        ...
        'auth' => array(
            ...
            'appLayout' => 'application.views.layouts.main', // the layout used by the module.
        ),
...

0

#44 User is offline   MaxS 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 28-August 09
  • Location:Moscow

Posted 05 April 2013 - 05:14 AM

View Postcappadochian, on 01 April 2013 - 06:49 AM, said:

I guess, for example:
'modules' => array(
        ...
        'auth' => array(
            ...
            'appLayout' => 'application.views.layouts.main', // the layout used by the module.
        ),
...



You need change in config appLayout to defaultLayout
        'auth' => array(
            'strictMode' => true,
            'userClass' => 'Users',
            'defaultLayout' => 'application.views.layouts.main',
            'viewDir' => 'application.modules.auth.views',
            'forceCopyAssets' => true,
        ),

0

#45 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 07 April 2013 - 02:15 PM

To answer everyone who's asking about the business rules, the reason why they are not include is because I don't think that such data belongs in the user interface. I've been thinking about writing a console command for setting business rules but I'm afraid that it's still on an idea level. I'll see what I can do when I have time to work on this project. Right now I'm kind of busy as my second son was born earlier this week.
Best regards,
Chris

My contribution to the Yii community:
Account | Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#46 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 07 April 2013 - 02:16 PM

View Posttoph, on 01 April 2013 - 05:25 AM, said:

I have an app with several modules. Each module has its own controllers. I tried using setting up operations using
moduleId.*
but users assigned that operation are still denied access. If I use
moduleId/controllerId.*
no such issues arise. Do I have to create operations for all the controllers?

I recently added support for moduleId.*, try upgrading and report back. I hope this resolves your issue.
Best regards,
Chris

My contribution to the Yii community:
Account | Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#47 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 07 April 2013 - 03:01 PM

View PostChris83, on 07 April 2013 - 02:15 PM, said:

Right now I'm kind of busy as my second son was born earlier this week.

what a pleasure! I wish you the bests for the little new man! :D
0

#48 User is offline   santhika 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-March 13

Posted 07 April 2013 - 10:14 PM

yii-auth not properly shown up with tab...i think the nav widget cant handle it?
0

#49 User is offline   Adam I 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 07-April 13

Posted 07 April 2013 - 10:42 PM

Hey Chris,

Thanks for the extension! One thing I'm finding frustrating though..

Why force everyone to use bootstrap?
Wouldn't the extension be more widely useful if using bootstrap were optional?
I mean, bootstrap looks great, but it seems to me that most developers would like to have their choice of front-end.
Since I'm not using bootstrap elsewhere, I have to install it for this functionality only. And then the auth management interface is not consistent with the rest of my app...
0

#50 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 08 April 2013 - 05:15 PM

View PostAdam I, on 07 April 2013 - 10:42 PM, said:

Hey Chris,

Thanks for the extension! One thing I'm finding frustrating though..

Why force everyone to use bootstrap?
Wouldn't the extension be more widely useful if using bootstrap were optional?
I mean, bootstrap looks great, but it seems to me that most developers would like to have their choice of front-end.
Since I'm not using bootstrap elsewhere, I have to install it for this functionality only. And then the auth management interface is not consistent with the rest of my app...

You're not forced to use bootstrap, just write your own views and you can use whatever you want. You can configure the views folder for the module.
Best regards,
Chris

My contribution to the Yii community:
Account | Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#51 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 10 April 2013 - 07:47 AM

Hey Chris,

i have downloaded yii-auth-1.6.0.zip version of this extension. and done configuration as you have mentioned here.

But when i am trying to access the application i am getting below given exception.

**"Property "AuthWebUser.admins" is not defined. "**

Any thoughts about it.

Then i temporary commented below given code.

'user' => array(
'class' => 'auth.components.AuthWebUser',
//'admins' => array('admin', 'foo', 'bar'), // users with full access
),

And run the app. now its working.

But i am unable to access the magic of this extension yet.Its showing permission error.

Could you please tell me how could i fix it.

And also. in you downloaded extension AuthModule.php is not updated as it is shown here
Could you please confirm it.i guess latest release of this extension have still some bugs.Any quick response would be great for us.

Looking forward to here from you.

Thanks in Advance.
CodeSutra
0

#52 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 10 April 2013 - 01:19 PM

View Postcodesutra, on 10 April 2013 - 07:47 AM, said:

Then i temporary commented below given code.

'user' => array(
'class' => 'auth.components.AuthWebUser',
//'admins' => array('admin', 'foo', 'bar'), // users with full access
),

And run the app. now its working.
it's not good. you have to solve this issue. something is not okay with your installation I guess. the extension has to work with 'admins' option enabled.

View Postcodesutra, on 10 April 2013 - 07:47 AM, said:

Its showing permission error.
exactly what page you want to see and exactly what error message do you get? without these informations it's impossible to help.
0

#53 User is offline   ramasurf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 06-February 12

Posted 10 April 2013 - 09:27 PM

Hi first of all, thanks for the extension. It's really useful, although I dont know how to set owner validation into the yii-auth logic

I always use the below code of validation, it's not a good piece of code because it does not allow the separation of cross-cutting logic.


actionUpdate($id){
$post_model=$this->loadmodel($id);
if($post_model->user_id==Yii::app()->user->getId())
 #do st..
else
 #shame on you
}



please, What is the best way to fulfill my expectations? thanks SERGIO
0

#54 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 11 April 2013 - 12:27 AM

View Postcappadochian, on 10 April 2013 - 01:19 PM, said:

it's not good. you have to solve this issue. something is not okay with your installation I guess. the extension has to work with 'admins' option enabled.

exactly what page you want to see and exactly what error message do you get? without these informations it's impossible to help.


Thanks for your reply.

Well i am trying to access /auth/assignment/index this page.then i am getting permission error. And when i am enable admins then it is throwing me Webuser Exception.

I hope it is a bit clear to you.

i Know that admins should be enable to access this extension.But its throwing me exception for Webuser module error.Which i need to fix.
CodeSutra
0

#55 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 11 April 2013 - 02:06 PM

View Postcodesutra, on 11 April 2013 - 12:27 AM, said:

Thanks for your reply.

Well i am trying to access /auth/assignment/index this page.then i am getting permission error. And when i am enable admins then it is throwing me Webuser Exception.

I hope it is a bit clear to you.

i Know that admins should be enable to access this extension.But its throwing me exception for Webuser module error.Which i need to fix.

paste exact error message or printscreen here.
0

#56 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 11 April 2013 - 11:12 PM

View Postcappadochian, on 11 April 2013 - 02:06 PM, said:

paste exact error message or printscreen here.



Error 401
Access denied.


This error i am getting here.When i was trying to access /auth/assignment/index this page.

And if i uncomment
'user' => array( 'class' => 'auth.components.AuthWebUser', //'admins' => array('admin', 'foo', 'bar'), // users with full access ),


admins there then it is throwing Property "AuthWebUser.admins" is not defined. Exception.

Check attached screenshot for it.

Attached File  CException 2013-04-12 09-41-32.png (32.91K)
Number of downloads: 28
CodeSutra
0

#57 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 23-September 11

Posted 12 April 2013 - 06:59 AM

codesutra, I have the same error now. Can't see what's wrong.

My main.php
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Yii Auth Demo',
	
    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory 

	// preloading 'log' component
	'preload'=>array('log'),
    
	'modules' => array(
	    'auth'=>array(
			'appLayout' => 'webroot.themes.theme.views.layouts.main', // the layout used by the module.
		),
		'gii'=>array(
            'generatorPaths'=>array(
                'bootstrap.gii',
            ),
        ),
	),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'defaultController'=>'post',

	// application components
	'components'=>array( 
		'bootstrap'=>array(
            'class'=>'bootstrap.components.Bootstrap',
        ),
		'authManager' => array(
			'class'=>'CDbAuthManager',
		  	//'connectionID' => 'db',
			'behaviors' => array(
	        	'auth' => array(
	          		'class' => 'auth.components.AuthBehavior',
					'admins'=>array('admin','demo','authenticated'), // users with full access
	        	),
			),
	    ),
	    'user'=>array(  
			'class' => 'auth.components.AuthWebUser',
			'admins' => array('admin','demo','authenticated'), // users with full access
			// enable cookie-based authentication
			//'allowAutoLogin'=>true,
		),
		/*'db'=>array(
			'connectionString' => 'sqlite:protected/data/blog.db',
			'tablePrefix' => 'tbl_',
		),*/
		// uncomment the following to use a MySQL database
		
		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=yii-auth',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => 'root',
			'charset' => 'utf8',
			'tablePrefix' => '',
		),
		
		'errorHandler'=>array(
			// use 'site/error' action to display errors
			'errorAction'=>'site/error',
		),
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'post/<id:\d+>/<title:.*?>'=>'post/view',
				'posts/<tag:.*?>'=>'post/index',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		'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',
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>require(dirname(__FILE__).'/params.php'),
);


UserIdentity.php
<?php

/**
 * UserIdentity represents the data needed to identity a user.
 * It contains the authentication method that checks if the provided
 * data can identity the user.
 */
class UserIdentity extends CUserIdentity
{
    private $_id;

    /**
     * Authenticates a user.
     * @return boolean whether authentication succeeds.
     */
    public function authenticate()
    {
        /* @var $user User */
        $user = User::model()->find('LOWER(username)=?', array(strtolower($this->username)));
        if ($user === null)
            $this->errorCode = self::ERROR_USERNAME_INVALID;
        else if (!$user->validatePassword($this->password))
            $this->errorCode = self::ERROR_PASSWORD_INVALID;
        else
        {
            $this->_id = $user->id;
            $this->username = $user->username;
			$auth=Yii::app()->authManager;
			if(!is_null($user->role)){
			    if(!$auth->isAssigned($user->role,$this->_id))
			    {
			        if($auth->assign($user->role,$this->_id))
			        {
			            Yii::app()->authManager->save();
			        }

			    }
			}
            $this->errorCode = self::ERROR_NONE;
        }

        return $this->errorCode == self::ERROR_NONE;
    }

    /**
     * @return integer the ID of the user record
     */
    public function getId()
    {
        return $this->_id;
    }
}


I use database, storing authitems and others...
0

#58 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 23-September 11

Posted 12 April 2013 - 08:22 AM

And another different error, after login (if i use dev version from github):

Property "AuthBehavior.admins" is not defined

it occur both with CPhpAuthManager or CDbAuthManager.

i found that it causes by
'authManager' => array(
			'class'=>'CDbAuthManager', 
			'behaviors' => array(
	        	'auth' => array(
	          		'class' => 'auth.components.AuthBehavior',
					'admins'=>array('authenticated'), // users with full access
	        	),
			),
	    ), 

This post has been edited by almix: 12 April 2013 - 02:31 PM

0

#59 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 12 April 2013 - 12:57 PM

well, as I see, in my config file there are additional settings for auth, for example in modules section:
'modules' => array(
        'auth' => array(
            'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.
            'userClass' => 'Users', // 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.
        ),
        'user' => array(
            'tableUsers' => 'users',
            'tableProfiles' => 'profiles',
            'tableProfileFields' => 'profiles_fields',
        ),

and also this one:
'import' => array(
        'application.models.*',
        'application.components.*',
        'application.modules.user.models.*',
        'application.modules.user.components.*',
        'application.modules.auth.*',
        'application.modules.auth.components.*',
        ...
    ),

do you also have these settings?
0

#60 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 12 April 2013 - 12:59 PM

View Postcappadochian, on 12 April 2013 - 12:57 PM, said:

well, as I see, in my config file there are additional settings for auth, for example in modules section:
'modules' => array(
        'auth' => array(
            'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.
            'userClass' => 'Users', // 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.
        ),
        'user' => array(
            'tableUsers' => 'users',
            'tableProfiles' => 'profiles',
            'tableProfileFields' => 'profiles_fields',
        ),

do you also have these settings?


Thanks cappadochian for your quick responses. But finally i manage to resolve all that errors :)

thanks again. :)
CodeSutra
0

Share this topic:


  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users