Skip to content

Commit

Permalink
FISH-338 Create HashiCorp MicroProfile Config Source
Browse files Browse the repository at this point in the history
Merge pull request payara#4982 from MeroRai/FISH-338
Merge pull request payara#5086 from Cousjava/FISH-876-hashicorp-vault-blocking
  • Loading branch information
MattGill98 committed Feb 26, 2021
1 parent 2427b8f commit 3e03658
Show file tree
Hide file tree
Showing 11 changed files with 829 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ microprofile.configuration.gcpSecretsConfigSourceTab=GCP Secrets
microprofile.configuration.azureSecretsConfigSourceTab=Azure Secrets
microprofile.configuration.jdbcConfigSourceTab=JDBC
microprofile.configuration.dynamodbConfigSourceTab=DynamoDB
microprofile.configuration.hashicorpSecretsConfigSourceTab=HashiCorp Secrets
microprofile.configuration.ldapConfigSourceTab=LDAP

microprofile.specs.configuration.config.pageTitle=Config API
Expand Down Expand Up @@ -122,6 +123,8 @@ microprofile.specs.configuration.config.jdbcConfigSource.pageTitle=JDBC
microprofile.specs.configuration.config.jdbcConfigSource.pageTitleHelpText=Configuration options to set the properties required by JDBC config source to read the values from the configured database.
microprofile.specs.configuration.config.dynamodbConfigSource.pageTitle=DynamoDB Config Source
microprofile.specs.configuration.config.dynamodbConfigSource.pageTitleHelpText=Configuration options to set the properties required by DynamoDB config source to retrieves data from the configured DynamoDB database table. Make sure that the password aliases AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY exist.
microprofile.specs.configuration.config.hashicorpSecretsConfigSource.pageTitle=HashiCorp Secrets Config Source
microprofile.specs.configuration.config.hashicorpSecretsConfigSource.pageTitleHelpText=Configuration options for the Hashicorp config source which fetches secrets from HashiCorp Vault. Hashicorp config source only supports the Vault KV secrets engine. Make sure that the password aliases HASHICORP_VAULT_TOKEN exist.
microprofile.specs.configuration.config.ldapConfigSource.pageTitle=LDAP
microprofile.specs.configuration.config.ldapConfigSource.pageTitleHelpText=Configuration options to set the properties required by LDAP config source to read the values from the LDAP server.

Expand Down Expand Up @@ -205,6 +208,19 @@ config.dynamodb.configuration.valueColumnNameHelpText=Name of the column contain
config.dynamodb.configuration.limitLabel=Limit
config.dynamodb.configuration.limitHelpText=The maximum number of items to retrieves from the database table. The default value is 100

config.hashicorp.configuration.enabledLabel=Enabled
config.hashicorp.configuration.enabledHelpText=Enable the config source, which fetches data from HashiCorp Vault
config.hashicorp.configuration.dynamicLabel=Dynamic
config.hashicorp.configuration.dynamicHelpText=Configure the config source dynamically, which will not require a restart
config.hashicorp.configuration.apiVersionLabel=API Version
config.hashicorp.configuration.apiVersionHelpText=KV Secrets Engine API version
config.hashicorp.configuration.secretsEnginePathLabel=Secrets engine path
config.hashicorp.configuration.secretsEnginePathHelpText=The path where the KV secrets engine is enabled
config.hashicorp.configuration.secretsPathLabel=Secrets path
config.hashicorp.configuration.secretsPathHelpText=The path where your secrets are stored
config.hashicorp.configuration.vaultAddressLabel=Vault Address
config.hashicorp.configuration.vaultAddressHelpText=Vault's address represented as URL and port. For example, "http://127.0.0.1:8200"

config.ldapConfigSource.configuration.enabled=Enabled
config.ldapConfigSource.configuration.enabledHelp=Enable the config source, which fetches data from the LDAP server
config.ldapConfigSource.configuration.dynamic=Dynamic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
setSessionAttribute(key="microprofileConfigTabs" value="microProfileConfigGCPSecretsConfigSourceTab");
gf.redirect(page="#{request.contextPath}/microprofile/microprofile/specs/configAPI/gcpConfigSourceConfiguration.jsf?configName=#{configName}");
/>
</sun:tab>
<sun:tab id="microProfileConfigHashiCorpSecretsConfigSourceTab" immediate="$boolean{true}"
text="$resource{i18n_microprofile.microprofile.configuration.hashicorpSecretsConfigSourceTab}"
toolTip="$resource{i18n_microprofile.microprofile.configuration.hashicorpSecretsConfigSourceTab} Tab" >
<!command
setSessionAttribute(key="microprofileConfigTabs" value="microProfileConfigHashiCorpSecretsConfigSourceTab");
gf.redirect(page="#{request.contextPath}/microprofile/microprofile/specs/configAPI/hashicorpConfigSourceConfiguration.jsf?configName=#{configName}");
/>
</sun:tab>
<sun:tab id="microProfileJdbcConfigSourceTab" immediate="$boolean{true}"
text="$resource{i18n_microprofile.microprofile.configuration.jdbcConfigSourceTab}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

Copyright (c) 2020 Payara Foundation and/or its affiliates. All rights reserved.

The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://github.com/payara/Payara/blob/master/LICENSE.txt
See the License for the specific
language governing permissions and limitations under the License.

When distributing the software, include this License Header Notice in each
file and include the License file at glassfish/legal/LICENSE.txt.

GPL Classpath Exception:
The Payara Foundation designates this particular file as subject to the "Classpath"
exception as provided by the Payara Foundation in the GPL Version 2 section of the License
file that accompanied this code.

Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"

Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->

