I made some further analyzing of the sources in order to understand the
structur of a plugin..
The nearest extension I could find was guacamole-history-recording-storage.
I took this as starting point and created a
classProxmoxAuthenticationProviderextendsAbstractAuthenticationProvider
As shown in the extension I made a function call to decorate:
publicUserContextdecorate(UserContextcontext,
AuthenticatedUserauthenticatedUser, Credentialscredentials)
throwsGuacamoleException{
returnnewProxmoxUserContext(context.self(), context);
}
That got to the classProxmoxUserContextextendsTokenInjectingUserContext
privatestaticfinalLoggerlogger=LoggerFactory.getLogger(ProxmoxUserContext.class);
publicProxmoxUserContext(UsercurrentUser, UserContextcontext) {
super(context);
this.currentUser=currentUser;
logger.warn("ProxmoxUserContext() ");
}
I got this to compile as a .jar file and included it into Guacamole.
Getting the log, I saw that this plugin is loaded: "INFO
o.a.g.extension.ExtensionModule - Extension "Proxmox machine
start/stop" (proxmox) loaded."
I was expecting that my logger message would be shown at some point.
When would this extension be called?
Do I need to use a different extends class?
Inside of the class ProxmoxUserContext the next step would be to
integrate the
publicDirectory<Connection> getConnectionDirectory()
throwsGuacamoleException{
returnnewDecoratingDirectory<Connection>(super.getConnectionDirectory())
from the HistoryUserContext.java.
Would this be the right approach? I'm still quite unshure if that's the
right way for the injection.
Thanks!
Am 18.11.23 um 01:01 schrieb Michael Jumper:
On 11/17/2023 1:18 PM, Kai wrote:
Hello,
I came across Guacamole some days ago and I'm quite impressed about
how quick I got an example running.
Originally, I was planning on doing some connections to virtual
machines behind a gateway by using a remote desktop client with some
scripts, but the web solution can be more convenient.
As virtualization I use Proxmox and I have some dedicated VMs only
running some old software without internet.
They also shouldn't be running all the time for power and performance
reasons.
I'm connecting to them by RDP and also tried this in Guacamole.
I currently use some easy scripts to startup and suspend the machines
before and after a RDP session.
What could be the best way for me to integrate running some
additional script? I looked at the wake-on-lan as example.
I saw that the client web application only collects these information
and the server application does the waiting and sending within C code.
As I can easily control the Proxmox VMs by using the Proxmox Rest
API, I only plan to integrate some http requests before showing the
RDP and after closing it. My idea was to integrate these requests
somewhere in the client web application, but I didn't see a good way,
yet.
Are there suggestions what position would be best?
You can hook into the connection process for any connection by
leveraging decoration to wrap the connection objects returned by other
extensions:
https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#decorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials)
https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/AuthenticationProvider.html#redecorate(org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.UserContext,org.apache.guacamole.net.auth.AuthenticatedUser,org.apache.guacamole.net.auth.Credentials)
Wrapping a Connection and its connect() implementation will allow you
to hook in before a connection is established, while overriding the
close() function of the returned GuacamoleTunnel will allow you to
hook into when the connection is closed down. You just need to make
sure that your implementation correctly *unwraps* any wrapped objects
before they are passed to Directory functions like update(), as
implementations may expect to receive objects of the same type that
they returned via a previous call to get(). You can use
DecoratingDirectory to make this much easier to do correctly:
https://guacamole.apache.org/doc/guacamole-ext/org/apache/guacamole/net/auth/DecoratingDirectory.html
It is also possible to inject arbitrary connection attributes at the
UserContext level such that administrators are presented with
additional configuration options when creating/updating a connection,
if that's something you're looking to do.
- Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@guacamole.apache.org
For additional commands, e-mail: user-h...@guacamole.apache.org