Skip to content

Commit 75dbced

Browse files
Fix review comments
1 parent 2699acb commit 75dbced

File tree

47 files changed

+264
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+264
-130
lines changed

docs/en_US/user_management.rst

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ dialog where you can fill in details for the new role.
102102

103103
Provide information about the new pgAdmin role in the row:
104104

105-
* Use the *Role Name* field to specify a unique name for the role.
105+
* Use the *Name* field to specify a unique name for the role.
106106
* Use the *Description* field to provide a brief description of the role.
107107

108108
To delete a role, click the trash icon to the left of the row and confirm deletion
@@ -162,10 +162,11 @@ email and password. role and active will be optional fields.
162162
163163
/path/to/python /path/to/setup.py add-user user1@gmail.com password
164164
165-
# to specify a role, admin and non-admin users:
165+
# to specify a role, either you can use --admin for Administrator role or provide the
166+
# role using --role. If both are provided --admin will be used:
166167
167168
/path/to/python /path/to/setup.py add-user user1@gmail.com password --admin
168-
/path/to/python /path/to/setup.py add-user user1@gmail.com password --nonadmin
169+
/path/to/python /path/to/setup.py add-user user1@gmail.com password --role Users
169170
170171
# to specify user's status
171172
@@ -186,10 +187,11 @@ followed by email, password and authentication source. email, role and status wi
186187
187188
/path/to/python /path/to/setup.py add-external-user ldapuser ldap --email user1@gmail.com
188189
189-
# to specify a role, admin and non-admin user:
190+
# to specify a role, either you can use --admin for Administrator role or provide the
191+
# role using --role. If both are provided --admin will be used:
190192
191193
/path/to/python /path/to/setup.py add-external-user ldapuser ldap --admin
192-
/path/to/python /path/to/setup.py add-external-user ldapuser ldap --nonadmin
194+
/path/to/python /path/to/setup.py add-external-user ldapuser ldap --role Users
193195
194196
# to specify user's status
195197
@@ -206,10 +208,11 @@ email address. password, role and active are updatable fields.
206208
207209
/path/to/python /path/to/setup.py update-user user1@gmail.com --password new-password
208210
209-
# to specify a role, admin and non-admin user:
211+
# to specify a role, either you can use --admin for Administrator role or provide the
212+
# role using --role. If both are provided --admin will be used:
210213
211-
/path/to/python /path/to/setup.py update-user user1@gmail.com password --role --admin
212-
/path/to/python /path/to/setup.py update-user user1@gmail.com password --role --nonadmin
214+
/path/to/python /path/to/setup.py update-user user1@gmail.com password --admin
215+
/path/to/python /path/to/setup.py update-user user1@gmail.com password --role Users
213216
214217
# to specify user's status
215218
@@ -226,17 +229,18 @@ followed by username and auth source. email, password, role and active are updat
226229
227230
# to change email address:
228231
229-
/path/to/python /path/to/setup.py update-external-user ldap ldapuser --email newemail@gmail.com
232+
/path/to/python /path/to/setup.py update-external-user ldapuser --auth-source ldap --email newemail@gmail.com
230233
231-
# to specify a role, admin and non-admin user:
234+
# to specify a role, either you can use --admin for Administrator role or provide the
235+
# role using --role. If both are provided --admin will be used:
232236
233-
/path/to/python /path/to/setup.py update-user user1@gmail.com password --role --admin
234-
/path/to/python /path/to/setup.py update-user user1@gmail.com password --role --nonadmin
237+
/path/to/python /path/to/setup.py update-external-user user1@gmail.com password --role --admin
238+
/path/to/python /path/to/setup.py update-external-user user1@gmail.com password --role --role Users
235239
236240
# to change user's status
237241
238-
/path/to/python /path/to/setup.py update-user ldap ldapuser --active
239-
/path/to/python /path/to/setup.py update-user ldap ldapuser --inactive
242+
/path/to/python /path/to/setup.py update-user ldapuser --auth-source ldap --active
243+
/path/to/python /path/to/setup.py update-user ldapuser --auth-source ldap --inactive
240244
241245
Delete User
242246
***********

web/migrations/versions/1f0eddc8fc79_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def upgrade():
3939
meta.reflect(op.get_bind(), only=('role',))
4040
role_table = sa.Table('role', meta)
4141

42-
from pgadmin.tools.user_management.PgPermissions import AllPermissionTypes
42+
from pgadmin.tools.user_management.PgAdminPermissions import AllPermissionTypes
4343
op.execute(
4444
role_table.update().where(role_table.c.name == 'User')
45-
.values(permissions=",".join(AllPermissionTypes.__dict__.keys())))
45+
.values(permissions=",".join(AllPermissionTypes.list())))
4646

