keystone/keystone
Dave Wilde (d34dh0r53) 7852ca24a4 Force algo specific maximum length & Properly trimm bcrypt hashed passwords
This is the squash of 2 patches related to bcrypt hashing settings.

1.
Force algo specific maximum length

The bcrypt algorithm that we use for password hashing silently
length limits the size of the password that is hashed giving the
user a false sense of security [0].  This patch adds a check
in the verify_length_and_trunc_password function for the hash in
use and updates the max_length accordingly, this will override
the configured value and log a warning if the password is truncated.

Conflicts:
* tox.ini

[0]: https://passlib.readthedocs.io/en/stable/lib/passlib.hash.bcrypt.html#security-issues

2.
Properly trimm bcrypt hashed passwords

bcrypt  hashing algorythm has a limitation on length of passwords it
can hash on 72 bytes. In [1] a password trimm to 54 symbols has been
implemented, which resulted in password being invalidated after the
keystone upgrade, since passwords are trimmed differently by bcrypt
itself, as well as len(str()) is not always equal to
len(str().encode()) as trimming should be done based on bytes and not
string itself.

With the change we return a byte object from
`verify_length_and_trunc_password`, so it does not need to
be encoded afterwards, since we need to strip based on bytes
rather then on length of the string.

[1] https://review.opendev.org/c/openstack/keystone/+/828595

Closes-Bug: #2028809
Related-Bug: #1901891
original change id: Iea95a3c2df041a0046647b3d3dadead1a6d054d1
(cherry picked from commit 6730c761d1)
(cherry picked from commit 65f1fb6b4a)

Closes-bug: #1901891
Change-Id: I8d0bb2438b23227b5a66b94af6f8e198084fcd8d
(cherry picked from commit 3288af579d)
(cherry picked from commit 1b3536a7a4)
2023-08-22 15:07:05 +02:00
..
api Fix host:port handling 2022-09-08 13:43:07 +02:00
application_credential Update hacking for Python3 2020-04-15 07:17:58 +02:00
assignment Merge "Delete system role assignments from system_assignment table" 2020-10-30 21:16:38 +00:00
auth Add expiring user group memberships on mapped authentication 2020-04-07 19:30:57 -04:00
catalog Remove six usage 2020-01-30 06:06:51 +00:00
cmd sql: Prepare for alembic migration 2022-02-04 19:23:05 +00:00
common Force algo specific maximum length & Properly trimm bcrypt hashed passwords 2023-08-22 15:07:05 +02:00
conf Force algo specific maximum length & Properly trimm bcrypt hashed passwords 2023-08-22 15:07:05 +02:00
credential Merge "Properly instantiate FernetUtils" 2022-02-17 18:15:40 +00:00
endpoint_policy Remove six usage 2020-01-30 06:06:51 +00:00
federation Add support for pysaml2 >= 7.1.0 2022-01-05 18:29:07 +00:00
identity [PooledLDAPHandler] Ensure result3() invokes message.clean() 2023-02-24 07:08:05 +00:00
limit Remove six usage 2020-01-30 06:06:51 +00:00
locale Imported Translations from Zanata 2021-01-09 06:47:38 +00:00
models fix E225 missing whitespace around operator 2020-11-27 13:21:26 +01:00
oauth1 Stop to use the __future__ module. 2020-06-02 20:20:37 +02:00
policy Remove six usage 2020-01-30 06:06:51 +00:00
receipt Remove six usage 2020-01-30 06:06:51 +00:00
resource Update hacking for Python3 2020-04-15 07:17:58 +02:00
revoke Remove six usage 2020-01-30 06:06:51 +00:00
server Merge "Stop to use the __future__ module." 2020-07-31 08:42:30 +00:00
tests Force algo specific maximum length & Properly trimm bcrypt hashed passwords 2023-08-22 15:07:05 +02:00
token Limit token expiration to application credential expiration 2022-10-30 02:27:25 +00:00
trust Improve performance on trust deletion 2021-09-02 15:18:29 +02:00
__init__.py Revert "Disable eventlet monkey-patching of DNS" 2013-05-10 10:24:48 -04:00
exception.py New config option 'user_limit' in credentials 2020-06-12 13:52:45 +05:30
i18n.py Fix translated response 2019-08-19 14:49:37 +08:00
notifications.py Hide AccountLocked exception from end users 2021-04-23 13:43:42 -05:00
version.py Add expiring user group memberships on mapped authentication 2020-04-07 19:30:57 -04:00