Skip to content

Commit

Permalink
feat: upgrade to support guacamole 1.5.4 and add a example react app
Browse files Browse the repository at this point in the history
  • Loading branch information
aiden0z committed Mar 21, 2024
1 parent 71e02a3 commit 08a7b13
Show file tree
Hide file tree
Showing 23 changed files with 4,817 additions and 2,997 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ yarn-error.log*
# data dir
example-app/data/
example-app/init/
example-app/guacamole/lib
example-app/guacamole/extensions
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,45 @@

## Description

This project is a plugin for [Guacamole](http://guac-dev.org), an HTML5 based
remote desktop solution supporting VNC/RFB, RDP, and SSH.
This project is a plugin for [Guacamole](http://guac-dev.org), an HTML5 based remote desktop solution supporting VNC/RFB, RDP, and SSH.

This plugin is an [authentication provider](http://guacamole.incubator.apache.org/doc/gug/custom-auth.html) that enables stateless, on-the-fly
configuration of remote desktop connections that are authorized using [JSON WEB TOKEN](https://jwt.io/).
This plugin is an [authentication provider](http://guacamole.incubator.apache.org/doc/gug/custom-auth.html) that enables stateless, on-the-fly configuration of remote desktop connections that are authorized using [JSON WEB TOKEN](https://jwt.io/).

## Deployment & Configuration
## Deployment

* [deploy guacamole extension](http://guacamole.incubator.apache.org/doc/gug/configuring-guacamole.html)
* [custom authentication](http://guacamole.incubator.apache.org/doc/gug/custom-auth.html)

`guacamole-auth-jwt` adds a config keys to `guacamole.properties`:
You should also download all the following dependent jars into the [GUACAMOLE_HOME/lib](https://guacamole.apache.org/doc/gug/configuring-guacamole.html#guacamole-home).

* jackson-annotations-2.12.7.jar
* jackson-core-2.12.7.jar
* jackson-databind-2.12.7.1.jar
* jjwt-api-0.12.5.jar
* jjwt-impl-0.12.5.jar
* jjwt-jackson-0.12.5.jar

## Configuration

Add the JWT secret key to `guacamole.properties` file:

* `secret-key` - The key that will be used to verify the jwt signature.

example

```properties
# jwt secret key for guacamole jwt auth plugin
secret-key: your-complex-secret-length-must-at-least-256-bits
```

## Usage

### First
### Example App

You can use the [example app](./example-app) to learn how to use this plugin.


### Create JWT using Python

Use flowing parameters as the payload of the jwt to get auth token from the rest api `/api/tokens` of guacamole web server.

Expand Down Expand Up @@ -66,8 +87,6 @@ The json response from `/api/tokens` like:
}
```

### Second

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

* `GUAC_ID` - A connection ID specified in first step;
Expand All @@ -83,12 +102,16 @@ Use flowing parameters to initialize the websocket connection to guacamole tunne

## Release

### Version 1.5.2
* Support Guacamole 1.5.2
* Support send JWT via HTTP header
### Version 1.5.3

* Support Guacamole 1.5.3.
* Additionally, support send JWT via HTTP header `Guacamole-Auth-Jwt` to get the Guacamole Authorization Token.
* Add a [react example app](./example-app) to show how to use guacamole-auth-jwt.

### History Versions

Version number will be same with guacamole start from 0.9.14.

* [Version 0.9.14](https://github.com/aiden0z/guacamole-auth-jwt/releases/download/0.9.14/guacamole-auth-jwt-0.9.14.jar) for guacamole 0.9.14;
* [Version 1.0.1](https://github.com/aiden0z/guacamole-auth-jwt/releases/download/1.0.1/guacamole-auth-jwt-1.0.1.jar) for guacamole 0.9.13-incubating;
* [Version 1.0.0](https://github.com/aiden0z/guacamole-auth-jwt/releases/download/1.0.0/guacamole-auth-jwt-1.0.0.jar) for guacamole 0.9.9;
Expand Down
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
apply plugin: 'java'
apply plugin: 'idea'
plugins {
id "java"
id "java-library"
}

group = 'com.aiden0z.guacamole-auth-jwt'
version = '1.5.3'
version = '1.5.4'
description = """ guacamole custome authentication based on JSON WEB TOKEN """

java {
Expand All @@ -12,20 +14,18 @@ java {
}

repositories {

maven { url "https://maven.aliyun.com/mvn/repository/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://repo.maven.apache.org/maven2" }
}

dependencies {
implementation "org.apache.guacamole:guacamole-ext:1.5.3"
implementation "org.apache.guacamole:guacamole-ext:1.5.4"
implementation "javax.servlet:servlet-api:2.5"
implementation "com.google.inject:guice:7.0.0"
implementation "com.google.inject.extensions:guice-testlib:7.0.0"
implementation "io.jsonwebtoken:jjwt-api:0.11.5"
implementation "io.jsonwebtoken:jjwt-impl:0.11.5"
runtimeOnly "io.jsonwebtoken:jjwt-jackson:0.11.5"
api "io.jsonwebtoken:jjwt-api:0.12.5"
runtimeOnly "io.jsonwebtoken:jjwt-jackson:0.12.5"
runtimeOnly "io.jsonwebtoken:jjwt-impl:0.12.5"

testImplementation "junit:junit:4.13.2"
testImplementation "org.mockito:mockito-core:4.11.0"
Expand Down
47 changes: 38 additions & 9 deletions example-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,54 @@

This is example app for [Guacamole JWT Auth](https://github.com/aiden0z/guacamole-auth-jwt) extension.

## Start
## How to Run

1. Build Guacamole JWT Authentication Plugin Jar
### Install React Dependency

```bash
cd ../
./gradle jar
mkdir example-app/guacamole/extensions
cp build/libs/guacamole-auth-jwt-1.5.3.jar example-app/guacamole/extensions/
npm install
```

### Initialize Guacamole Database

```shell
mkdir ./init >/dev/null 2>&1
docker run --rm guacamole/guacamole:1.5.4 /opt/guacamole/bin/initdb.sh --postgresql > ./init/initdb.sql
```

1. Build the frontend app
### Build Guacamole JWT Authentication Plugin Jar

```bash
cd frontend && npm run build
cd ../
./gradlew jar
mkdir example-app/guacamole/extensions
mkdir example-app/guacamole/lib
cp build/libs/guacamole-auth-jwt-1.5.4.jar example-app/guacamole/extensions/
```

2. Start the docker compose
### Download the Dependency Jars

Download all dependent jars into into ./guacamole/lib/ dir.

* jackson-annotations-2.12.7.jar
* jackson-core-2.12.7.jar
* jackson-databind-2.12.7.1.jar
* jjwt-api-0.12.5.jar
* jjwt-impl-0.12.5.jar
* jjwt-jackson-0.12.5.jar

### Start

start docker compose

```bash
docker compose up

```
start dev app

```bash
cd frontend && npm run dev
```

Access http://localhost:8080/example-app to start.
7 changes: 3 additions & 4 deletions example-app/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
ports:
- 5901/tcp
guacd:
image: guacamole/guacd:1.5.3
image: guacamole/guacd:1.5.4
restart: always
postgres:
environment:
Expand All @@ -33,12 +33,11 @@ services:
POSTGRESQL_USER: guacamole_user
# reference https://guacamole.apache.org/doc/1.5.0/gug/guacamole-docker.html#custom-extensions-and-guacamole-home
GUACAMOLE_HOME: /tmp/guacamole_home_template
image: guacamole/guacamole:1.5.3
image: guacamole/guacamole:1.5.4
volumes:
# mount guacamole jwt auth plugin
# reference https://guacamole.apache.org/doc/1.5.0/gug/guacamole-docker.html#custom-extensions-and-guacamole-home
# reference https://guacamole.apache.org/doc/1.5.4/gug/guacamole-docker.html#custom-extensions-and-guacamole-home
- ./guacamole:/tmp/guacamole_home_template
- ../gradle/build/guacamole-auth-jwt.jar:/etc/guacamole/extensions/
links:
- guacd
ports:
Expand Down
Loading

0 comments on commit 08a7b13

Please sign in to comment.