4747

4848
def downgrade():

web/pgadmin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def get_locale():
350350
(gettext("Incorrect username or password."), "error")
351351
app.config['SECURITY_PASSWORD_LENGTH_MIN'] = config.PASSWORD_LENGTH_MIN
352352
app.config['SECURITY_MSG_UNAUTHORIZED'] = \
353-
(gettext("You do not have permission to this resource."), "error")
353+
(gettext("Unauthorised access, permission denied."), "error")
354354

355355
# Create database connection object and mailer
356356
db.init_app(app)

web/pgadmin/browser/server_groups/servers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from pgadmin.utils.crypto import encrypt, decrypt, pqencryptpassword
2525
from pgadmin.utils.menu import MenuItem
2626
from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
27-
from pgadmin.tools.user_management.PgPermissions import AllPermissionTypes
27+
from pgadmin.tools.user_management.PgAdminPermissions import AllPermissionTypes
2828

2929
import config
3030
from config import PG_DEFAULT_DRIVER

web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import PGSchema from './schema.ui';
1111
import { getNodePrivilegeRoleSchema } from '../../../../static/js/privilege.ui';
1212
import { getNodeListByName } from '../../../../../../static/js/node_ajax';
13+
import { AllPermissionTypes } from '../../../../../../static/js/constants';
1314

