Skip to content

Commit c71b860

Browse files
authored
GUACAMOLE-2137: Add: module guacamole-vault-hv (Hashicorp Vault)
1 parent d6c091c commit c71b860

File tree

22 files changed

+1966
-0
lines changed

22 files changed

+1966
-0
lines changed

extensions/guacamole-vault/modules/guacamole-vault-dist/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
<version>1.6.0</version>
5050
</dependency>
5151

52+
<!-- Hashicorp Vault Extension -->
53+
<dependency>
54+
<groupId>org.apache.guacamole</groupId>
55+
<artifactId>guacamole-vault-hv</artifactId>
56+
<version>1.6.0</version>
57+
</dependency>
58+
5259
</dependencies>
5360

5461
<build>

extensions/guacamole-vault/modules/guacamole-vault-dist/src/main/assembly/dist.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
</includes>
4242
</dependencySet>
4343

44+
<!-- Hashicorp Vault extension .jar -->
45+
<dependencySet>
46+
<outputDirectory>hv</outputDirectory>
47+
<includes>
48+
<include>org.apache.guacamole:guacamole-vault-hv</include>
49+
</includes>
50+
</dependencySet>
51+
4452
</dependencySets>
4553

4654
<!-- Licenses -->

extensions/guacamole-vault/modules/guacamole-vault-hv/.ratignore

