MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/65294
Change subject: Adding params to permissions errors
......................................................................
Adding params to permissions errors
Permission errors now take parameters, which will help disambiguate when we
allow for multiple project requests.
Change-Id: I5d59bcd592be80ec934937b66d406acad711dc18
---
M OpenStackManager.i18n.php
M api/ApiNovaInstance.php
M special/SpecialNova.php
M special/SpecialNovaAddress.php
M special/SpecialNovaInstance.php
M special/SpecialNovaKey.php
M special/SpecialNovaProject.php
M special/SpecialNovaPuppetGroup.php
M special/SpecialNovaSecurityGroup.php
M special/SpecialNovaSudoer.php
M special/SpecialNovaVolume.php
11 files changed, 73 insertions(+), 65 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager
refs/changes/94/65294/1
diff --git a/OpenStackManager.i18n.php b/OpenStackManager.i18n.php
index 1e2f14e..ec02142 100644
--- a/OpenStackManager.i18n.php
+++ b/OpenStackManager.i18n.php
@@ -58,8 +58,8 @@
'openstackmanager-nonovacred' => 'No Nova credentials found for your
account.',
'openstackmanager-nonovacred-admincreate' => 'There were no Nova
credentials found for your user account.
Please ask a Nova administrator to create credentials for you.',
- 'openstackmanager-noaccount' => 'Your account is not in the project
requested.',
- 'openstackmanager-noaccount2' => 'You can not complete the action
requested as your user account is not in the project requested.',
+ 'openstackmanager-noaccount' => 'Your account is not in the project
$1.',
+ 'openstackmanager-noaccount2' => 'You can not complete the action
requested as your user account is not in the project $1.',
'openstackmanager-nonexistentresource' => 'The specified resource does
not exist.',
'openstackmanager-createdomain' => 'Create domain',
@@ -296,8 +296,8 @@
'openstackmanager-nonexistenthost' => 'The requested host does not
exist.',
'openstackmanager-nonexistentrole' => 'The requested role does not
exist.',
- 'openstackmanager-needrole' => '$1 role required',
- 'openstackmanager-needrole2' => 'You must be a member of the $1 role to
perform this action.',
+ 'openstackmanager-needrole' => '$1 role required in project $2',
+ 'openstackmanager-needrole2' => 'You must be a member of the $1 role in
project $2 to perform this action.',
'openstackmanager-createsecuritygroup' => 'Create security group',
'openstackmanager-securitygroupname' => 'Security group name',
@@ -506,7 +506,11 @@
'openstackmanager-nonovacred' => 'Used as page title in Special:Nova.
The page body for this title is:
-* {{msg-mw|Openstackmanager-nonovacred-admincreate}}',
+* {{msg-mw|Openstackmanager-nonovacred-admincreate}}
+
+Parameters:
+* $1 The name of the project for which the account does not have permissions.',
+
'openstackmanager-nonovacred-admincreate' => 'Used in Special:Nova.
The page title for this message is:
@@ -518,7 +522,11 @@
'openstackmanager-noaccount2' => 'Used as page body in Special:Nova.
The page title for this message is:
-* {{msg-mw|Openstackmanager-noaccount}}',
+* {{msg-mw|Openstackmanager-noaccount}}
+
+Parameters:
+* $1 The name of the project for which the account does not have permissions.
+',
'openstackmanager-nonexistentresource' => 'Used as error message in
Special:NovaPuppetGroup.',
'openstackmanager-createdomain' => 'Page title',
'openstackmanager-deletedomain' => 'Used as page title in
Special:NovaDomain.',
diff --git a/api/ApiNovaInstance.php b/api/ApiNovaInstance.php
index c858ef9..1b9a3b8 100644
--- a/api/ApiNovaInstance.php
+++ b/api/ApiNovaInstance.php
@@ -9,10 +9,10 @@
$this->dieUsageMsg( 'openstackmanager-nonovacred' );
}
if ( ! $this->userLDAP->inProject( $this->params['project'] ) )
{
- $this->dieUsageMsg( 'openstackmanager-noaccount' );
+ $this->dieUsageMsg( 'openstackmanager-noaccount',
$this->params['project'] );
}
if ( ! $this->userLDAP->inRole( 'projectadmin',
$this->params['project'] ) ) {
- $this->dieUsageMsg( 'openstackmanager-needrole' );
+ $this->dieUsageMsg( 'openstackmanager-needrole',
'projectadmin', $this->params['project'] );
}
}
diff --git a/special/SpecialNova.php b/special/SpecialNova.php
index 41fafbe..41027be 100644
--- a/special/SpecialNova.php
+++ b/special/SpecialNova.php
@@ -29,10 +29,10 @@
/**
* @return void
*/
- function notInProject() {
+ function notInProject( $project ) {
$this->setHeaders();
- $this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-noaccount' ) );
- $this->getOutput()->addWikiMsg( 'openstackmanager-noaccount2' );
+ $this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-noaccount', $project ) );
+ $this->getOutput()->addWikiMsg( 'openstackmanager-noaccount2',
$project );
}
/**
@@ -48,10 +48,10 @@
* @param $role
* @return void
*/
- function notInRole( $role ) {
+ function notInRole( $role, $project ) {
$this->setHeaders();
- $this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-needrole', $role ) );
- $this->getOutput()->addWikiMsg( 'openstackmanager-needrole2',
$role );
+ $this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-needrole', $role, $project ) );
+ $this->getOutput()->addWikiMsg( 'openstackmanager-needrole2',
$role, $project );
}
function checkTwoFactor() {
diff --git a/special/SpecialNovaAddress.php b/special/SpecialNovaAddress.php
index 3cfb470..7e218a8 100644
--- a/special/SpecialNovaAddress.php
+++ b/special/SpecialNovaAddress.php
@@ -64,7 +64,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
if ( !$this->getRequest()->wasPosted() ) {
@@ -106,7 +106,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$id = $this->getRequest()->getText( 'id' );
@@ -158,7 +158,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$instances = $this->userNova->getInstances();
@@ -219,7 +219,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$id = $this->getRequest()->getText( 'id' );
@@ -269,7 +269,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$id = $this->getRequest()->getText( 'id' );
@@ -333,7 +333,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$id = $this->getRequest()->getText( 'id' );
diff --git a/special/SpecialNovaInstance.php b/special/SpecialNovaInstance.php
index 5848c7e..fa767be 100644
--- a/special/SpecialNovaInstance.php
+++ b/special/SpecialNovaInstance.php
@@ -51,31 +51,31 @@
if ( $action === "create" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->createInstance();
} elseif ( $action === "delete" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->deleteInstance();
} elseif ( $action === "configure" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->configureInstance();
} elseif ( $action === "reboot" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->rebootInstance();
} elseif ( $action === "consoleoutput" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->getConsoleOutput();
@@ -101,7 +101,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$instanceInfo = array();
@@ -274,7 +274,7 @@
}
if ( !$this->userLDAP->inRole( 'projectadmin',
$instance->getProject() ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin',
$instance->getProject() );
return false;
}
@@ -334,7 +334,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$instanceosid = $this->getRequest()->getText( 'instanceid' );
@@ -394,7 +394,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$instanceosid = $this->getRequest()->getText( 'instanceid' );
@@ -458,7 +458,7 @@
$project = $this->getRequest()->getText( 'project' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return;
}
$consoleOutput = $this->userNova->getConsoleOutput(
$instanceosid );
diff --git a/special/SpecialNovaKey.php b/special/SpecialNovaKey.php
index 015acdf..4184b3d 100644
--- a/special/SpecialNovaKey.php
+++ b/special/SpecialNovaKey.php
@@ -54,7 +54,7 @@
$keyname = $this->getRequest()->getVal( 'keyname' );
$project = $this->getRequest()->getVal( 'project' );
if ( $project && ! $this->userLDAP->inProject( $project
) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return true;
}
$keyInfo['keyname'] = array(
diff --git a/special/SpecialNovaProject.php b/special/SpecialNovaProject.php
index b13cfe4..9e3596d 100644
--- a/special/SpecialNovaProject.php
+++ b/special/SpecialNovaProject.php
@@ -61,7 +61,7 @@
$project = $this->getRequest()->getText( 'projectname' );
if ( !$this->userCanExecute( $this->getUser() ) &&
!$this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$projectInfo = array();
@@ -100,7 +100,7 @@
$projectname = $this->getRequest()->getText( 'projectname' );
if ( !$this->userCanExecute( $this->getUser() ) &&
!$this->userLDAP->inRole( 'projectadmin', $projectname ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $projectname );
return false;
}
$project = OpenStackNovaProject::getProjectByName( $projectname
);
@@ -145,7 +145,7 @@
$project = $this->getRequest()->getText( 'projectname' );
if ( !$this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return false;
}
@@ -185,7 +185,7 @@
$project = $this->getRequest()->getText( 'projectname' );
if ( !$this->userCanExecute( $this->getUser() ) &&
!$this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-removeservicegroup' ) );
@@ -412,7 +412,7 @@
$projectName = $this->getRequest()->getText( 'projectname' );
$this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-configureproject', $projectName ) );
if ( !$this->userCanExecute( $this->getUser() ) &&
!$this->userLDAP->inRole( 'projectadmin', $projectName ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $projectName );
return false;
}
$project = OpenStackNovaProject::getProjectByName( $projectName
);
diff --git a/special/SpecialNovaPuppetGroup.php
b/special/SpecialNovaPuppetGroup.php
index 90c0472..a45b2f3 100644
--- a/special/SpecialNovaPuppetGroup.php
+++ b/special/SpecialNovaPuppetGroup.php
@@ -62,7 +62,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -117,7 +117,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -176,7 +176,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -226,7 +226,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -286,7 +286,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -338,7 +338,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -391,7 +391,7 @@
}
$project = $newgroup->getProject();
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
}
@@ -403,7 +403,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -467,7 +467,7 @@
}
$project = $newgroup->getProject();
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
}
@@ -480,7 +480,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
@@ -542,7 +542,7 @@
if ( $project ) {
// Project specific
if ( ! $this->userLDAP->inRole( 'projectadmin',
$project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
} else {
diff --git a/special/SpecialNovaSecurityGroup.php
b/special/SpecialNovaSecurityGroup.php
index a52c650..f9af2b9 100644
--- a/special/SpecialNovaSecurityGroup.php
+++ b/special/SpecialNovaSecurityGroup.php
@@ -64,7 +64,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$securityGroupInfo = array();
@@ -116,7 +116,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$securitygroupid = $this->getRequest()->getText( 'groupid' );
@@ -291,7 +291,7 @@
$groupid = $this->getRequest()->getText( 'groupid' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$securitygroup = $this->userNova->getSecurityGroup( $groupid );
@@ -385,7 +385,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$groupid = $this->getRequest()->getText( 'groupid' );
diff --git a/special/SpecialNovaSudoer.php b/special/SpecialNovaSudoer.php
index 44494f6..941299a 100644
--- a/special/SpecialNovaSudoer.php
+++ b/special/SpecialNovaSudoer.php
@@ -31,19 +31,19 @@
$this->project = OpenStackNovaProject::getProjectByName(
$this->projectName );
if ( $action === "create" ) {
if ( ! $this->userLDAP->inProject( $this->projectName )
) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->createSudoer();
} elseif ( $action === "delete" ) {
if ( ! $this->userLDAP->inProject( $this->projectName )
) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->deleteSudoer();
} elseif ( $action === "modify" ) {
if ( ! $this->userLDAP->inProject( $this->projectName )
) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->modifySudoer();
@@ -59,7 +59,7 @@
$this->setHeaders();
$this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-modifysudoer' ) );
if ( ! $this->userLDAP->inRole( 'projectadmin',
$this->projectName ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $this->projectName );
return false;
}
@@ -146,7 +146,7 @@
$this->setHeaders();
$this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-deletesudoer' ) );
if ( ! $this->userLDAP->inRole( 'projectadmin',
$this->projectName ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $this->projectName );
return false;
}
$sudoername = $this->getRequest()->getText( 'sudoername' );
@@ -185,7 +185,7 @@
$this->setHeaders();
$this->getOutput()->setPagetitle( $this->msg(
'openstackmanager-modifysudoer' ) );
if ( ! $this->userLDAP->inRole( 'projectadmin',
$this->projectName ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $this->projectName );
return false;
}
$sudoername = $this->getRequest()->getText( 'sudoername' );
diff --git a/special/SpecialNovaVolume.php b/special/SpecialNovaVolume.php
index 1b5853f..234c6c4 100644
--- a/special/SpecialNovaVolume.php
+++ b/special/SpecialNovaVolume.php
@@ -43,25 +43,25 @@
if ( $action === "create" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->createVolume();
} elseif ( $action === "delete" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->deleteVolume();
} elseif ( $action === "attach" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->attachVolume();
} elseif ( $action === "detach" ) {
if ( ! $this->userLDAP->inProject( $project ) ) {
- $this->notInProject();
+ $this->notInProject( $project );
return;
}
$this->detachVolume();
@@ -80,7 +80,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$volumeInfo = array();
@@ -140,7 +140,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$volumeid = $this->getRequest()->getText( 'volumeid' );
@@ -187,7 +187,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$instances = $this->userNova->getInstances();
@@ -266,7 +266,7 @@
$project = $this->getRequest()->getText( 'project' );
$region = $this->getRequest()->getText( 'region' );
if ( ! $this->userLDAP->inRole( 'projectadmin', $project ) ) {
- $this->notInRole( 'projectadmin' );
+ $this->notInRole( 'projectadmin', $project );
return false;
}
$volumeInfo = array();
--
To view, visit https://gerrit.wikimedia.org/r/65294
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d59bcd592be80ec934937b66d406acad711dc18
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits