title: Apache guacamole create user using postgres
body: <p>Im using apache guacamole latest from docker hub and postgres 12  as database,
  I want to create a login user using postgres but its not working.</p>
  
  <p>This is how to create user from docs:</p>
  
  <pre><code>-- Generate salt
  SET @salt = UNHEX(SHA2(UUID(), 256));
  
  -- Create user and hash password with salt
  INSERT INTO guacamole_user (username, password_salt, password_hash)
       VALUES ('myuser', @salt, UNHEX(SHA2(CONCAT('mypassword', HEX(@salt)), 256)));
  </code></pre>
  
  <p>But here the first command gives me an error : </p>
  
  <pre><code>guacamole_db=# SET @salt = UNHEX(SHA2(UUID(), 256));
  ERROR:  syntax error at or near "@"
  LINE 1: SET @salt = UNHEX(SHA2(UUID(), 256));
              ^
  </code></pre>
  
  <p>From docs this is how they created the defult user in postgres: "guacadmin"</p>
  
  <pre><code>INSERT INTO guacamole_entity (name, type) VALUES ('guacadmin', 'USER');
  INSERT INTO guacamole_user (entity_id, password_hash, password_salt, password_date)
  SELECT
      entity_id,
      decode('CA458A7D494E3BE824F5E1E175A1556C0F8EEF2C2D7DF3633BEC4A29C4411960', 'hex'),  -- 'guacadmin'
      decode('FE24ADC5E11E2B25288D1704ABE67A79E342ECC26064CE69C5B3177795A82264', 'hex'),
      CURRENT_TIMESTAMP
  FROM guacamole_entity WHERE name = 'guacadmin' AND guacamole_entity.type = 'USER';
  
  -- Grant admin permission to read/update/administer self
  INSERT INTO guacamole_user_permission (entity_id, affected_user_id, permission)
  SELECT guacamole_entity.entity_id, guacamole_user.user_id, permission::guacamole_object_permission_type
  FROM (
      VALUES
          ('guacadmin', 'guacadmin', 'READ'),
          ('guacadmin', 'guacadmin', 'UPDATE'),
          ('guacadmin', 'guacadmin', 'ADMINISTER')
  ) permissions (username, affected_username, permission)
  JOIN guacamole_entity          ON permissions.username = guacamole_entity.name AND guacamole_entity.type = 'USER'
  JOIN guacamole_entity affected ON permissions.affected_username = affected.name AND guacamole_entity.type = 'USER'
  JOIN guacamole_user            ON guacamole_user.entity_id = affected.entity_id;
  </code></pre>
  
  <p>How can i translate this to create new user, "test" with password "123456" and only READ premmision?</p>
  
  <p>this is how the related tables looks like :</p>
  
  <p><strong>guacamole_entity :</strong></p>
  
  <pre><code> entity_id |   name    | type
  -----------+-----------+------
           1 | guacadmin | USER
  </code></pre>
  
  <p><strong>guacamole_user:</strong></p>
  
  <pre><code> user_id | entity_id |                           password_hash                            |                           password_salt                            |        pass
  word_date         | disabled | expired | access_window_start | access_window_end | valid_from | valid_until | timezone | full_name | email_address | organization | organiza
  tional_role
  ---------+-----------+--------------------------------------------------------------------+--------------------------------------------------------------------+------------
  ------------------+----------+---------+---------------------+-------------------+------------+-------------+----------+-----------+---------------+--------------+---------
  ------------
         1 |         1 | \xca458a7d494e3be824f5e1e175a1556c0f8eef2c2d7df3633bec4a29c4411960 | \xfe24adc5e11e2b25288d1704abe67a79e342ecc26064ce69c5b3177795a82264 | 2020-01-13
  09:10:56.73947+00 | f        | f       |                     |                   |            |             |          |           |               |              |
  </code></pre>
  
  <p><strong>guacamole_user_permission :</strong></p>
  
  <pre><code> entity_id | affected_user_id | permission
  -----------+------------------+------------
           1 |                1 | READ
           1 |                1 | UPDATE
           1 |                1 | ADMINISTER
  </code></pre>