1415
define('pgadmin.node.schema', [
1516
'sources/gettext', 'sources/url_for',
@@ -64,7 +65,8 @@ define('pgadmin.node.schema', [
6465
},{
6566
name: 'generate_erd', node: 'schema', module: this,
6667
applies: ['object', 'context'], callback: 'generate_erd',
67-
priority: 5, label: gettext('ERD For Schema')
68+
priority: 5, label: gettext('ERD For Schema'),
69+
permission: AllPermissionTypes.TOOLS_ERD_TOOL,
6870
}]);
6971
},
7072
can_create_schema: function(node) {

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { getNodeTableSchema } from './table.ui';
1010
import _ from 'lodash';
1111
import getApiInstance from '../../../../../../../../static/js/api_instance';
12+
import { AllPermissionTypes } from '../../../../../../../static/js/constants';
1213

1314
define('pgadmin.node.table', [
1415
'pgadmin.tables.js/enable_disable_triggers',
@@ -127,7 +128,8 @@ define('pgadmin.node.table', [
127128
priority: 5, label: gettext('ERD For Table'),
128129
enable: (_, item) => {
129130
return !('catalog' in pgAdmin.Browser.tree.getTreeNodeHierarchy(item));
130-
}
131+
},
132+
permission: AllPermissionTypes.TOOLS_ERD_TOOL,
131133
}
132134
]);
133135
pgBrowser.Events.on(

web/pgadmin/browser/server_groups/servers/databases/static/js/database.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import DatabaseSchema from './database.ui';
1414
import { showServerPassword } from '../../../../../../static/js/Dialogs/index';
1515
import _ from 'lodash';
1616
import getApiInstance, { parseApiError } from '../../../../../../static/js/api_instance';
17+
import { AllPermissionTypes } from '../../../../../static/js/constants';
1718

1819
define('pgadmin.node.database', [
1920
'sources/gettext', 'sources/url_for',
@@ -122,7 +123,8 @@ define('pgadmin.node.database', [
122123
priority: 5, label: gettext('ERD For Database'),
123124
enable: (node) => {
124125
return node.allowConn;
125-
}
126+
},
127+
permission: AllPermissionTypes.TOOLS_ERD_TOOL,
126128
}]);
127129

128130
_.bindAll(this, 'connection_lost');

web/pgadmin/browser/server_groups/servers/static/js/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import ServerSchema from './server.ui';
1212
import { showServerPassword, showChangeServerPassword, showNamedRestorePoint } from '../../../../../static/js/Dialogs/index';
1313
import _ from 'lodash';
1414
import getApiInstance, { parseApiError } from '../../../../../static/js/api_instance';
15+
import { AllPermissionTypes } from '../../../../static/js/constants';
1516

1617
define('pgadmin.node.server', [
1718
'sources/gettext', 'sources/url_for',
@@ -81,7 +82,7 @@ define('pgadmin.node.server', [
8182
name: 'create_server_on_sg', node: 'server_group', module: this,
8283
applies: ['object', 'context'], callback: 'show_obj_properties',
8384
category: 'register', priority: 1, label: gettext('Server...'),
84-
data: {action: 'create'}, enable: 'canCreate', permission: 'object_register_server'
85+
data: {action: 'create'}, enable: 'canCreate', permission: AllPermissionTypes.OBJECT_REGISTER_SERVER
8586
},{
8687
name: 'disconnect_all_servers', node: 'server_group', module: this,
8788
applies: ['object','context'], callback: 'disconnect_all_servers',
@@ -91,7 +92,7 @@ define('pgadmin.node.server', [
9192
name: 'create_server', node: 'server', module: this,
9293
applies: ['object', 'context'], callback: 'show_obj_properties',
9394
category: 'register', priority: 3, label: gettext('Server...'),
94-
data: {action: 'create'}, enable: 'canCreate', permission: 'object_register_server'
95+
data: {action: 'create'}, enable: 'canCreate', permission: AllPermissionTypes.OBJECT_REGISTER_SERVER
9596
},{
9697
name: 'connect_server', node: 'server', module: this,
9798
applies: ['object', 'context'], callback: 'connect_server',
@@ -167,7 +168,7 @@ define('pgadmin.node.server', [
167168
name: 'copy_server', node: 'server', module: this,
168169
applies: ['object', 'context'], callback: 'show_obj_properties',
169170
label: gettext('Copy Server...'), data: {action: 'copy'},
170-
priority: 4,
171+
priority: 4, permission: AllPermissionTypes.OBJECT_REGISTER_SERVER,
171172
}]);
172173

173174
_.bindAll(this, 'connection_lost');

web/pgadmin/browser/static/js/collection.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88
//////////////////////////////////////////////////////////////
99
import _ from 'lodash';
10+
import { AllPermissionTypes } from './constants';
1011

1112
define([
1213
'sources/gettext', 'sources/pgadmin',
@@ -53,13 +54,15 @@ define([
5354
name: 'show_query_tool', node: this.type, module: this,
5455
applies: ['context'], callback: 'show_query_tool',
5556
priority: 998, label: gettext('Query Tool'),
57+
permission: AllPermissionTypes.TOOLS_QUERY_TOOL,
5658
}]);
5759

5860
// show search objects same as query tool
5961
pgAdmin.Browser.add_menus([{
6062
name: 'search_objects', node: this.type, module: this,
6163
applies: ['context'], callback: 'show_search_objects',
6264
priority: 997, label: gettext('Search Objects...'),
65+
permission: AllPermissionTypes.TOOLS_SEARCH_OBJECTS,
6366
}]);
6467

6568
// show psql tool same as query tool.
@@ -68,6 +71,7 @@ define([
6871
name: 'show_psql_tool', node: this.type, module: this,
6972
applies: ['context'], callback: 'show_psql_tool',
7073
priority: 998, label: gettext('PSQL Tool'),
74+
permission: AllPermissionTypes.TOOLS_PSQL_TOOL,
7175
}]);
7276
}
7377
}

web/pgadmin/browser/static/js/constants.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,21 @@ export const WEEKDAYS = [
116116
];
117117

118118
export const PGAGENT_MONTHDAYS = [...MONTHDAYS].concat([{label: gettext('Last day'), value: 'Last Day'}]);
119+
120+
export const AllPermissionTypes = {
121+
OBJECT_REGISTER_SERVER: 'object_register_server',
122+
TOOLS_ERD_TOOL: 'tools_erd_tool',
123+
TOOLS_QUERY_TOOL: 'tools_query_tool',
124+
TOOLS_DEBUGGER: 'tools_debugger',
125+
TOOLS_PSQL_TOOL: 'tools_psql_tool',
126+
TOOLS_BACKUP: 'tools_backup',
127+
TOOLS_RESTORE: 'tools_restore',
128+
TOOLS_IMPORT_EXPORT_DATA: 'tools_import_export_data',
129+
TOOLS_IMPORT_EXPORT_SERVERS: 'tools_import_export_servers',
130+
TOOLS_SEARCH_OBJECTS: 'tools_search_objects',
131+
TOOLS_MAINTENANCE: 'tools_maintenance',
132+
TOOLS_SCHEMA_DIFF: 'tools_schema_diff',
133+
TOOLS_GRANT_WIZARD: 'tools_grant_wizard',
134+
STORAGE_ADD_FOLDER: 'storage_add_folder',
135+
STORAGE_REMOVE_FOLDER: 'storage_remove_folder'
136+
};

0 commit comments

Comments
 (0)