Files
umbrel-apps/guacamole/data/initdb/002-set-guacadmin-password.sql

16 lines
710 B
SQL

-- Runs once, when the database is first created. The schema (generated by the
-- init service as 001-schema.sql) creates guacadmin with the well-known
-- password "guacadmin". Replace it with the per-install Umbrel app password.
-- Guacamole stores SHA-256(password || uppercase hex salt).
\getenv guacadmin_password GUACADMIN_PASSWORD
UPDATE guacamole_user AS u
SET password_salt = s.salt,
password_hash = sha256(convert_to(:'guacadmin_password' || upper(encode(s.salt, 'hex')), 'UTF8')),
password_date = CURRENT_TIMESTAMP
FROM guacamole_entity AS e,
(SELECT sha256(gen_random_uuid()::text::bytea) AS salt) AS s
WHERE u.entity_id = e.entity_id
AND e.name = 'guacadmin'
AND e.type = 'USER';