4

I have just set up Guacamole 0.9.9 with a MySQL user database and LDAP authentication and it all works flawlessly so far.

However, I want to be able to create new users and connections in the MySQL database from outside of Guacamole. Is there a way to use the API to perform these tasks?

All I'm reading about the API is creating a new web application which embeds remote connections.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mehrkat
  • 141
  • 1
  • 6

2 Answers2

2

You can use the following MySQL commands in your code to create new users.

SET @salt = UNHEX(SHA2(UUID(), 256));
INSERT INTO guacamole_user (username, password_salt, password_hash, password_date) VALUES ('testuser', @salt, UNHEX(SHA2(CONCAT('testpass', HEX(@salt)), 256)), NOW());
Banafshe Bamdad
  • 509
  • 5
  • 5
1

You can create users with Guacamole REST API.

Firstly you need create a token:

Endpoint:

POST {{baseURL}}/api/tokens

x-www-form-urlencoded:

username: guacadmin
password: guacadmin

Sample Response:

{
    "authToken": "8144B9B1EBAF73E8EDCE08EF5C145F49C1C9F563F13E21BF7A1CEC43E74011A4",
    "username": "guacadmin",
    "dataSource": "postgresql",
    "availableDataSources": [
        "postgresql",
        "postgresql-shared"
    ]
}

After then you can create a user with using the token.

Endpoint:

POST {{baseURL}}/api/session/data/{{dataSource}}/users?token={{authToken}}

Sample Request Body:

{
    "username": "testuser",
    "password": "password",
    "attributes":{
        "disabled":"",
        "expired":"",
        "access-window-start":"",
        "access-window-end":"",
        "valid-from":"",
        "valid-until":"",
        "timezone": ""
    }
}
ridvanaltun
  • 2,595
  • 2
  • 15
  • 28
  • I am not that into REST API and since our server is behind VPN I am stricted to Client based REST API TOOLs. I use httpie in WSL2 Ubuntu and was able to create a Token but have no Idea how second part has to be done. We are running guacamole 1.3 – MaKaNu Oct 21 '21 at 15:32