|
| 1 | +# OpenBao Vault Extension for Apache Guacamole |
| 2 | + |
| 3 | +This extension integrates Apache Guacamole with [OpenBao](https://openbao.org/) vault to automatically retrieve connection credentials from OpenBao at connection time. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The OpenBao vault extension allows Guacamole to retrieve credentials from an OpenBao server using token-based authentication. Connection parameters configured with special tokens like `${OPENBAO_SECRET}` are automatically replaced with values retrieved from OpenBao when a user connects. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Automatic Credential Retrieval**: Fetches credentials from OpenBao without requiring users to re-enter passwords |
| 12 | +- **Token-Based Resolution**: Uses `${OPENBAO_SECRET}` and `${GUAC_USERNAME}` tokens in connection parameters |
| 13 | +- **KV v2 Support**: Works with OpenBao KV v2 secrets engine |
| 14 | +- **Simple Configuration**: Minimal configuration required in `guacamole.properties` |
| 15 | +- **Secure**: Uses OpenBao's token-based authentication for secure API access |
| 16 | + |
| 17 | +## How It Works |
| 18 | + |
| 19 | +1. User logs into Guacamole with their username |
| 20 | +2. User initiates a connection configured with `${OPENBAO_SECRET}` token |
| 21 | +3. Extension queries OpenBao API to retrieve the secret for that username |
| 22 | +4. Password is extracted and injected into the connection parameters |
| 23 | +5. Connection proceeds with the retrieved credentials |
| 24 | + |
| 25 | +## Configuration |
| 26 | + |
| 27 | +### OpenBao Server Setup |
| 28 | + |
| 29 | +Before using this extension, you need: |
| 30 | + |
| 31 | +1. An OpenBao server running and accessible from the Guacamole server |
| 32 | +2. A KV v2 secrets engine mounted (eg path: `guacamole-credentails`) |
| 33 | +3. An OpenBao authentication token with read access to the secrets |
| 34 | +4. Secrets stored with a `password` field in the data |
| 35 | + |
| 36 | +Example secret structure: |
| 37 | +```json |
| 38 | +{ |
| 39 | + "data": { |
| 40 | + "data": { |
| 41 | + "username": "user1", |
| 42 | + "password": "SecretPassword123" |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +### Guacamole Configuration |
| 49 | + |
| 50 | +Add the following properties to `guacamole.properties`: |
| 51 | + |
| 52 | +```properties |
| 53 | +# OpenBao server URL (required) |
| 54 | +openbao-server-url: http://openbao.example.com:8200 |
| 55 | + |
| 56 | +# OpenBao authentication token (required) |
| 57 | +openbao-token: s.YourTokenHere |
| 58 | + |
| 59 | +# KV mount path (optional, default: guacamole-credentails) |
| 60 | +openbao-mount-path: guacamole-credentails |
| 61 | +``` |
| 62 | + |
| 63 | +**Note**: The extension uses hardcoded defaults for: |
| 64 | +- KV version: `2` (KV v2 secrets engine) |
| 65 | +- Connection timeout: `5000ms` (5 seconds) |
| 66 | +- Request timeout: `10000ms` (10 seconds) |
| 67 | + |
| 68 | +### Connection Configuration |
| 69 | + |
| 70 | +When creating connections in Guacamole, use these token patterns: |
| 71 | + |
| 72 | +- **`${OPENBAO_SECRET}`**: Replaced with the password from OpenBao |
| 73 | +- **`${GUAC_USERNAME}`**: Replaced with the logged-in Guacamole username |
| 74 | + |
| 75 | +Example RDP connection: |
| 76 | +- Username: `${GUAC_USERNAME}` |
| 77 | +- Password: `${OPENBAO_SECRET}` |
| 78 | +- Hostname: `192.168.1.100` |
| 79 | + |
| 80 | +## Secret Path Mapping |
| 81 | + |
| 82 | +The extension maps Guacamole usernames directly to OpenBao secret paths: |
| 83 | + |
| 84 | +``` |
| 85 | +Guacamole username: "john" |
| 86 | +OpenBao secret path: /v1/guacamole-credentails/data/john |
| 87 | +``` |
| 88 | + |
| 89 | +For each user, create a corresponding secret in OpenBao at the path matching their Guacamole username. |
| 90 | + |
| 91 | +## Building |
| 92 | + |
| 93 | +Build the extension from the guacamole-client source tree: |
| 94 | + |
| 95 | +```bash |
| 96 | +cd extensions/guacamole-vault |
| 97 | +mvn clean package |
| 98 | +``` |
| 99 | + |
| 100 | +The built extension will be located at: |
| 101 | +``` |
| 102 | +modules/guacamole-vault-openbao/target/guacamole-vault-openbao-<version>.jar |
| 103 | +``` |
| 104 | + |
| 105 | +## Installation |
| 106 | + |
| 107 | +1. Copy the built JAR to the Guacamole extensions directory: |
| 108 | + ```bash |
| 109 | + cp guacamole-vault-openbao-*.jar /etc/guacamole/extensions/ |
| 110 | + ``` |
| 111 | + |
| 112 | +2. Ensure `guacamole-vault-base-*.jar` is also present in the extensions directory (it's a dependency) |
| 113 | + |
| 114 | +3. Configure `guacamole.properties` as described above |
| 115 | + |
| 116 | +4. Restart Guacamole (e.g., restart Tomcat) |
| 117 | + |
| 118 | +## Security Considerations |
| 119 | + |
| 120 | +1. **Protect the OpenBao Token**: Use a dedicated token with minimal permissions (read-only access to required secret paths) |
| 121 | + |
| 122 | +2. **Use TLS in Production**: Always use HTTPS URLs for OpenBao in production: |
| 123 | + ```properties |
| 124 | + openbao-server-url: https://openbao.example.com:8200 |
| 125 | + ``` |
| 126 | + |
| 127 | +3. **Network Security**: Restrict OpenBao access to the Guacamole server using firewall rules |
| 128 | + |
| 129 | +4. **Audit Logging**: Enable OpenBao audit logging to track credential access |
| 130 | + |
| 131 | +5. **Token Rotation**: Regularly rotate OpenBao tokens and update the configuration |
| 132 | + |
| 133 | +## Troubleshooting |
| 134 | + |
| 135 | +### Extension Not Loading |
| 136 | + |
| 137 | +Check the Guacamole logs (typically in Tomcat's `catalina.out`) for errors. Common issues: |
| 138 | + |
| 139 | +- Missing `guacamole-vault-base` dependency |
| 140 | +- Incorrect permissions on JAR files |
| 141 | +- Configuration errors in `guacamole.properties` |
| 142 | + |
| 143 | +### Secret Not Found |
| 144 | + |
| 145 | +Error: `Secret not found in OpenBao for username: john` |
| 146 | + |
| 147 | +Solutions: |
| 148 | +1. Verify the secret exists in OpenBao at the expected path |
| 149 | +2. Check that the Guacamole username matches the secret name in OpenBao |
| 150 | +3. Verify the token has read access to the secret |
| 151 | + |
| 152 | +### Permission Denied |
| 153 | + |
| 154 | +Error: `Permission denied accessing OpenBao. Check token permissions.` |
| 155 | + |
| 156 | +Solutions: |
| 157 | +1. Verify the token has appropriate policies attached |
| 158 | +2. Check that the token hasn't expired |
| 159 | +3. Ensure the token has read access to the KV mount path |
| 160 | + |
| 161 | +### Connection Timeout |
| 162 | + |
| 163 | +Error: `Failed to communicate with OpenBao` |
| 164 | + |
| 165 | +Solutions: |
| 166 | +1. Verify OpenBao is accessible from the Guacamole server |
| 167 | +2. Check firewall rules between Guacamole and OpenBao |
| 168 | +3. Verify the OpenBao URL is correct in the configuration |
| 169 | + |
| 170 | +## Example Deployment |
| 171 | + |
| 172 | +1. **Setup OpenBao**: |
| 173 | + ```bash |
| 174 | + # Start OpenBao |
| 175 | + bao server -dev |
| 176 | + |
| 177 | + # Enable KV v2 engine |
| 178 | + bao secrets enable -path=guacamole-credentails kv-v2 |
| 179 | + |
| 180 | + # Create a secret |
| 181 | + bao kv put guacamole-credentails/john password=SecretPass123 |
| 182 | + ``` |
| 183 | + |
| 184 | +2. **Configure Guacamole**: |
| 185 | + ```properties |
| 186 | + openbao-server-url: http://openbao.example.com:8200 |
| 187 | + openbao-token: s.yourtokenhere |
| 188 | + openbao-mount-path: guacamole-credentails |
| 189 | + ``` |
| 190 | + |
| 191 | +3. **Create Connection**: |
| 192 | + - Name: Windows Server |
| 193 | + - Protocol: RDP |
| 194 | + - Hostname: 192.168.1.100 |
| 195 | + - Username: `${GUAC_USERNAME}` |
| 196 | + - Password: `${OPENBAO_SECRET}` |
| 197 | + |
| 198 | +4. **Connect**: Log in as user "john" and connect to the Windows Server connection. The password will be automatically retrieved from OpenBao. |
| 199 | + |
| 200 | +## License |
| 201 | + |
| 202 | +This extension is licensed under the Apache License, Version 2.0. See the LICENSE file for details. |
| 203 | + |
| 204 | +## Support |
| 205 | + |
| 206 | +For issues or questions: |
| 207 | +- Apache Guacamole: https://guacamole.apache.org/ |
| 208 | +- OpenBao: https://openbao.org/ |
| 209 | +- Issue Tracker: https://issues.apache.org/jira/browse/GUACAMOLE/ |
0 commit comments