Whitespace-only changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
23+
http://maven.apache.org/maven-v4_0_0.xsd">
24+
25+
<modelVersion>4.0.0</modelVersion>
26+
<groupId>org.apache.guacamole</groupId>
27+
<artifactId>guacamole-vault-hv</artifactId>
28+
<packaging>jar</packaging>
29+
<version>1.6.0</version>
30+
<name>guacamole-vault-hv</name>
31+
<url>http://guacamole.apache.org/</url>
32+
33+
<parent>
34+
<groupId>org.apache.guacamole</groupId>
35+
<artifactId>guacamole-vault</artifactId>
36+
<version>1.6.0</version>
37+
<relativePath>../../</relativePath>
38+
</parent>
39+
40+
<properties>
41+
<kotlin.version>1.9.25</kotlin.version>
42+
</properties>
43+
44+
<dependencies>
45+
46+
<!-- Guacamole Extension API -->
47+
<dependency>
48+
<groupId>org.apache.guacamole</groupId>
49+
<artifactId>guacamole-ext</artifactId>
50+
<scope>provided</scope>
51+
</dependency>
52+
53+
<!-- Guacamole base key vault support -->
54+
<dependency>
55+
<groupId>org.apache.guacamole</groupId>
56+
<artifactId>guacamole-vault-base</artifactId>
57+
<version>1.6.0</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>com.fasterxml.jackson.core</groupId>
62+
<artifactId>jackson-databind</artifactId>
63+
<version>2.19.0</version>
64+
</dependency>
65+
66+
<!-- Use same version of Kotlin across all dependencies -->
67+
<dependency>
68+
<groupId>org.jetbrains.kotlin</groupId>
69+
<artifactId>kotlin-reflect</artifactId>
70+
<version>${kotlin.version}</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.jetbrains.kotlin</groupId>
74+
<artifactId>kotlin-stdlib</artifactId>
75+
<version>${kotlin.version}</version>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.jetbrains.kotlin</groupId>
79+
<artifactId>kotlin-stdlib-jdk8</artifactId>
80+
<version>${kotlin.version}</version>
81+
</dependency>
82+
83+
<!-- Use FIPS variant of Bouncy Castle crypto library -->
84+
<dependency>
85+
<groupId>org.bouncycastle</groupId>
86+
<artifactId>bc-fips</artifactId>
87+
<version>2.1.0</version>
88+
</dependency>
89+
90+
</dependencies>
91+
92+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.guacamole.vault.hv;
21+
22+
import org.apache.guacamole.GuacamoleException;
23+
24+
/**
25+
* A class that is basically equivalent to the standard Supplier class in
26+
* Java, except that the get() function can throw GuacamoleException, which
27+
* is impossible with any of the standard Java lambda type classes, since
28+
* none of them can handle checked exceptions
29+
*
30+
* @param <T>
31+
* The type of object which will be returned as a result of calling
32+
* get().
33+
*/
34+
public interface GuacamoleExceptionSupplier<T> {
35+
36+
/**
37+
* Returns a value of the declared type.
38+
*
39+
* @return
40+
* A value of the declared type.
41+
*
42+
* @throws GuacamoleException
43+
* If an error occurs while attemping to calculate the return value.
44+
*/
45+
public T get() throws GuacamoleException;
46+
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.guacamole.vault.hv;
21+
22+
import org.apache.guacamole.GuacamoleException;
23+
import org.apache.guacamole.vault.VaultAuthenticationProvider;
24+
25+
/**
26+
* VaultAuthenticationProvider implementation which reads secrets from
27+
* Hashicorp Vault
28+
*/
29+
public class HvAuthenticationProvider extends VaultAuthenticationProvider {
30+
31+
/**
32+
* Creates a new HvKeyVaultAuthenticationProvider which reads secrets
33+
* from a configured Hashicorp Vault.
34+
*
35+
* @throws GuacamoleException
36+
* If configuration details cannot be read from guacamole.properties.
37+
*/
38+
public HvAuthenticationProvider() throws GuacamoleException {
39+
super(new HvAuthenticationProviderModule());
40+
}
41+
42+
@Override
43+
public String getIdentifier() {
44+
return "hashicorp-vault";
45+
}
46+
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.guacamole.vault.hv;
21+
22+
import com.google.inject.assistedinject.FactoryModuleBuilder;
23+
import java.security.Security;
24+
import org.apache.guacamole.GuacamoleException;
25+
import org.apache.guacamole.vault.VaultAuthenticationProviderModule;
26+
import org.apache.guacamole.vault.conf.VaultAttributeService;
27+
import org.apache.guacamole.vault.conf.VaultConfigurationService;
28+
import org.apache.guacamole.vault.hv.conf.HvAttributeService;
29+
import org.apache.guacamole.vault.hv.conf.HvConfigurationService;
30+
import org.apache.guacamole.vault.hv.secret.HvClient;
31+
import org.apache.guacamole.vault.hv.secret.HvClientFactory;
32+
import org.apache.guacamole.vault.hv.secret.HvSecretService;
33+
import org.apache.guacamole.vault.hv.user.HvConnectionGroup;
34+
import org.apache.guacamole.vault.hv.user.HvDirectoryService;
35+
import org.apache.guacamole.vault.hv.user.HvUser;
36+
import org.apache.guacamole.vault.hv.user.HvUserFactory;
37+
import org.apache.guacamole.vault.secret.VaultSecretService;
38+
import org.apache.guacamole.vault.user.VaultDirectoryService;
39+
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
40+
41+
/**
42+
* Guice module which configures injections specific to Hashicorp Vault
43+
* support.
44+
*/
45+
public class HvAuthenticationProviderModule
46+
extends VaultAuthenticationProviderModule {
47+
48+
/**
49+
* Creates a new HvAuthenticationProviderModule which
50+
* configures dependency injection for the Hashicorp Vault
51+
* authentication provider and related services.
52+
*
53+
* @throws GuacamoleException
54+
* If configuration details in guacamole.properties cannot be parsed.
55+
*/
56+
public HvAuthenticationProviderModule() throws GuacamoleException {
57+
Security.addProvider(new BouncyCastleFipsProvider());
58+
}
59+
60+
@Override
61+
protected void configureVault() {
62+
63+
// Bind services specific to Hashicorp Vault
64+
bind(HvAttributeService.class);
65+
bind(VaultAttributeService.class).to(HvAttributeService.class);
66+
bind(VaultConfigurationService.class).to(HvConfigurationService.class);
67+
bind(VaultSecretService.class).to(HvSecretService.class);
68+
bind(VaultDirectoryService.class).to(HvDirectoryService.class);
69+
70+
// Bind factory for creating HV Clients
71+
install(new FactoryModuleBuilder()
72+
.implement(HvClient.class, HvClient.class)
73+
.build(HvClientFactory.class));
74+
75+
// Bind factory for creating HvUsers
76+
install(new FactoryModuleBuilder()
77+
.implement(HvUser.class, HvUser.class)
78+
.build(HvUserFactory.class));
79+
}
80+
81+
}

0 commit comments

Comments
 (0)