Bug 55876 - Use scram-sha-256 as default hashing algorithm for postgres (instead of md5)
Use scram-sha-256 as default hashing algorithm for postgres (instead of md5)
Status: NEW
Product: UCS
Classification: Unclassified
Component: PostgreSQL
UCS 5.0
Other Windows NT
: P5 normal (vote)
: ---
Assigned To: UCS maintainers
UCS maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2023-03-14 07:52 CET by Thorsten
Modified: 2023-03-14 15:05 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thorsten univentionstaff 2023-03-14 07:52:21 CET
Switch the default hashing algorithm for postgresql to scram-sha-256. Postgresql itself switches to that default anyway with v14.

For machines that run only self-service this can be achived post-install e.g. using ansible:

```
- name: "enable password_encryption to default to scram-sha-256 in /etc/postgresql/11/main/postgresql.conf"
  ansible.builtin.lineinfile:
    path: "/etc/postgresql/11/main/postgresql.conf"
    regexp: '^#?password_encrption.+'
    line: "password_encryption = scram-sha-256"

- name: "allow only scram-sha-256 for authentication in /etc/postgresql/11/main/pg_hba.conf"
  ansible.builtin.replace:
    path: "/etc/postgresql/11/main/pg_hba.conf"
    regexp: 'md5'
    replace: 'scram-sha-256'

- name: "restart service: postgres"
  ansible.builtin.systemd:
    state: "restarted"
    name: "postgresql"

- name: "update password for selfservice in /etc/self-service-db.secret"
  copy:
    content: "{{ choose_a_new_password_for_selfservice }}"
    dest: "/etc/self-service-db.secret"

- name: "update password for selfservice in database"
  become: true
  become_user: postgres
  shell: psql -c "ALTER USER selfservice WITH PASSWORD '{{ choose_a_new_password_for_selfservice }}'"
```