aiden0z / guacamole-auth-jwt

Guacamole authentication extension based on JWT.
MIT License
35 stars 9 forks source link

Need more details of second step please #1

Closed 0000sir closed 7 years ago

0000sir commented 7 years ago

Thank you for your work, It seems like the only working extension of on-the-fly configuration.

I have the first step works well, got tokens from the server, but I don't know how to make the second step work.

Use flowing parameters to initialize the websocket connection to guacamole tunnel endpoint /websocket-tunnel.

Can you give more details about this? any instructions or codes could be a great help, thank you.

I noticed the url /#/client/xxxx?xxx were used in some old hmac extensions, that won't work anymore?

Thank you.

0000sir commented 7 years ago

I think I've figured this out, thank you.

<html>
<head>
<title>Guaca</title>
</head>
    <body>

        <!-- Guacamole -->
        <script type="text/javascript"
            src="guacamole-common-js/all.min.js"></script>

        <!-- Display -->
        <div id="display"></div>

        <!-- Init -->
        <script type="text/javascript"> /* <![CDATA[ */

            // Get display div from document
            var display = document.getElementById("display");

            // Instantiate client, using an HTTP tunnel for communications.
            //var guac = new Guacamole.Client(new Guacamole.HTTPTunnel("tunnel"));
            var guac = new Guacamole.Client(new Guacamole.WebSocketTunnel("ws://127.0.0.1:8080/guacamole-0.9.10-incubating/websocket-tunnel"));

            // Add client to display div
            display.appendChild(guac.getDisplay().getElement());

            // Error handler
            guac.onerror = function(error) {
                alert(error);
            };

            // Connect
            guac.connect('GUAC_ID=123&GUAC_TYPE=c&GUAC_DATA_SOURCE=hmac&token=4530D26714A0A3D88EE37FACDC59E362838BD509D0CD143792C06C9FA95EDFC2');

            // Disconnect on close
            window.onunload = function() {
                guac.disconnect();
            }

            // Mouse
            var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());

            mouse.onmousedown =
            mouse.onmouseup   =
            mouse.onmousemove = function(mouseState) {
                guac.sendMouseState(mouseState);
            };

            // Keyboard
            var keyboard = new Guacamole.Keyboard(document);

            keyboard.onkeydown = function (keysym) {
                guac.sendKeyEvent(1, keysym);
            };

            keyboard.onkeyup = function (keysym) {
                guac.sendKeyEvent(0, keysym);
            };

        /* ]]> */ </script>

    </body>
</html>