Skip to content

Commit

Permalink
Add an encrypted password for create and edit roles.pgadmin-org#2646
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Bhati authored and akshay-joshi committed Sep 30, 2024
1 parent 28eb2c0 commit 6a50ef7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
Binary file modified docs/en_US/images/role_definition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/en_US/role_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Click the *Definition* tab to continue.

Use the *Definition* tab to set a password and configure connection rules:

* If enabled, *Encrypted Password?* will consider the password as encrypted and will use ENCRYPTED keyword.
* Provide a password that will be associated with the role in the *Password*
field.
* Provide an expiration date for the password in the *Account Expires* field
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/browser/server_groups/servers/roles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,11 @@ def wrapped(self, **kwargs):
'rolcanlogin', 'rolsuper', 'rolcreatedb',
'rolcreaterole', 'rolinherit', 'rolreplication',
'rolconnlimit', 'rolvaliduntil', 'rolpassword',
'rolbypassrls'
'rolencryptedpassword', 'rolbypassrls'
] if self.manager.version >= 90200 else [
'rolcanlogin', 'rolsuper', 'rolcreatedb',
'rolcreaterole', 'rolinherit', 'rolconnlimit',
'rolvaliduntil', 'rolpassword'
'rolvaliduntil', 'rolpassword', 'rolencryptedpassword'
]

fetch_name, check_permission, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ export default class RoleSchema extends BaseUISchema {
mode: ['properties', 'edit', 'create'],
disabled: obj.readOnly,
},
{
id: 'rolencryptedpassword', label: gettext('Encrypted Password?'), type: 'switch',
group: gettext('Definition'), mode: ['edit', 'create'],
deps: ['rolcanlogin'], disabled: obj.readOnly,
},
{
id: 'rolpassword', label: gettext('Password'), type: 'password',
group: gettext('Definition'), mode: ['edit', 'create'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ CREATE ROLE {{ conn|qtIdent(data.rolname) }} WITH{% if data.rolcanlogin and data

CONNECTION LIMIT {{ data.rolconnlimit }}{% endif %}{% if data.rolvaliduntil and data.rolvaliduntil is not none %}

VALID UNTIL {{ data.rolvaliduntil|qtLiteral(conn) }} {% endif %}{% if data.rolpassword %}

PASSWORD {% if data.rolpassword is none %}NULL{% else %}{% if dummy %}'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral(conn) }}{% endif %}{% endif %}{% endif %};{% if data.members and data.members|length > 0 %}

VALID UNTIL {{ data.rolvaliduntil|qtLiteral(conn) }} {% endif %}{% if data.rolpassword %}{% if data.rolencryptedpassword %}

ENCRYPTED PASSWORD{% else %}

PASSWORD{% endif %}{% if data.rolpassword is none %}NULL{% else %}{% if dummy %}'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral(conn) }}{% endif %}{% endif %}{% endif %};{% if data.members and data.members|length > 0 %}

GRANT {{ conn|qtIdent(data.members)|join(', ') }} TO {{ conn|qtIdent(data.rolname) }};{% endif %}{% if data.admins and data.admins|length > 0 %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ ALTER ROLE {{ conn|qtIdent(rolname) }}{% if 'rolcanlogin' in data %}
{% endif %}{% if 'rolvaliduntil' in data %}

VALID UNTIL {% if data.rolvaliduntil %}{{ data.rolvaliduntil|qtLiteral(conn) }}{% else %}'infinity'
{% endif %}{% endif %}{% if 'rolpassword' in data %}
{% endif %}{% endif %}{% if 'rolpassword' in data %}{% if data.rolencryptedpassword %}

PASSWORD{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral(conn) }}{% endif %}{% endif %}{% endif %};{% endif %}
ENCRYPTED PASSWORD{% else %}

PASSWORD{% endif %}{% if data.rolpassword is none %} NULL{% else %}{% if dummy %} 'xxxxxx'{% else %} {{ data.rolpassword|qtLiteral(conn) }}{% endif %}{% endif %}{% endif %};{% endif %}

{% if 'revoked_admins' in data and
data.revoked_admins|length > 0
Expand Down

0 comments on commit 6a50ef7

Please sign in to comment.