Reputation: 161
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.
Upvotes: 4
Views: 5496
Reputation: 3020
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": ""
}
}
Upvotes: 1
Reputation: 529
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());
Upvotes: 2