<!initPage
setResourceBundle(key="i18n_microprofile" bundle="fish.payara.admingui.microprofile.Strings");
/>
<!composition template="/templates/default.layout"
guiTitle="$resource{i18n_microprofile.microprofile.specs.configuration.config.hashicorpSecretsConfigSource.pageTitle}">

<!define name="content">

<event>
<!beforeCreate
setSessionAttribute(key="microprofileConfigTabs" value="microProfileConfigHashiCorpSecretsConfigSourceTab");
getRequestValue(key="configName" value="#{pageSession.configName}");
setPageSessionAttribute(key="MICROPROFILE_CONFIG_URL",
value="#{sessionScope.REST_URL}/configs/config/#{pageSession.configName}/microprofile-config");
gf.restRequest(endpoint="#{pageSession.MICROPROFILE_CONFIG_URL}/get-hashicorp-config-source-configuration?target=#{pageSession.configName}"
method="GET" result="#{requestScope.resp}");

setPageSessionAttribute(key="valueMap",
value="#{requestScope.resp.data.extraProperties.configSourceConfiguration}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");

setPageSessionAttribute(key="convertToFalseList", value={"enabled"});

if (#{pageSession.valueMap['enabled']}=true) {
setPageSessionAttribute(key="enabledSelected", value="true");
}
setPageSessionAttribute(key="dynamic", value="true");
/>
</event>


<sun:form id="propertyForm">
#include "/common/shared/alertMsg_1.inc"
#include "/microprofile/microprofile/microprofileConfigTabs.inc"
#include "/microprofile/microprofile/microprofileConfigAPITabs.inc"
<sun:title id="propertyContentPage" title="$resource{i18n_microprofile.microprofile.specs.configuration.config.hashicorpSecretsConfigSource.pageTitle}"
helpText="$resource{i18n_microprofile.microprofile.specs.configuration.config.hashicorpSecretsConfigSource.pageTitleHelpText}" >
<!facet pageButtonsTop>
<sun:panelGroup id="topButtons">
<sun:button id="saveButton" text="$resource{i18n.button.Save}"
onClick="if (guiValidate('#{reqMsg}','#{reqInt}','#{reqPort}'))
submitAndDisable(this, '$resource{i18n.button.Processing}'); return false;" >
<!command
mapPut(map="#{pageSession.valueMap}" key="enabled" value="#{pageSession.enabledSelected}");
mapPut(map="#{pageSession.valueMap}" key="dynamic" value="#{pageSession.dynamic}");
prepareSuccessfulMsg();
gf.updateEntity(endpoint="#{pageSession.MICROPROFILE_CONFIG_URL}/set-hashicorp-config-source-configuration"
attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
/>
</sun:button>
</sun:panelGroup>
</facet>
</sun:title>
<sun:propertySheet id="propertySheet">
#include "/common/shared/configNameSection.inc"
<sun:propertySheetSection id="hashicorpSecretsConfigSourceProps">
<sun:property id="enabledProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.hashicorp.configuration.enabledLabel}"
helpText="$resource{i18n_microprofile.config.hashicorp.configuration.enabledHelpText}">
<sun:checkbox id="enabledProp" selected="#{pageSession.enabledSelected}" selectedValue="true" />
</sun:property>
<sun:property id="dynamic" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.hashicorp.configuration.dynamicLabel}"
helpText="$resource{i18n_microprofile.config.hashicorp.configuration.dynamicHelpText}">
<sun:checkbox id="dynamic" selected="#{pageSession.dynamic}" selectedValue="true" />
</sun:property>
<sun:property id="apiVersionProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.hashicorp.configuration.apiVersionLabel}"
helpText="$resource{i18n_microprofile.config.hashicorp.configuration.apiVersionHelpText}">
<sun:dropDown id="apiVersionDropdown" selected="#{pageSession.valueMap['apiVersion']}"
labels={"1", "2"} />
</sun:property>
<sun:property id="vaultAddressProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.hashicorp.configuration.vaultAddressLabel}"
helpText="$resource{i18n_microprofile.config.hashicorp.configuration.vaultAddressHelpText}">
<sun:textField id="vaultAddressField" columns="$int{75}" maxLength="512"
text="#{pageSession.valueMap['vaultAddress']}" styleClass="required"
required="#{true}"/>
</sun:property>
<sun:property id="secretsEnginePathProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.hashicorp.configuration.secretsEnginePathLabel}"
helpText="$resource{i18n_microprofile.config.hashicorp.configuration.secretsEnginePathHelpText}">
<sun:textField id="secretsEnginePathField" columns="$int{75}" maxLength="255"
text="#{pageSession.valueMap['secretsEnginePath']}" styleClass="required"
required="#{true}"/>
</sun:property>
<sun:property id="secretsPathProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
label="$resource{i18n_microprofile.config.hashicorp.configuration.secretsPathLabel}"
helpText="$resource{i18n_microprofile.config.hashicorp.configuration.secretsPathHelpText}">
<sun:textField id="secretsPathField" columns="$int{75}" maxLength="255"
text="#{pageSession.valueMap['secretsPath']}" styleClass="required"
required="#{true}"/>
</sun:property>
</sun:propertySheetSection>
</sun:propertySheet>
</sun:form>
</define>
</composition>
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,15 @@
<artifactId>oauth2-client-integration</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public void bootstrap() {
| IOException ex) {
LOGGER.log(Level.WARNING, "Unable to get value from password aliases", ex);
}

}

@Override
Expand Down
Loading

0 comments on commit 3e03658

Please sign in to comment.