Skip to content

Conversation

@samdark
Copy link
Member

@samdark samdark commented Nov 13, 2013

It's rarely used in apps other than web and can be set in config if needed.

… in apps other than web and can be set in config if needed
@klimov-paul
Copy link
Member

Disagreed.
It could be a situation, when I need RBAC checks even in console application. Indeed it will unlikely check current user permissions, but it can be used to check permissions for the particular user in the database.

// Some cron script:
$users = User::find()->all();
foreach ($users as $user) {
    if (Yii::$app->authManager->checkAccess($user->id, 'adminNotification')) {
        Yii::$app->mail->... ->send();
    }
}

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 89aa62f on moved-auth-to-web into 0eaafd7 on master.

@ponikrf
Copy link

ponikrf commented Nov 13, 2013

Am... if count users over 9000? superfast realization...
imho you went on the wrong side
And... you can load this component late...

Sorry for my english

@klimov-paul
Copy link
Member

if count users over 9000?

Need to use DataProvider with pagination then. This is a concept example after all.

you can load this component late

I can tell same thing about almost any application component. Following this philosophy we should remove “authManager” even from yii\web\Application, because it could be a web application, which will not use RBAC.

RBAC is not web-specific feature – it is a basic thing, which can be used anywhere, so it should be kept in the base application.

@samdark
Copy link
Member Author

samdark commented Nov 13, 2013

Yes, it can be used in console but it's rare in practice. Nothing prevents you from adding it later via config.

@ponikrf
Copy link

ponikrf commented Nov 13, 2013

Following your logic, anything can be used anywhere.

RBAC is not web-specific feature – it is a basic thing, which can be used anywhere, so it should be kept in the >base application.

Basic application can not exist without RBAC? seriously?

@qiangxue
Copy link
Member

I think it should remain in base application. It's like urlManager. You usually don't directly use it in console, but you often need to work with it (such as maintaining RBAC, generating URLs, etc.)

@samdark
Copy link
Member Author

samdark commented Nov 13, 2013

Makes sense.

@samdark samdark closed this Nov 13, 2013
@ponikrf
Copy link

ponikrf commented Nov 13, 2013

If you add this method to \yii\web\Application and \yii\console\Application and remove from \yii\base\application?
You do not like this practice?

@cebe
Copy link
Member

cebe commented Nov 13, 2013

@ponikrf it would be duplicating code that can be done in one place. so not a good solution.

@cebe cebe deleted the moved-auth-to-web branch November 26, 2013 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants