Account Locking and Password Expiration Overview
Robert Bîndar
Software Developer @MariaDB Foundation
MariaDB Unconference�New York 23-24 February 2019
2
#define
Account Locking:
Offers the ability to mark an account locked and deny any subsequent connection requests for that account during the authentication stage.
Password Expiration:
A new connection for an account with an expired password is either denied or only allowed to execute SET PASSWORD to change the password (sandbox mode), depending on various server and client settings.
The feature supports expiring passwords with immediate effect, per-account automatic expiration as well as global policies for automatic expiration.
Account Locking and Password Expiration Overview
3
Account Locking and Password Expiration Overview
Motivation
4
Account Locking and Password Expiration Overview
Initial Requirements
5
Account Locking
Account Locking and Password Expiration Overview
6
Account Locking and Password Expiration Overview
Account Locking
MariaDB [(none)]> CREATE USER user@localhost ACCOUNT LOCK;
Query OK, 0 rows affected (0.00 sec)�
7
Account Locking and Password Expiration Overview
Account Locking
MariaDB [(none)]> SHOW CREATE USER user@localhost;
+---------------------------------------------+
| CREATE USER for user@localhost |
+---------------------------------------------+
| CREATE USER 'user'@'localhost' ACCOUNT LOCK |
+---------------------------------------------+
1 row in set (0.000 sec)
8
Account Locking and Password Expiration Overview
Account Locking
MariaDB [(none)]> ALTER USER user@localhost ACCOUNT UNLOCK;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> ALTER USER user@localhost ACCOUNT LOCK;
Query OK, 0 rows affected (0.00 sec)
9
Account Locking and Password Expiration Overview
Account Locking
bindar@computer:~/MariaDB/server$ ./client/mysql -uuser
ERROR 4151 (HY000): Access denied, this account is locked�
10
Whether an account is locked or not is checked during the authentication phase (including COM_CHANGE_USER).
Locking an account does not affect existing connections.
Account Locking and Password Expiration Overview
Account Locking
11
Password Expiration
Account Locking and Password Expiration Overview
12
Account Locking and Password Expiration Overview
Password Expiration
MariaDB [(none)]> CREATE USER user@localhost PASSWORD EXPIRE;
Query OK, 0 rows affected (0.00 sec)�
13
Password Expiration
Disconnect Mode:
In this mode, any new connections for accounts with expired passwords are refused.
Sandbox Mode:
A new connection for an account with the password expired is only allowed to execute SET PASSWORD to change the account password, attempts to execute any other statements are rejected.
Account Locking and Password Expiration Overview
14
clients unaware of the sandbox mode are treated
Account Locking and Password Expiration Overview
Password Expiration
15
statement is allowed for changing the account password
Account Locking and Password Expiration Overview
Password Expiration
$ mysql -u user
Welcome to the MariaDB monitor.
MariaDB [(none)]> SELECT CURRENT_USER;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
MariaDB [(none)]> SET PASSWORD= PASSWORD(‘abc’);
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SELECT CURRENT_USER;
+-----------------+
| CURRENT_USER |
+-----------------+
| user@localhost |
+-----------------+
1 row in set (0.00 sec)
16
Account Locking and Password Expiration Overview
Password Expiration
$ mysql -u user
ERROR 1862 (HY000): Your password has expired. To log in you must change
it using a client that supports expired passwords
17
Account Locking and Password Expiration Overview
Password Expiration
18
Account Locking and Password Expiration Overview
Password Expiration
MariaDB [(none)]> ALTER USER user@localhost PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW CREATE USER user@localhost;
+-------------------------------------------------------+
| CREATE USER for user@localhost |
+-------------------------------------------------------+
| CREATE USER 'user'@'localhost' PASSWORD EXPIRE NEVER |
+-------------------------------------------------------+
1 row in set (0.00 sec)
�
19
Account Locking and Password Expiration Overview
Password Expiration
MariaDB [(none)]> ALTER USER user@localhost PASSWORD EXPIRE INTERVAL 30 DAY;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW CREATE USER user@localhost;
+-----------------------------------------------------------------+
| CREATE USER for user@localhost |
+-----------------------------------------------------------------+
| CREATE USER 'user'@'localhost' PASSWORD EXPIRE INTERVAL 30 DAY |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)
20
Account Locking and Password Expiration Overview
Password Expiration
MariaDB [(none)]> ALTER USER user@localhost PASSWORD EXPIRE DEFAULT;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW CREATE USER user@localhost;
+---------------------------------+
| CREATE USER for user@localhost |
+---------------------------------+
| CREATE USER 'user'@'localhost' |
+---------------------------------+
1 row in set (0.00 sec)
21
Title of the presentation, if necessary shortened
Sponsors
22
Account Locking and Password Expiration Overview