diff --git a/gravitee-apim-definition/gravitee-apim-definition-model/pom.xml b/gravitee-apim-definition/gravitee-apim-definition-model/pom.xml index d09b4d0ad38..308bfbbe873 100644 --- a/gravitee-apim-definition/gravitee-apim-definition-model/pom.xml +++ b/gravitee-apim-definition/gravitee-apim-definition-model/pom.xml @@ -47,6 +47,12 @@ io.gravitee.node gravitee-node-vertx + + io.gravitee.apim.definition + gravitee-apim-definition-jackson + 4.5.0-SNAPSHOT + test + diff --git a/gravitee-apim-definition/gravitee-apim-definition-model/src/main/java/io/gravitee/definition/model/services/secrets/ApiV4DefinitionBrowser.java b/gravitee-apim-definition/gravitee-apim-definition-model/src/main/java/io/gravitee/definition/model/services/secrets/ApiV4DefinitionBrowser.java new file mode 100644 index 00000000000..439c659c229 --- /dev/null +++ b/gravitee-apim-definition/gravitee-apim-definition-model/src/main/java/io/gravitee/definition/model/services/secrets/ApiV4DefinitionBrowser.java @@ -0,0 +1,131 @@ +package io.gravitee.definition.model.services.secrets; + +import static io.gravitee.node.api.secrets.runtime.discovery.PayloadLocation.PLUGIN_KIND; + +import io.gravitee.definition.model.v4.Api; +import io.gravitee.definition.model.v4.endpointgroup.service.EndpointGroupServices; +import io.gravitee.definition.model.v4.endpointgroup.service.EndpointServices; +import io.gravitee.definition.model.v4.flow.Flow; +import io.gravitee.definition.model.v4.plan.PlanSecurity; +import io.gravitee.definition.model.v4.service.Service; +import io.gravitee.node.api.secrets.runtime.discovery.Definition; +import io.gravitee.node.api.secrets.runtime.discovery.DefinitionBrowser; +import io.gravitee.node.api.secrets.runtime.discovery.DefinitionPayloadNotifier; +import io.gravitee.node.api.secrets.runtime.discovery.PayloadLocation; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * @author Benoit BORDIGONI (benoit.bordigoni at graviteesource.com) + * @author GraviteeSource Team + */ +public class ApiV4DefinitionBrowser implements DefinitionBrowser { + + @Override + public boolean canHandle(Object definition) { + return definition != null && Objects.equals(definition.getClass(), Api.class); + } + + @Override + public Definition getDefinitionLocation(Api definition, Map metadata) { + return new Definition("api-v4", metadata.get("api_cross_id"), Optional.ofNullable(metadata.get("deployment_number"))); + } + + @Override + public void findPayloads(Api definition, DefinitionPayloadNotifier notifier) { + // listeners + definition + .getListeners() + .stream() + .flatMap(l -> l.getEntrypoints().stream()) + .forEach(entrypoint -> { + String payload = entrypoint.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, entrypoint.getType()), entrypoint::setConfiguration); + }); + + // resources + definition + .getResources() + .forEach(resource -> { + String payload = resource.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, resource.getType()), resource::setConfiguration); + }); + + // flows api and plan + List flows = definition + .getPlans() + .stream() + .flatMap(p -> p.getFlows().stream()) + .collect(Collectors.toCollection(ArrayList::new)); + flows.addAll(definition.getFlows()); + Stream + .concat( + Stream.concat( + flows.stream().flatMap(flow -> flow.getRequest().stream()), + flows.stream().flatMap(flow -> flow.getResponse().stream()) + ), + Stream.concat( + flows.stream().flatMap(flow -> flow.getPublish().stream()), + flows.stream().flatMap(flow -> flow.getSubscribe().stream()) + ) + ) + .forEach(step -> { + var payload = step.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, step.getPolicy()), step::setConfiguration); + }); + + definition + .getPlans() + .forEach(plan -> { + PlanSecurity security = plan.getSecurity(); + String payload = security.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, security.getType()), security::setConfiguration); + }); + + // endpoint groups + definition + .getEndpointGroups() + .stream() + .flatMap(endpointGroup -> { + EndpointGroupServices services = endpointGroup.getServices(); + Stream + .of(services.getDiscovery(), services.getHealthCheck()) + .filter(Service::isEnabled) + .forEach(service -> { + String payload = service.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, service.getType()), service::setConfiguration); + }); + String payload = endpointGroup.getSharedConfiguration(); + notifier.onPayload( + payload, + new PayloadLocation(PLUGIN_KIND, endpointGroup.getType()), + endpointGroup::setSharedConfiguration + ); + return endpointGroup.getEndpoints().stream(); + }) + .forEach(endpoint -> { + EndpointServices services = endpoint.getServices(); + Stream + .of(services.getHealthCheck()) + .filter(Service::isEnabled) + .forEach(service -> { + String payload = service.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, service.getType()), service::setConfiguration); + }); + String payload = endpoint.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, endpoint.getType()), endpoint::setConfiguration); + payload = endpoint.getSharedConfigurationOverride(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, endpoint.getType()), endpoint::setSharedConfigurationOverride); + }); + + // services + Service dynamicProperty = definition.getServices().getDynamicProperty(); + String payload = dynamicProperty.getConfiguration(); + notifier.onPayload(payload, new PayloadLocation(PLUGIN_KIND, dynamicProperty.getType()), dynamicProperty::setConfiguration); + } +} diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/pom.xml b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/pom.xml index 34b04e8ed4f..a1f21ec3768 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/pom.xml +++ b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/pom.xml @@ -134,6 +134,12 @@ gravitee-node-api + + io.gravitee.node + gravitee-node-secrets-runtime + ${gravitee-node.version} + + io.gravitee.apim.definition gravitee-apim-definition-jackson diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/manager/impl/ApiManagerImpl.java b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/manager/impl/ApiManagerImpl.java index a03b695e32c..1224d9e3a5e 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/manager/impl/ApiManagerImpl.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/manager/impl/ApiManagerImpl.java @@ -15,6 +15,7 @@ */ package io.gravitee.gateway.handlers.api.manager.impl; +import com.graviteesource.services.runtimesecrets.RuntimeSecretsService; import io.gravitee.common.event.EventManager; import io.gravitee.common.util.DataEncryptor; import io.gravitee.definition.model.DefinitionVersion; @@ -29,7 +30,6 @@ import io.gravitee.gateway.reactor.ReactorEvent; import io.gravitee.node.api.license.ForbiddenFeatureException; import io.gravitee.node.api.license.InvalidLicenseException; -import io.gravitee.node.api.license.License; import io.gravitee.node.api.license.LicenseManager; import java.util.Collection; import java.util.List; @@ -60,16 +60,19 @@ public class ApiManagerImpl implements ApiManager { private final LicenseManager licenseManager; private final Map> apis = new ConcurrentHashMap<>(); private final Map>, ? extends Deployer> deployers; + private final RuntimeSecretsService runtimeSecretsService; public ApiManagerImpl( final EventManager eventManager, final GatewayConfiguration gatewayConfiguration, LicenseManager licenseManager, - final DataEncryptor dataEncryptor + final DataEncryptor dataEncryptor, + final RuntimeSecretsService runtimeSecretsService ) { this.eventManager = eventManager; this.gatewayConfiguration = gatewayConfiguration; this.licenseManager = licenseManager; + this.runtimeSecretsService = runtimeSecretsService; deployers = Map.of( Api.class, @@ -210,6 +213,9 @@ private void deploy(ReactableApi api) { } apis.put(api.getId(), api); + + runtimeSecretsService.onDefinitionDeploy(api.getEnvironmentId(), api.getDefinition(), api.getDeploymentProperties()); + eventManager.publishEvent(ReactorEvent.DEPLOY, api); log.info("{} has been deployed", api); } else { @@ -250,6 +256,9 @@ private void update(ReactableApi api) { } apis.put(api.getId(), api); + + runtimeSecretsService.onDefinitionDeploy(api.getEnvironmentId(), api.getDefinition(), api.getDeploymentProperties()); + eventManager.publishEvent(ReactorEvent.UPDATE, api); log.info("{} has been updated", api); } else { @@ -265,6 +274,11 @@ private void undeploy(String apiId) { if (currentApi != null) { MDC.put("api", apiId); log.debug("Undeployment of {}", currentApi); + runtimeSecretsService.onDefinitionUnDeploy( + currentApi.getEnvironmentId(), + currentApi.getDefinition(), + currentApi.getDeploymentProperties() + ); eventManager.publishEvent(ReactorEvent.UNDEPLOY, currentApi); log.info("{} has been undeployed", currentApi); diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/spring/ApiHandlerConfiguration.java b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/spring/ApiHandlerConfiguration.java index cf4a973a44a..541687f5a4f 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/spring/ApiHandlerConfiguration.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/main/java/io/gravitee/gateway/handlers/api/spring/ApiHandlerConfiguration.java @@ -15,6 +15,7 @@ */ package io.gravitee.gateway.handlers.api.spring; +import com.graviteesource.services.runtimesecrets.RuntimeSecretsService; import io.gravitee.common.event.EventManager; import io.gravitee.common.util.DataEncryptor; import io.gravitee.gateway.core.classloader.DefaultClassLoader; @@ -88,9 +89,10 @@ public ApiManager apiManager( EventManager eventManager, GatewayConfiguration gatewayConfiguration, LicenseManager licenseManager, + RuntimeSecretsService runtimeSecretsService, DataEncryptor dataEncryptor ) { - return new ApiManagerImpl(eventManager, gatewayConfiguration, licenseManager, dataEncryptor); + return new ApiManagerImpl(eventManager, gatewayConfiguration, licenseManager, dataEncryptor, runtimeSecretsService); } @Bean diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerTest.java b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerTest.java index da965e5dd16..8d429d307a3 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerTest.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerTest.java @@ -19,10 +19,17 @@ import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.anyCollection; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; +import com.graviteesource.services.runtimesecrets.RuntimeSecretsService; import io.gravitee.common.event.EventManager; import io.gravitee.common.util.DataEncryptor; import io.gravitee.definition.model.Plan; @@ -79,11 +86,14 @@ public class ApiManagerTest { @Mock private LicenseManager licenseManager; + @Mock + RuntimeSecretsService runtimeSecretsService; + private ApiManagerImpl apiManager; @Before public void setUp() throws Exception { - apiManager = spy(new ApiManagerImpl(eventManager, gatewayConfiguration, licenseManager, dataEncryptor)); + apiManager = spy(new ApiManagerImpl(eventManager, gatewayConfiguration, licenseManager, dataEncryptor, runtimeSecretsService)); when(gatewayConfiguration.shardingTags()).thenReturn(Optional.empty()); when(gatewayConfiguration.hasMatchingTags(any())).thenCallRealMethod(); } diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerV4Test.java b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerV4Test.java index 9a587d5bf2f..fdff4e01e83 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerV4Test.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-handlers/gravitee-apim-gateway-handlers-api/src/test/java/io/gravitee/gateway/handlers/api/manager/ApiManagerV4Test.java @@ -18,9 +18,18 @@ import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyCollection; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; +import com.graviteesource.services.runtimesecrets.RuntimeSecretsService; import io.gravitee.common.event.EventManager; import io.gravitee.common.util.DataEncryptor; import io.gravitee.definition.model.v4.listener.Listener; @@ -77,9 +86,12 @@ public class ApiManagerV4Test { @Mock private LicenseManager licenseManager; + @Mock + private RuntimeSecretsService runtimeSecretsService; + @Before public void setUp() throws Exception { - apiManager = spy(new ApiManagerImpl(eventManager, gatewayConfiguration, licenseManager, dataEncryptor)); + apiManager = spy(new ApiManagerImpl(eventManager, gatewayConfiguration, licenseManager, dataEncryptor, runtimeSecretsService)); when(gatewayConfiguration.shardingTags()).thenReturn(Optional.empty()); when(gatewayConfiguration.hasMatchingTags(any())).thenCallRealMethod(); } diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-reactor/src/main/java/io/gravitee/gateway/reactor/ReactableApi.java b/gravitee-apim-gateway/gravitee-apim-gateway-reactor/src/main/java/io/gravitee/gateway/reactor/ReactableApi.java index 9d933cfc4a5..df012b3cf77 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-reactor/src/main/java/io/gravitee/gateway/reactor/ReactableApi.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-reactor/src/main/java/io/gravitee/gateway/reactor/ReactableApi.java @@ -20,6 +20,7 @@ import io.gravitee.definition.model.DefinitionVersion; import java.io.Serializable; import java.util.Date; +import java.util.Map; import java.util.Objects; import java.util.Set; @@ -45,6 +46,8 @@ public abstract class ReactableApi implements Reactable, Serializable { private DefinitionContext definitionContext = new DefinitionContext(); + private Map deploymentProperties; + protected ReactableApi() {} protected ReactableApi(T definition) { @@ -115,6 +118,14 @@ public void setDefinitionContext(DefinitionContext definitionContext) { this.definitionContext = definitionContext; } + public void setDeploymentProperties(Map deploymentProperties) { + this.deploymentProperties = deploymentProperties; + } + + public Map getDeploymentProperties() { + return deploymentProperties; + } + public T getDefinition() { return this.definition; } diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-services/gravitee-apim-gateway-services-sync/src/main/java/io/gravitee/gateway/services/sync/process/repository/mapper/ApiMapper.java b/gravitee-apim-gateway/gravitee-apim-gateway-services/gravitee-apim-gateway-services-sync/src/main/java/io/gravitee/gateway/services/sync/process/repository/mapper/ApiMapper.java index f82678442cf..3797eaba640 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-services/gravitee-apim-gateway-services-sync/src/main/java/io/gravitee/gateway/services/sync/process/repository/mapper/ApiMapper.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-services/gravitee-apim-gateway-services-sync/src/main/java/io/gravitee/gateway/services/sync/process/repository/mapper/ApiMapper.java @@ -61,11 +61,13 @@ public Maybe> to(Event apiEvent) { // Update definition with required information for deployment phase reactableApi = new io.gravitee.gateway.handlers.api.definition.Api(eventApiDefinition); + reactableApi.setDeploymentProperties(apiEvent.getProperties()); } else { var eventApiDefinition = objectMapper.readValue(api.getDefinition(), io.gravitee.definition.model.v4.Api.class); // Update definition with required information for deployment phase reactableApi = new io.gravitee.gateway.reactive.handlers.api.v4.Api(eventApiDefinition); + reactableApi.setDeploymentProperties(apiEvent.getProperties()); } reactableApi.setEnabled(api.getLifecycleState() == LifecycleState.STARTED); diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/secrets/DefinitionBrowserBeanFactory.java b/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/secrets/DefinitionBrowserBeanFactory.java new file mode 100644 index 00000000000..1830e8c2466 --- /dev/null +++ b/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/secrets/DefinitionBrowserBeanFactory.java @@ -0,0 +1,20 @@ +package io.gravitee.gateway.standalone.secrets; + +import io.gravitee.definition.model.services.secrets.ApiV4DefinitionBrowser; +import io.gravitee.definition.model.v4.Api; +import io.gravitee.node.api.secrets.runtime.discovery.DefinitionBrowser; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author Benoit BORDIGONI (benoit.bordigoni at graviteesource.com) + * @author GraviteeSource Team + */ +@Configuration +public class DefinitionBrowserBeanFactory { + + @Bean + DefinitionBrowser apiV4() { + return new ApiV4DefinitionBrowser(); + } +} diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/spring/StandaloneConfiguration.java b/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/spring/StandaloneConfiguration.java index a34aefe42b9..169a35d51c0 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/spring/StandaloneConfiguration.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/main/java/io/gravitee/gateway/standalone/spring/StandaloneConfiguration.java @@ -36,6 +36,7 @@ import io.gravitee.gateway.repository.plugins.GatewayRepositoryScopeProvider; import io.gravitee.gateway.standalone.node.GatewayNode; import io.gravitee.gateway.standalone.node.GatewayNodeMetadataResolver; +import io.gravitee.gateway.standalone.secrets.DefinitionBrowserBeanFactory; import io.gravitee.gateway.standalone.vertx.VertxReactorConfiguration; import io.gravitee.node.api.Node; import io.gravitee.node.api.NodeMetadataResolver; @@ -62,6 +63,7 @@ PlatformConfiguration.class, ConnectorConfiguration.class, RequestConfiguration.class, + DefinitionBrowserBeanFactory.class, } ) public class StandaloneConfiguration { diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/test/java/io/gravitee/gateway/standalone/license/PermissiveLicenseManager.java b/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/test/java/io/gravitee/gateway/standalone/license/PermissiveLicenseManager.java index 4ca0af20eea..0735ccde1f6 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/test/java/io/gravitee/gateway/standalone/license/PermissiveLicenseManager.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-standalone/gravitee-apim-gateway-standalone-container/src/test/java/io/gravitee/gateway/standalone/license/PermissiveLicenseManager.java @@ -66,6 +66,6 @@ public void validatePluginFeatures(String organizationId, Collection plu @Override public void onLicenseExpires(Consumer expirationListener) { - // Don't do anything as there is no license expiration. + // Don't do anything as there is no license pollInterval. } } diff --git a/gravitee-apim-gateway/gravitee-apim-gateway-tests-sdk/src/main/java/io/gravitee/apim/gateway/tests/sdk/license/PermissiveLicenseManager.java b/gravitee-apim-gateway/gravitee-apim-gateway-tests-sdk/src/main/java/io/gravitee/apim/gateway/tests/sdk/license/PermissiveLicenseManager.java index e4270556e04..a0babfc0e05 100644 --- a/gravitee-apim-gateway/gravitee-apim-gateway-tests-sdk/src/main/java/io/gravitee/apim/gateway/tests/sdk/license/PermissiveLicenseManager.java +++ b/gravitee-apim-gateway/gravitee-apim-gateway-tests-sdk/src/main/java/io/gravitee/apim/gateway/tests/sdk/license/PermissiveLicenseManager.java @@ -62,6 +62,6 @@ public void validatePluginFeatures(String organizationId, Collection plu @Override public void onLicenseExpires(Consumer expirationListener) { - // Don't do anything as there is no license expiration. + // Don't do anything as there is no license pollInterval. } } diff --git a/gravitee-apim-integration-tests/src/test/java/io/gravitee/apim/integration/tests/secrets/conf/UnsecuredVaultSecretProviderIntegrationTest.java b/gravitee-apim-integration-tests/src/test/java/io/gravitee/apim/integration/tests/secrets/conf/UnsecuredVaultSecretProviderIntegrationTest.java index bc80e558bfb..fc3921c36e7 100644 --- a/gravitee-apim-integration-tests/src/test/java/io/gravitee/apim/integration/tests/secrets/conf/UnsecuredVaultSecretProviderIntegrationTest.java +++ b/gravitee-apim-integration-tests/src/test/java/io/gravitee/apim/integration/tests/secrets/conf/UnsecuredVaultSecretProviderIntegrationTest.java @@ -26,7 +26,12 @@ import java.io.IOException; import java.util.Set; import java.util.UUID; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; import org.springframework.core.env.Environment; import org.testcontainers.containers.Container; @@ -52,7 +57,14 @@ static void startAndConfigure() throws IOException, InterruptedException { .withInitCommand("kv put secret/test top_secret=thatWillRemainOurDirtyLittleSecret"); vaultContainer.start(); // create a renewable token so the plugin does not start panicking - Container.ExecResult execResult = vaultContainer.execInContainer("vault", "token", "create", "-period=10m", "-field", "token"); + Container.ExecResult execResult = vaultContainer.execInContainer( + "vault", + "token", + "create", + "-pollInterval=10m", + "-field", + "token" + ); token = execResult.getStdout(); } diff --git a/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/ApiKey.java b/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/ApiKey.java index e29fdaeff75..dcc0a64e902 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/ApiKey.java +++ b/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/ApiKey.java @@ -160,7 +160,7 @@ public enum AuditEvent implements Audit.ApiAuditEvent { private boolean federated; /** - * Number of days before the expiration of this API Key when the last pre-expiration notification was sent + * Number of days before the pollInterval of this API Key when the last pre-pollInterval notification was sent */ @Setter @Getter diff --git a/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Event.java b/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Event.java index 68f0277972f..0c59eedf176 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Event.java +++ b/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Event.java @@ -90,6 +90,7 @@ public class Event implements Serializable { public enum EventProperties { ID("id"), API_ID("api_id"), + API_CROSS_ID("api_cross_id"), SHARED_POLICY_GROUP_ID("shared_policy_group_id"), DICTIONARY_ID("dictionary_id"), ORIGIN("origin"), diff --git a/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Subscription.java b/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Subscription.java index 10afc6c418a..3a65de8ca89 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Subscription.java +++ b/gravitee-apim-repository/gravitee-apim-repository-api/src/main/java/io/gravitee/repository/management/model/Subscription.java @@ -125,7 +125,7 @@ public enum AuditEvent implements Audit.ApiAuditEvent { private String generalConditionsContentPageId; private Boolean generalConditionsAccepted; /** - * Number of days before the expiration of this subscription when the last pre-expiration notification was sent + * Number of days before the pollInterval of this subscription when the last pre-pollInterval notification was sent */ private Integer daysToExpirationOnLastNotification; private String configuration; diff --git a/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/ApiKeyMongo.java b/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/ApiKeyMongo.java index 46e8975f192..03c10d982c5 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/ApiKeyMongo.java +++ b/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/ApiKeyMongo.java @@ -17,7 +17,6 @@ import java.util.Date; import java.util.HashSet; -import java.util.Objects; import java.util.Set; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -160,7 +159,7 @@ public class ApiKeyMongo { private boolean federated; /** - * Number of days before the expiration of this API Key when the last pre-expiration notification was sent + * Number of days before the pollInterval of this API Key when the last pre-pollInterval notification was sent */ @Setter @Getter diff --git a/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/SubscriptionMongo.java b/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/SubscriptionMongo.java index d849b171b04..afeb72e6a67 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/SubscriptionMongo.java +++ b/gravitee-apim-repository/gravitee-apim-repository-mongodb/src/main/java/io/gravitee/repository/mongodb/management/internal/model/SubscriptionMongo.java @@ -122,7 +122,7 @@ public class SubscriptionMongo extends Auditable { private Boolean generalConditionsAccepted; /** - * Number of days before the expiration of this subscription when the last pre-expiration notification was sent + * Number of days before the pollInterval of this subscription when the last pre-pollInterval notification was sent */ private Integer daysToExpirationOnLastNotification; diff --git a/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/ApiKeyRepositoryTest.java b/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/ApiKeyRepositoryTest.java index 371330f4d67..cb6d8baa5ef 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/ApiKeyRepositoryTest.java +++ b/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/ApiKeyRepositoryTest.java @@ -72,11 +72,11 @@ public void create_should_create_apiKey_with_right_data() throws Exception { assertNotNull("API Key not found", keyFound); assertEquals("Key value saved doesn't match", apiKey.getKey(), keyFound.getKey()); - assertTrue("Key expiration doesn't match", compareDate(apiKey.getExpireAt(), keyFound.getExpireAt())); + assertTrue("Key pollInterval doesn't match", compareDate(apiKey.getExpireAt(), keyFound.getExpireAt())); assertEquals("Key paused status doesn't match", apiKey.isPaused(), keyFound.isPaused()); assertEquals("Key revoked status doesn't match", apiKey.isRevoked(), keyFound.isRevoked()); assertEquals( - "Days to expiration on last notification don't match", + "Days to pollInterval on last notification don't match", apiKey.getDaysToExpirationOnLastNotification(), keyFound.getDaysToExpirationOnLastNotification() ); @@ -116,7 +116,7 @@ public void findById_should_find_apikey() throws Exception { assertTrue("Key paused status doesn't match", keyFound.isPaused()); assertTrue("Key revoked status doesn't match", keyFound.isRevoked()); assertEquals( - "Days to expiration on last notification don't match", + "Days to pollInterval on last notification don't match", Integer.valueOf(30), keyFound.getDaysToExpirationOnLastNotification() ); diff --git a/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/SubscriptionRepositoryTest.java b/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/SubscriptionRepositoryTest.java index d04ff11e2fa..9c13fff06b8 100644 --- a/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/SubscriptionRepositoryTest.java +++ b/gravitee-apim-repository/gravitee-apim-repository-test/src/test/java/io/gravitee/repository/management/SubscriptionRepositoryTest.java @@ -89,7 +89,7 @@ public void shouldFindByPlan() throws TechnicalException { assertEquals("Subscription configuration", "{}", subscription.getConfiguration()); assertEquals("Subscription type", Subscription.Type.STANDARD, subscription.getType()); assertEquals( - "Subscription days to expiration on last notification", + "Subscription days to pollInterval on last notification", Integer.valueOf(30), subscription.getDaysToExpirationOnLastNotification() ); diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml index 39ef48b46d9..d2d388bb16a 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml @@ -2428,25 +2428,25 @@ paths: default: $ref: "#/components/responses/Error" /environments/{envId}/apis/{apiId}/scoring: - parameters: - - $ref: "#/components/parameters/envIdParam" - - $ref: "#/components/parameters/apiIdParam" - post: - tags: - - API Scoring - summary: Get API Scoring - description: |- - Get API Scoring. - operationId: getApiScoring - responses: - "200": - description: API Scoring - content: - application/json: - schema: - $ref: "#/components/schemas/ApiScoring" - default: - $ref: "#/components/responses/Error" + parameters: + - $ref: "#/components/parameters/envIdParam" + - $ref: "#/components/parameters/apiIdParam" + post: + tags: + - API Scoring + summary: Get API Scoring + description: |- + Get API Scoring. + operationId: getApiScoring + responses: + "200": + description: API Scoring + content: + application/json: + schema: + $ref: "#/components/schemas/ApiScoring" + default: + $ref: "#/components/responses/Error" # Categories @@ -2496,36 +2496,35 @@ paths: # Async Job /environments/{envId}/async-jobs: - parameters: - - $ref: "#/components/parameters/envIdParam" - get: parameters: - - $ref: "#/components/parameters/pageParam" - - $ref: "#/components/parameters/perPageParam" - - name: sourceId - in: query - required: true - description: SourceId to filter - schema: - type: string - - name: status - in: query - required: true - description: Status to filter - schema: - $ref: "#/components/schemas/AsyncJobStatus" - tags: - - AsyncJobs - summary: List Async Jobs - description: |- - Get the list of AsyncJobs. - operationId: listAsyncJob - responses: - "200": - $ref: "#/components/responses/AsyncJobsResponse" - default: - $ref: "#/components/responses/Error" - + - $ref: "#/components/parameters/envIdParam" + get: + parameters: + - $ref: "#/components/parameters/pageParam" + - $ref: "#/components/parameters/perPageParam" + - name: sourceId + in: query + required: true + description: SourceId to filter + schema: + type: string + - name: status + in: query + required: true + description: Status to filter + schema: + $ref: "#/components/schemas/AsyncJobStatus" + tags: + - AsyncJobs + summary: List Async Jobs + description: |- + Get the list of AsyncJobs. + operationId: listAsyncJob + responses: + "200": + $ref: "#/components/responses/AsyncJobsResponse" + default: + $ref: "#/components/responses/Error" components: schemas: @@ -3279,7 +3278,7 @@ components: enum: - MESSAGE - PROXY -# FIXME: Kafka Gateway - properly support it, it has just been added for mapstruct + # FIXME: Kafka Gateway - properly support it, it has just been added for mapstruct - NATIVE Visibility: type: string @@ -3933,7 +3932,7 @@ components: - HTTP - SUBSCRIPTION - TCP -# FIXME: Kafka Gateway: properly support it, it has just been added for mapstruct + # FIXME: Kafka Gateway: properly support it, it has just been added for mapstruct - KAFKA LoadBalancer: type: object @@ -4505,7 +4504,7 @@ components: daysToExpirationOnLastNotification: type: integer format: int32 - description: Number of days before the expiration of this subscription when the last pre-expiration notification was sent. + description: Number of days before the pollInterval of this subscription when the last pre-pollInterval notification was sent. consumerConfiguration: $ref: "#/components/schemas/SubscriptionConsumerConfiguration" failureCause: @@ -4751,11 +4750,11 @@ components: daysToExpirationOnLastNotification: type: integer format: int32 - description: Number of days before the expiration of this subscription when the last pre-expiration notification was sent. + description: Number of days before the pollInterval of this subscription when the last pre-pollInterval notification was sent. expireAt: type: string format: date-time - description: The datetime when the API Key expires. No date means no expiration. + description: The datetime when the API Key expires. No date means no pollInterval. example: 2023-05-18T12:40:46.184Z createdAt: type: string @@ -4779,7 +4778,7 @@ components: expireAt: type: string format: date-time - description: The datetime when the API Key expires. No date means no expiration. + description: The datetime when the API Key expires. No date means no pollInterval. example: 2023-05-18T12:40:46.184Z RenewApiKey: @@ -6666,7 +6665,7 @@ components: type: object description: Configuration of a page additionalProperties: - type: string + type: string source: $ref: "#/components/schemas/PageSource" required: @@ -6896,32 +6895,32 @@ components: items: $ref: "#/components/schemas/ApiScoringAsset" ApiScoringSummary: - type: object - properties: - score: - type: number - description: The score of the API. - example: 0.91 - all: - type: integer - description: The total number of violated rules for all assets. - example: 100 - errors: - type: integer - description: The total number of violated rules with severity ERROR for all assets. - example: 10 - warnings: - type: integer - description: The total number of violated rules with severity WARN for all assets. - example: 20 - infos: - type: integer - description: The total number of violated rules with severity INFO for all assets. - example: 30 - hints: - type: integer - description: The total number of violated rules with severity HINT for all assets. - example: 40 + type: object + properties: + score: + type: number + description: The score of the API. + example: 0.91 + all: + type: integer + description: The total number of violated rules for all assets. + example: 100 + errors: + type: integer + description: The total number of violated rules with severity ERROR for all assets. + example: 10 + warnings: + type: integer + description: The total number of violated rules with severity WARN for all assets. + example: 20 + infos: + type: integer + description: The total number of violated rules with severity INFO for all assets. + example: 30 + hints: + type: integer + description: The total number of violated rules with severity HINT for all assets. + example: 40 ApiScoringAsset: type: object properties: @@ -6990,49 +6989,49 @@ components: # Async Jobs AsyncJob: - type: object - properties: - id: - type: string - description: Id of the job. - example: b21cbef5-02b6-462e-9ee8-694c89c3dee5 - sourceId: - type: string - description: Resource id related to this job. - example: 660bf428-4f06-451f-8144-10bbb581db65 - environmentId: - type: string - description: The environment id - example: DEFAULT - initiatorId: - type: string - description: User id who triggered this job. - example: 660bf428-4f06-451f-8144-10bbb581db65 - type: - type: string - description: Resource id related to this job. - example: FEDERATED_APIS_INGESTION - enum: - - FEDERATED_APIS_INGESTION - - SCORING_REQUEST - status: - $ref: "#/components/schemas/AsyncJobStatus" - errorMessage: - type: string - description: A message detailing why the job failed. - createdAt: - type: string - format: date-time - description: The date when the job has been created. - example: 2023-05-18T12:40:46.184Z + type: object + properties: + id: + type: string + description: Id of the job. + example: b21cbef5-02b6-462e-9ee8-694c89c3dee5 + sourceId: + type: string + description: Resource id related to this job. + example: 660bf428-4f06-451f-8144-10bbb581db65 + environmentId: + type: string + description: The environment id + example: DEFAULT + initiatorId: + type: string + description: User id who triggered this job. + example: 660bf428-4f06-451f-8144-10bbb581db65 + type: + type: string + description: Resource id related to this job. + example: FEDERATED_APIS_INGESTION + enum: + - FEDERATED_APIS_INGESTION + - SCORING_REQUEST + status: + $ref: "#/components/schemas/AsyncJobStatus" + errorMessage: + type: string + description: A message detailing why the job failed. + createdAt: + type: string + format: date-time + description: The date when the job has been created. + example: 2023-05-18T12:40:46.184Z AsyncJobStatus: - type: string - description: Status of the job. - example: SUCCESS - enum: - - SUCCESS - - PENDING - - ERROR + type: string + description: Status of the job. + example: SUCCESS + enum: + - SUCCESS + - PENDING + - ERROR parameters: ############# @@ -7818,21 +7817,21 @@ components: # Async Jobs AsyncJobsResponse: - description: Page of async jobs - content: - application/json: - schema: - title: "AsyncJobsResponse" - properties: - data: - description: List of Async Jobs. - type: array - items: - $ref: "#/components/schemas/AsyncJob" - pagination: - $ref: "#/components/schemas/Pagination" - links: - $ref: "#/components/schemas/Links" + description: Page of async jobs + content: + application/json: + schema: + title: "AsyncJobsResponse" + properties: + data: + description: List of Async Jobs. + type: array + items: + $ref: "#/components/schemas/AsyncJob" + pagination: + $ref: "#/components/schemas/Pagination" + links: + $ref: "#/components/schemas/Links" securitySchemes: BasicAuth: diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-management/gravitee-apim-rest-api-management-rest/src/main/java/io/gravitee/rest/api/management/rest/resource/auth/CockpitAuthenticationResource.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-management/gravitee-apim-rest-api-management-rest/src/main/java/io/gravitee/rest/api/management/rest/resource/auth/CockpitAuthenticationResource.java index c7ec37e5365..031e81e2bab 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-management/gravitee-apim-rest-api-management-rest/src/main/java/io/gravitee/rest/api/management/rest/resource/auth/CockpitAuthenticationResource.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-management/gravitee-apim-rest-api-management-rest/src/main/java/io/gravitee/rest/api/management/rest/resource/auth/CockpitAuthenticationResource.java @@ -117,7 +117,7 @@ public void afterPropertiesSet() { if (enabled) { try { - // Initialize the JWT processor which will handle JWT signature verification and assertions such as expiration time. + // Initialize the JWT processor which will handle JWT signature verification and assertions such as pollInterval time. final RSAKey rsaKey = new RSAKey.Builder((RSAPublicKey) getPublicKey()).keyID(KID).build(); final JWSAlgorithmFamilyJWSKeySelector jwsKeySelector = new JWSAlgorithmFamilyJWSKeySelector<>( JWSAlgorithm.Family.RSA, diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/ApiKeyEntity.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/ApiKeyEntity.java index 368195875b6..30487409ee8 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/ApiKeyEntity.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/ApiKeyEntity.java @@ -15,11 +15,15 @@ */ package io.gravitee.rest.api.model; -import static java.util.stream.Collectors.*; +import static java.util.stream.Collectors.toList; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.*; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -75,7 +79,7 @@ public class ApiKeyEntity { private boolean federated; /** - * Number of days before the expiration of this API Key when the last pre-expiration notification was sent + * Number of days before the pollInterval of this API Key when the last pre-pollInterval notification was sent */ private Integer daysToExpirationOnLastNotification; diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/SubscriptionEntity.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/SubscriptionEntity.java index 1a7448d8921..7e840519e1f 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/SubscriptionEntity.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-model/src/main/java/io/gravitee/rest/api/model/SubscriptionEntity.java @@ -98,7 +98,7 @@ public class SubscriptionEntity { private String security; /** - * Number of days before the expiration of this subscription when the last pre-expiration notification was sent + * Number of days before the pollInterval of this subscription when the last pre-pollInterval notification was sent */ private Integer daysToExpirationOnLastNotification; diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/api_key/model/ApiKeyEntity.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/api_key/model/ApiKeyEntity.java index 5814fc0269b..46c8f166039 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/api_key/model/ApiKeyEntity.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/api_key/model/ApiKeyEntity.java @@ -58,7 +58,7 @@ public class ApiKeyEntity { private boolean federated; /** - * Number of days before the expiration of this API Key when the last pre-expiration notification was sent + * Number of days before the pollInterval of this API Key when the last pre-pollInterval notification was sent */ private Integer daysToExpirationOnLastNotification; diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/subscription/model/SubscriptionEntity.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/subscription/model/SubscriptionEntity.java index b2b47f42b86..b8112ad2528 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/subscription/model/SubscriptionEntity.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/apim/core/subscription/model/SubscriptionEntity.java @@ -76,7 +76,7 @@ public class SubscriptionEntity { private Integer generalConditionsContentRevision; private String generalConditionsContentPageId; private Boolean generalConditionsAccepted; - /** Number of days before the expiration of this subscription when the last pre-expiration notification was sent */ + /** Number of days before the pollInterval of this subscription when the last pre-pollInterval notification was sent */ private Integer daysToExpirationOnLastNotification; private SubscriptionConfiguration configuration; private Map metadata; diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/builder/EmailNotificationBuilder.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/builder/EmailNotificationBuilder.java index ee330670d10..e2ac6b0211f 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/builder/EmailNotificationBuilder.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/builder/EmailNotificationBuilder.java @@ -16,7 +16,12 @@ package io.gravitee.rest.api.service.builder; import io.gravitee.rest.api.service.EmailNotification; -import io.gravitee.rest.api.service.notification.*; +import io.gravitee.rest.api.service.notification.ActionHook; +import io.gravitee.rest.api.service.notification.AlertHook; +import io.gravitee.rest.api.service.notification.ApiHook; +import io.gravitee.rest.api.service.notification.ApplicationHook; +import io.gravitee.rest.api.service.notification.Hook; +import io.gravitee.rest.api.service.notification.PortalHook; import java.util.HashMap; import java.util.Map; @@ -83,7 +88,7 @@ public EmailNotification build() { public enum EmailTemplate { API_APIKEY_REVOKED(ApiHook.APIKEY_REVOKED, "apiKeyRevoked.html", "API Key revoked for API ${api.name}"), API_APIKEY_RENEWED(ApiHook.APIKEY_RENEWED, "apiKeyRenewed.html", "API Key renewed"), - API_APIKEY_EXPIRED(ApiHook.APIKEY_EXPIRED, "apiKeyExpired.html", "API Key expiration!"), + API_APIKEY_EXPIRED(ApiHook.APIKEY_EXPIRED, "apiKeyExpired.html", "API Key pollInterval!"), API_SUBSCRIPTION_NEW( ApiHook.SUBSCRIPTION_NEW, "subscriptionReceived.html", diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/AlertServiceImpl.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/AlertServiceImpl.java index 8fec31689e2..f5e135bd1cd 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/AlertServiceImpl.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/AlertServiceImpl.java @@ -51,19 +51,44 @@ import io.gravitee.repository.management.model.AlertTrigger; import io.gravitee.rest.api.model.AlertEventQuery; import io.gravitee.rest.api.model.EnvironmentEntity; -import io.gravitee.rest.api.model.alert.*; +import io.gravitee.rest.api.model.alert.AlertEventEntity; +import io.gravitee.rest.api.model.alert.AlertReferenceType; +import io.gravitee.rest.api.model.alert.AlertStatusEntity; +import io.gravitee.rest.api.model.alert.AlertTriggerEntity; +import io.gravitee.rest.api.model.alert.NewAlertTriggerEntity; +import io.gravitee.rest.api.model.alert.UpdateAlertTriggerEntity; import io.gravitee.rest.api.model.common.PageableImpl; import io.gravitee.rest.api.model.parameters.Key; import io.gravitee.rest.api.model.parameters.ParameterReferenceType; -import io.gravitee.rest.api.service.*; +import io.gravitee.rest.api.service.AlertService; +import io.gravitee.rest.api.service.ApiService; +import io.gravitee.rest.api.service.ApplicationService; +import io.gravitee.rest.api.service.EnvironmentService; +import io.gravitee.rest.api.service.ParameterService; +import io.gravitee.rest.api.service.PlanService; import io.gravitee.rest.api.service.common.ExecutionContext; import io.gravitee.rest.api.service.common.ReferenceContext; import io.gravitee.rest.api.service.converter.AlertTriggerConverter; -import io.gravitee.rest.api.service.exceptions.*; +import io.gravitee.rest.api.service.exceptions.AlertNotFoundException; +import io.gravitee.rest.api.service.exceptions.AlertTemplateInvalidException; +import io.gravitee.rest.api.service.exceptions.AlertUnavailableException; +import io.gravitee.rest.api.service.exceptions.ApiNotFoundException; +import io.gravitee.rest.api.service.exceptions.ApplicationNotFoundException; +import io.gravitee.rest.api.service.exceptions.PlanNotFoundException; +import io.gravitee.rest.api.service.exceptions.TechnicalManagementException; import io.gravitee.rest.api.service.impl.alert.EmailNotifierConfiguration; import java.io.IOException; import java.time.Duration; -import java.util.*; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.function.Supplier; import java.util.stream.Collectors; import org.slf4j.Logger; @@ -315,7 +340,7 @@ public List findByReferenceWithEventCounts(final AlertRefere from.toInstant().minus(Duration.ofDays(30)) ) .entrySet() - // Get the count of events for each time period in parallel to speed up the process + // Get the count of events for each time pollInterval in parallel to speed up the process .parallelStream() .map(entry -> new AbstractMap.SimpleEntry<>( diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiKeyServiceImpl.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiKeyServiceImpl.java index 3c6f8669220..3ecca0363a6 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiKeyServiceImpl.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiKeyServiceImpl.java @@ -360,7 +360,7 @@ public ApiKeyEntity reactivate(ExecutionContext executionContext, ApiKeyEntity a key.setRevokedAt(null); // If this is not a shared API Key, - // Get the subscription to get ending date and set key expiration date + // Get the subscription to get ending date and set key pollInterval date if (!apiKeyEntity.getApplication().hasApiKeySharedMode()) { SubscriptionEntity subscription = subscriptionService.findById(key.getSubscriptions().get(0)); if (subscription.getStatus() != SubscriptionStatus.PAUSED && subscription.getStatus() != SubscriptionStatus.ACCEPTED) { @@ -583,7 +583,7 @@ private void updateExpirationDate(ExecutionContext executionContext, Date expira return; } - // If the expiration date is before now, then the key is already expired + // If the pollInterval date is before now, then the key is already expired if (expirationDate != null && expirationDate.before(now)) { expirationDate = now; } @@ -611,7 +611,7 @@ private void updateExpirationDate(ExecutionContext executionContext, Date expira // Audit createAuditLog(executionContext, convert(executionContext, key), oldkey, APIKEY_EXPIRED, key.getUpdatedAt()); - // If there is an expiration date then notify + // If there is an pollInterval date then notify if (expirationDate != null) { NotificationParamsBuilder paramsBuilder = new NotificationParamsBuilder(); if (key.getExpireAt() != null && now.before(key.getExpireAt())) { diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiServiceImpl.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiServiceImpl.java index 0bcd3c4f2c9..26f58219317 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiServiceImpl.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiServiceImpl.java @@ -1761,6 +1761,7 @@ private ApiEntity deployCurrentAPI( Map properties = new HashMap<>(); properties.put(Event.EventProperties.USER.getValue(), userId); + properties.put(Event.EventProperties.API_CROSS_ID.getValue(), api.getCrossId()); // Clear useless field for history api.setPicture(null); diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/EventServiceImpl.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/EventServiceImpl.java index 1dba7a9d793..ef19da6c740 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/EventServiceImpl.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/EventServiceImpl.java @@ -62,7 +62,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.function.Consumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -158,6 +157,7 @@ public EventEntity createApiEvent( Api apiDefinition = api != null ? buildApiEventPayload(executionContext, api) : null; if (apiDefinition != null) { eventProperties.put(Event.EventProperties.API_ID.getValue(), apiDefinition.getId()); + eventProperties.put(Event.EventProperties.API_CROSS_ID.getValue(), api.getCrossId()); } EventEntity event = createEvent(executionContext, environmentsIds, organizationId, type, apiDefinition, eventProperties); if (apiDefinition != null) { diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/SubscriptionServiceImpl.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/SubscriptionServiceImpl.java index e52ab689139..529cca45270 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/SubscriptionServiceImpl.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/SubscriptionServiceImpl.java @@ -786,7 +786,7 @@ public SubscriptionEntity update( subscription.setUpdatedAt(new Date()); subscription.setStartingAt(updateSubscription.getStartingAt()); subscription.setEndingAt(updateSubscription.getEndingAt()); - // Reset info about pre expiration notification as the expiration date has changed + // Reset info about pre pollInterval notification as the pollInterval date has changed subscription.setDaysToExpirationOnLastNotification(null); subscriptionTransformer.accept(subscription); @@ -801,7 +801,7 @@ public SubscriptionEntity update( subscription ); - // Update the expiration date for not yet revoked api-keys relative to this subscription (except for shared API Keys) + // Update the pollInterval date for not yet revoked api-keys relative to this subscription (except for shared API Keys) PlanSecurity planSecurity = genericPlanEntity.getPlanSecurity(); if (planSecurity != null) { Date endingAt = subscription.getEndingAt(); diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/notification/ActionHook.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/notification/ActionHook.java index a175fac038f..391431e1740 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/notification/ActionHook.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/notification/ActionHook.java @@ -42,7 +42,7 @@ public enum ActionHook implements Hook { USER_GROUP_INVITATION("User group invitation", "Email sent when using the messaging service.", "USER"), USER_PASSWORD_RESET("User password reset", "Email sent to a user which password has been reset.", "USER"), SUBSCRIPTION_PRE_EXPIRATION( - "Subscription pre-expiration notification", + "Subscription pre-pollInterval notification", "Email sent to the subscriber and the primary owner of an application when a the subscription will expire after a specific duration.", "SUBSCRIPTION" ); diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTest.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTest.java index 5911459607f..5f21c39f306 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTest.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTest.java @@ -15,11 +15,49 @@ */ package io.gravitee.rest.api.service.impl; -import static io.gravitee.rest.api.model.parameters.Key.*; +import static io.gravitee.rest.api.model.parameters.Key.ALERT_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.ANALYTICS_CLIENT_TIMEOUT; +import static io.gravitee.rest.api.model.parameters.Key.API_LABELS_DICTIONARY; +import static io.gravitee.rest.api.model.parameters.Key.COMPANY_NAME; +import static io.gravitee.rest.api.model.parameters.Key.CONSOLE_AUTHENTICATION_LOCALLOGIN_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.CONSOLE_HTTP_CORS_EXPOSED_HEADERS; +import static io.gravitee.rest.api.model.parameters.Key.CONSOLE_SCHEDULER_NOTIFICATIONS; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_FROM; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_HOST; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_PASSWORD; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_PORT; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_PROPERTIES_AUTH_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_PROPERTIES_SSL_TRUST; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_PROPERTIES_STARTTLS_ENABLE; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_PROTOCOL; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_SUBJECT; +import static io.gravitee.rest.api.model.parameters.Key.EMAIL_USERNAME; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_AUDIT_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_AUDIT_TRAIL_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_DEFAULT_MAX_DURATION; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_MESSAGE_SAMPLING_COUNT_DEFAULT; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_MESSAGE_SAMPLING_COUNT_LIMIT; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_MESSAGE_SAMPLING_PROBABILISTIC_DEFAULT; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_MESSAGE_SAMPLING_PROBABILISTIC_LIMIT; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_MESSAGE_SAMPLING_TEMPORAL_DEFAULT; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_MESSAGE_SAMPLING_TEMPORAL_LIMIT; +import static io.gravitee.rest.api.model.parameters.Key.LOGGING_USER_DISPLAYED; +import static io.gravitee.rest.api.model.parameters.Key.OPEN_API_DOC_TYPE_SWAGGER_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.PORTAL_ANALYTICS_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.PORTAL_AUTHENTICATION_FORCELOGIN_ENABLED; +import static io.gravitee.rest.api.model.parameters.Key.PORTAL_HTTP_CORS_EXPOSED_HEADERS; +import static io.gravitee.rest.api.model.parameters.Key.PORTAL_SCHEDULER_NOTIFICATIONS; +import static io.gravitee.rest.api.model.parameters.Key.PORTAL_URL; +import static io.gravitee.rest.api.model.parameters.Key.TRIAL_INSTANCE; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import io.gravitee.apim.core.installation.query_service.InstallationAccessQueryService; import io.gravitee.repository.management.model.Parameter; @@ -232,7 +270,9 @@ public void shouldGetConsoleSettings() { assertThat(consoleSettings.getCors().getExposedHeaders()).as("cors exposed headers").hasSize(2); assertThat(consoleSettings.getAnalyticsPendo().getEnabled()).as("analytics pendo enabled").isFalse(); assertThat(consoleSettings.getAnalyticsPendo().getApiKey()).as("analytics pendo apiKey").isEmpty(); - assertThat(consoleSettings.getLicenseExpirationNotification().getEnabled()).as("license expiration notification enabled").isTrue(); + assertThat(consoleSettings.getLicenseExpirationNotification().getEnabled()) + .as("license pollInterval notification enabled") + .isTrue(); assertThat(consoleSettings.getEmail().getEnabled()).as("email enabled").isTrue(); } @@ -268,7 +308,9 @@ public void shouldGetConsoleSettingsForTrialInstance() { assertThat(consoleSettings.getCors().getExposedHeaders()).as("cors exposed headers").hasSize(2); assertThat(consoleSettings.getAnalyticsPendo().getEnabled()).as("analytics pendo enabled").isFalse(); assertThat(consoleSettings.getAnalyticsPendo().getApiKey()).as("analytics pendo apiKey").isEmpty(); - assertThat(consoleSettings.getLicenseExpirationNotification().getEnabled()).as("license expiration notification enabled").isTrue(); + assertThat(consoleSettings.getLicenseExpirationNotification().getEnabled()) + .as("license pollInterval notification enabled") + .isTrue(); assertThat(consoleSettings.getEmail()).as("email should be null").isNull(); } @@ -299,7 +341,7 @@ public void shouldGetConsoleConfig() { assertThat(consoleConfig.getReCaptcha().getSiteKey()).as("recaptcha siteKey").isEqualTo("my-site-key"); assertThat(consoleConfig.getAlert().getEnabled()).as("alerting enabled").isTrue(); assertThat(consoleConfig.getReCaptcha().getEnabled()).as("recaptcha enabled").isTrue(); - assertThat(consoleConfig.getLicenseExpirationNotification().getEnabled()).as("license expiration notification enabled").isTrue(); + assertThat(consoleConfig.getLicenseExpirationNotification().getEnabled()).as("license pollInterval notification enabled").isTrue(); } @Test diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTestNew.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTestNew.java index d9b1295eac8..754014eaffb 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTestNew.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/ConfigServiceTestNew.java @@ -262,7 +262,7 @@ void shouldGetConsoleSettings() { assertThat(consoleSettings.getAnalyticsPendo().getEnabled()).as("analytics pendo enabled").isEqualTo(Boolean.FALSE); assertThat(consoleSettings.getAnalyticsPendo().getApiKey()).as("analytics pendo apiKey").isEqualTo(""); assertThat(consoleSettings.getLicenseExpirationNotification().getEnabled()) - .as("license expiration notification enabled") + .as("license pollInterval notification enabled") .isEqualTo(Boolean.TRUE); } @@ -294,7 +294,7 @@ void shouldGetConsoleConfig() { assertThat(consoleConfig.getAlert().getEnabled()).as("alerting enabled").isEqualTo(Boolean.TRUE); assertThat(consoleConfig.getReCaptcha().getEnabled()).as("recaptcha enabled").isEqualTo(Boolean.TRUE); assertThat(consoleConfig.getLicenseExpirationNotification().getEnabled()) - .as("license expiration notification enabled") + .as("license pollInterval notification enabled") .isEqualTo(Boolean.TRUE); } diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/SubscriptionServiceTest.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/SubscriptionServiceTest.java index f05ce7db66f..8f76c98a3be 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/SubscriptionServiceTest.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/rest/api/service/impl/SubscriptionServiceTest.java @@ -135,7 +135,6 @@ import java.util.Optional; import java.util.Set; import java.util.function.BiFunction; -import java.util.function.Consumer; import org.apache.commons.lang3.time.FastDateFormat; import org.assertj.core.api.Assertions; import org.junit.AfterClass; @@ -1841,7 +1840,7 @@ public void shouldUpdateSubscriptionWithEndingDateAndSetApiKeyExpirationIfNotSha // Run subscriptionService.update(GraviteeContext.getExecutionContext(), updatedSubscription); - // verify apikey 1 and 3 expiration date has been updated as they are not revoked nor expired + // verify apikey 1 and 3 pollInterval date has been updated as they are not revoked nor expired verify(subscriptionRepository, times(1)).update(subscription); verify(apiKeyService, times(1)).findBySubscription(GraviteeContext.getExecutionContext(), SUBSCRIPTION_ID); verify(apiKeyService, times(1)) diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationService.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationService.java index ee13e15adae..16f972475e2 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationService.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationService.java @@ -33,7 +33,6 @@ import io.gravitee.rest.api.service.UserService; import io.gravitee.rest.api.service.builder.EmailNotificationBuilder; import io.gravitee.rest.api.service.common.GraviteeContext; -import io.gravitee.rest.api.service.common.ReferenceContext; import io.gravitee.rest.api.service.notification.NotificationParamsBuilder; import io.gravitee.rest.api.service.v4.ApiSearchService; import io.gravitee.rest.api.service.v4.PlanSearchService; @@ -195,7 +194,7 @@ List getCleanedNotificationDays(List inputDays) { if (!invalidValues.isEmpty()) { logger.warn( - "The configuration key `services.subscription.pre-expiration-notification-schedule` contains some invalid values: {}. Values should be between {} and {} (days).", + "The configuration key `services.subscription.pre-pollInterval-notification-schedule` contains some invalid values: {}. Values should be between {} and {} (days).", invalidValues.stream().map(Object::toString).collect(Collectors.joining(", ")), min, max diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/spring/SubscriptionPreExpirationNotificationConfiguration.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/spring/SubscriptionPreExpirationNotificationConfiguration.java index bdb8f17a138..3203bf55bb5 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/spring/SubscriptionPreExpirationNotificationConfiguration.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/main/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/spring/SubscriptionPreExpirationNotificationConfiguration.java @@ -28,7 +28,7 @@ public class SubscriptionPreExpirationNotificationConfiguration { @Qualifier("subscriptionPreExpirationTaskScheduler") public TaskScheduler taskScheduler() { ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); - scheduler.setThreadNamePrefix("subscription-pre-expiration-notification-"); + scheduler.setThreadNamePrefix("subscription-pre-pollInterval-notification-"); return scheduler; } } diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/test/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationServiceTest.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/test/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationServiceTest.java index 77285c193c4..5ff0098548d 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/test/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationServiceTest.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-services/gravitee-apim-rest-api-services-subscription-pre-expiration-notif/src/test/java/io/gravitee/rest/api/services/subscriptionpreexpirationnotif/ScheduledSubscriptionPreExpirationNotificationServiceTest.java @@ -16,17 +16,39 @@ package io.gravitee.rest.api.services.subscriptionpreexpirationnotif; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.*; - -import io.gravitee.rest.api.model.*; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.argThat; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import io.gravitee.rest.api.model.ApiKeyEntity; +import io.gravitee.rest.api.model.ApplicationEntity; +import io.gravitee.rest.api.model.PlanEntity; +import io.gravitee.rest.api.model.PrimaryOwnerEntity; +import io.gravitee.rest.api.model.SubscriptionEntity; +import io.gravitee.rest.api.model.SubscriptionStatus; +import io.gravitee.rest.api.model.UserEntity; import io.gravitee.rest.api.model.api.ApiEntity; import io.gravitee.rest.api.model.key.ApiKeyQuery; import io.gravitee.rest.api.model.subscription.SubscriptionQuery; -import io.gravitee.rest.api.service.*; +import io.gravitee.rest.api.service.ApiKeyService; +import io.gravitee.rest.api.service.EmailNotification; +import io.gravitee.rest.api.service.EmailService; +import io.gravitee.rest.api.service.SubscriptionService; +import io.gravitee.rest.api.service.UserService; import io.gravitee.rest.api.service.builder.EmailNotificationBuilder; import io.gravitee.rest.api.service.common.GraviteeContext; import java.time.Instant; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -81,7 +103,7 @@ public void shouldFindSubscriptionExpirationsToNotify() { // 1469886010000 -> now + 10 days subscriptionQuery.getEndingAtAfter() == 1469886010000L && - // 1469889610000 -> now + 10 days + 1h (cron period) + // 1469889610000 -> now + 10 days + 1h (cron pollInterval) subscriptionQuery.getEndingAtBefore() == 1469889610000L ) @@ -185,7 +207,7 @@ public void shouldFindApiKeyExpirationsToNotify() { // 1469886010000 -> now + 10 days apiKeyQuery.getExpireAfter() == 1469886010000L && - // 1469889610000 -> now + 10 days + 1h (cron period) + // 1469889610000 -> now + 10 days + 1h (cron pollInterval) apiKeyQuery.getExpireBefore() == 1469889610000L ) diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-standalone/gravitee-apim-rest-api-standalone-distribution/src/main/resources/config/gravitee.yml b/gravitee-apim-rest-api/gravitee-apim-rest-api-standalone/gravitee-apim-rest-api-standalone-distribution/src/main/resources/config/gravitee.yml index 148fbc1a922..40f86577fb8 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-standalone/gravitee-apim-rest-api-standalone-distribution/src/main/resources/config/gravitee.yml +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-standalone/gravitee-apim-rest-api-standalone-distribution/src/main/resources/config/gravitee.yml @@ -55,47 +55,47 @@ # password: secret http: - api: - # Configure the listening path for the API. Default to / -# entrypoint: / + api: + # Configure the listening path for the API. Default to / + # entrypoint: / # Configure Management API and Portal API. -# management: -# enabled: true -# entrypoint: ${http.api.entrypoint}management -# cors: -# Allows to configure the header Access-Control-Allow-Origin (default value: *) -# '*' is a valid value but is considered as a security risk as it will be opened to cross origin requests from anywhere. -# allow-origin: '*' -# Allows to define how long the result of the preflight request should be cached for (default value; 1728000 [20 days]) -# max-age: 1728000 -# Which methods to allow (default value: OPTIONS, GET, POST, PUT, DELETE) -# allow-methods: 'OPTIONS, GET, POST, PUT, DELETE' -# Which headers to allow (default values: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token) -# allow-headers: 'Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token' -# Allows to configure the header Access-Control-Expose-Headers -# exposed-headers: 'ETag;X-Xsrf-Token' -# portal: -# enabled: true -# entrypoint: ${http.api.entrypoint}portal -# cors: -# Allows to configure the header Access-Control-Allow-Origin (default value: *) -# '*' is a valid value but is considered as a security risk as it will be opened to cross origin requests from anywhere. -# allow-origin: '*' -# Allows to define how long the result of the preflight request should be cached for (default value; 1728000 [20 days]) -# max-age: 1728000 -# Which methods to allow (default value: OPTIONS, GET, POST, PUT, DELETE) -# allow-methods: 'OPTIONS, GET, POST, PUT, DELETE' -# Which headers to allow (default values: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token) -# allow-headers: 'Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token' -# Allows to configure the header Access-Control-Expose-Headers -# exposed-headers: 'ETag;X-Xsrf-Token' - csrf: - # Allows to enable or disable the CSRF protection. Enabled by default. - enabled: true - hsts: - enabled: true - include-sub-domains: true - max-age: 31536000 + # management: + # enabled: true + # entrypoint: ${http.api.entrypoint}management + # cors: + # Allows to configure the header Access-Control-Allow-Origin (default value: *) + # '*' is a valid value but is considered as a security risk as it will be opened to cross origin requests from anywhere. + # allow-origin: '*' + # Allows to define how long the result of the preflight request should be cached for (default value; 1728000 [20 days]) + # max-age: 1728000 + # Which methods to allow (default value: OPTIONS, GET, POST, PUT, DELETE) + # allow-methods: 'OPTIONS, GET, POST, PUT, DELETE' + # Which headers to allow (default values: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token) + # allow-headers: 'Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token' + # Allows to configure the header Access-Control-Expose-Headers + # exposed-headers: 'ETag;X-Xsrf-Token' + # portal: + # enabled: true + # entrypoint: ${http.api.entrypoint}portal + # cors: + # Allows to configure the header Access-Control-Allow-Origin (default value: *) + # '*' is a valid value but is considered as a security risk as it will be opened to cross origin requests from anywhere. + # allow-origin: '*' + # Allows to define how long the result of the preflight request should be cached for (default value; 1728000 [20 days]) + # max-age: 1728000 + # Which methods to allow (default value: OPTIONS, GET, POST, PUT, DELETE) + # allow-methods: 'OPTIONS, GET, POST, PUT, DELETE' + # Which headers to allow (default values: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token) + # allow-headers: 'Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With, If-Match, X-Xsrf-Token' + # Allows to configure the header Access-Control-Expose-Headers + # exposed-headers: 'ETag;X-Xsrf-Token' + csrf: + # Allows to enable or disable the CSRF protection. Enabled by default. + enabled: true + hsts: + enabled: true + include-sub-domains: true + max-age: 31536000 # Plugins repository #plugins: @@ -109,12 +109,12 @@ http: # For more information about MongoDB configuration, please have a look to: # - http://mongodb.github.io/mongo-java-driver/4.1/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html management: - type: mongodb # repository type - mongodb: # mongodb repository -# prefix: # collections prefix - dbname: ${ds.mongodb.dbname} # mongodb name (default gravitee) - host: ${ds.mongodb.host} # mongodb host (default localhost) - port: ${ds.mongodb.port} # mongodb port (default 27017) + type: mongodb # repository type + mongodb: # mongodb repository + # prefix: # collections prefix + dbname: ${ds.mongodb.dbname} # mongodb name (default gravitee) + host: ${ds.mongodb.host} # mongodb host (default localhost) + port: ${ds.mongodb.port} # mongodb port (default 27017) ## Client settings # description: # mongodb description (default gravitee.io) @@ -183,93 +183,92 @@ management: # socketTimeout: 250 services: - core: - http: - enabled: true - port: 18083 - host: localhost - authentication: - # authentication type to be used for the core services - # - none : to disable authentication - # - basic : to use basic authentication - # default is "basic" - type: basic - users: - admin: adminadmin - bridge: - http: - enabled: false - # port: 18092 - # host: localhost - # tcpKeepAlive: true - # maxHeaderSize: 8192 - # maxChunkSize: 8192 - # alpn: false - # authentication: - # type: none # Supports: Basic, JWT - # # type = JWT - # jwt: - # signature: - # algorithm: RS256 - # path: ${gravitee.home}/security/bridge/public_key.pem - # value: # raw pem file as a strign block - # verifyClaims: true - # # type = Basic - # users: - # admin: secret - # superadmin: password - # secured: true - # ssl: - # clientAuth: None # Supports: Request, Required - # keystore: - # type: jks # Supports: PKCS12, PEM - # path: ${gravitee.home}/security/keystore.jks - # password: secret - # defaultAlias: - # secret: secret://kubernetes/my-tls - # watch: true - # # for type= PEM - # certificates: - # - cert: ${gravitee.home}/security/cert1.pem - # key: ${gravitee.home}/security/key1.pem - # - cert: ${gravitee.home}/security/cert2.pem - # key: ${gravitee.home}/security/key2.pem - # truststore: - # type: jks # Supports: PKCS12, PEM - # path: ${gravitee.home}/security/truststore.jks - # password: secret - # secret: secret://kubernetes/my-tls - - # metrics service - metrics: - enabled: false - prometheus: - enabled: true - - # v3 upgrader service. Can be disabled after first launch. - v3-upgrader: - enabled: true - # AutoFetch service. (since 3.2) - # Use to fetch periodically documentation pages. - auto_fetch: - enabled: true - cron: "0 */5 * * * *" - - # Subscription service - subscription: - enabled: true - # Pre-expiration notification, number of days before the expiration an email should be send to subscriber and primary owner - pre-expiration-notification-schedule: 90,45,30 - + core: + http: + enabled: true + port: 18083 + host: localhost + authentication: + # authentication type to be used for the core services + # - none : to disable authentication + # - basic : to use basic authentication + # default is "basic" + type: basic + users: + admin: adminadmin + bridge: + http: + enabled: false + # port: 18092 + # host: localhost + # tcpKeepAlive: true + # maxHeaderSize: 8192 + # maxChunkSize: 8192 + # alpn: false + # authentication: + # type: none # Supports: Basic, JWT + # # type = JWT + # jwt: + # signature: + # algorithm: RS256 + # path: ${gravitee.home}/security/bridge/public_key.pem + # value: # raw pem file as a strign block + # verifyClaims: true + # # type = Basic + # users: + # admin: secret + # superadmin: password + # secured: true + # ssl: + # clientAuth: None # Supports: Request, Required + # keystore: + # type: jks # Supports: PKCS12, PEM + # path: ${gravitee.home}/security/keystore.jks + # password: secret + # defaultAlias: + # secret: secret://kubernetes/my-tls + # watch: true + # # for type= PEM + # certificates: + # - cert: ${gravitee.home}/security/cert1.pem + # key: ${gravitee.home}/security/key1.pem + # - cert: ${gravitee.home}/security/cert2.pem + # key: ${gravitee.home}/security/key2.pem + # truststore: + # type: jks # Supports: PKCS12, PEM + # path: ${gravitee.home}/security/truststore.jks + # password: secret + # secret: secret://kubernetes/my-tls + + # metrics service + metrics: + enabled: false + prometheus: + enabled: true + + # v3 upgrader service. Can be disabled after first launch. + v3-upgrader: + enabled: true + # AutoFetch service. (since 3.2) + # Use to fetch periodically documentation pages. + auto_fetch: + enabled: true + cron: "0 */5 * * * *" + + # Subscription service + subscription: + enabled: true + # Pre-pollInterval notification, number of days before the pollInterval an email should be send to subscriber and primary owner + pre-expiration-notification-schedule: 90,45,30 # Analytics repository is used to store all reporting, metrics, health-checks stored by gateway instances # This is the default configuration using Elasticsearch. If you want to disable it completely, you can set # the type as "none" analytics: - type: elasticsearch # or none - elasticsearch: - endpoints: - - http://${ds.elastic.host}:${ds.elastic.port} + type: elasticsearch # or none + elasticsearch: + endpoints: + - http://${ds.elastic.host}:${ds.elastic.port} # index: gravitee # index_per_type: true # index_mode: daily # "daily" indexes, suffixed with date. Or "ilm" managed indexes, without date @@ -315,60 +314,60 @@ analytics: # API_CONSUMER: Can create and manage Applications # ADMIN: Can manage global system security: - # When using an authentication providers, use trustAll mode for TLS connections - # trustAll: false - providers: # authentication providers - - type: memory - # allow search results to display the user email. Be careful, It may be contrary to the user privacy. + # When using an authentication providers, use trustAll mode for TLS connections + # trustAll: false + providers: # authentication providers + - type: memory + # allow search results to display the user email. Be careful, It may be contrary to the user privacy. + # allow-email-in-search-results: true + # password encoding/hashing algorithm. One of: + # - bcrypt : passwords are hashed with bcrypt (supports only $2a$ algorithm) + # - none : passwords are not hashed/encrypted + # default value is bcrypt + password-encoding-algo: bcrypt + users: + - user: + username: user + #firstname: + #lastname: + # Passwords are encoded using BCrypt + # Password value: password + password: $2a$10$9kjw/SH9gucCId3Lnt6EmuFreUAcXSZgpvAYuW2ISv7hSOhHRH1AO + roles: ORGANIZATION:USER,ENVIRONMENT:USER + # Useful to receive notifications + #email: + - user: + username: admin + #firstname: + #lastname: + # Password value: admin + password: $2a$10$Ihk05VSds5rUSgMdsMVi9OKMIx2yUvMz7y9VP3rJmQeizZLrhLMyq + roles: ORGANIZATION:ADMIN,ENVIRONMENT:ADMIN + #email: + - user: + username: api1 + #firstname: + #lastname: + # Password value: api1 + password: $2a$10$iXdXO4wAYdhx2LOwijsp7.PsoAZQ05zEdHxbriIYCbtyo.y32LTji + # You can declare multiple roles using comma separator + roles: ORGANIZATION:USER,ENVIRONMENT:API_PUBLISHER + #email: + - user: + username: application1 + #firstname: + #lastname: + # Password value: application1 + password: $2a$10$2gtKPYRB9zaVaPcn5RBx/.3T.7SeZoDGs9GKqbo9G64fKyXFR1He. + roles: ORGANIZATION:USER,ENVIRONMENT:USER + #email: + # Enable authentication using internal repository + - type: gravitee + # allow search results to display the user email. Be careful, It may be contrary to the user privacy. # allow-email-in-search-results: true - # password encoding/hashing algorithm. One of: - # - bcrypt : passwords are hashed with bcrypt (supports only $2a$ algorithm) - # - none : passwords are not hashed/encrypted - # default value is bcrypt - password-encoding-algo: bcrypt - users: - - user: - username: user - #firstname: - #lastname: - # Passwords are encoded using BCrypt - # Password value: password - password: $2a$10$9kjw/SH9gucCId3Lnt6EmuFreUAcXSZgpvAYuW2ISv7hSOhHRH1AO - roles: ORGANIZATION:USER,ENVIRONMENT:USER - # Useful to receive notifications - #email: - - user: - username: admin - #firstname: - #lastname: - # Password value: admin - password: $2a$10$Ihk05VSds5rUSgMdsMVi9OKMIx2yUvMz7y9VP3rJmQeizZLrhLMyq - roles: ORGANIZATION:ADMIN,ENVIRONMENT:ADMIN - #email: - - user: - username: api1 - #firstname: - #lastname: - # Password value: api1 - password: $2a$10$iXdXO4wAYdhx2LOwijsp7.PsoAZQ05zEdHxbriIYCbtyo.y32LTji - # You can declare multiple roles using comma separator - roles: ORGANIZATION:USER,ENVIRONMENT:API_PUBLISHER - #email: - - user: - username: application1 - #firstname: - #lastname: - # Password value: application1 - password: $2a$10$2gtKPYRB9zaVaPcn5RBx/.3T.7SeZoDGs9GKqbo9G64fKyXFR1He. - roles: ORGANIZATION:USER,ENVIRONMENT:USER - #email: - # Enable authentication using internal repository - - type: gravitee - # allow search results to display the user email. Be careful, It may be contrary to the user privacy. -# allow-email-in-search-results: true - # Enable authentication using an LDAP/Active Directory +# Enable authentication using an LDAP/Active Directory # - type: ldap - # This is default LDAP configuration for ApacheDS +# This is default LDAP configuration for ApacheDS # context: # username: "uid=admin,ou=system" # password: "secret" @@ -377,16 +376,16 @@ security: # referral: "ignore" # authentication: # user: - # Search base for user authentication. Defaults to "". Only used with user filter. - # It should be relative to the Base DN. If the whole DN is o=user accounts,c=io,o=gravitee then the base should be like this: +# Search base for user authentication. Defaults to "". Only used with user filter. +# It should be relative to the Base DN. If the whole DN is o=user accounts,c=io,o=gravitee then the base should be like this: # base: "o=user accounts" - # The LDAP filter used to search for user during authentication. For example "(uid={0})". The substituted parameter is the user's login name. +# The LDAP filter used to search for user during authentication. For example "(uid={0})". The substituted parameter is the user's login name. # filter: "mail={0}" - # Specifies the attribute name which contains the user photo (URL or binary) +# Specifies the attribute name which contains the user photo (URL or binary) # photo-attribute: "jpegPhoto" # group: - # Search base for groups searches. Defaults to "". Only used with group filter. - # It should be relative to the Base DN. If the whole DN is o=authorization groups,c=io,o=gravitee then the base should be like this: +# Search base for groups searches. Defaults to "". Only used with group filter. +# It should be relative to the Base DN. If the whole DN is o=authorization groups,c=io,o=gravitee then the base should be like this: # base: "o=authorization groups" # filter: "member={0}" # role: @@ -398,13 +397,13 @@ security: # GRAVITEE-USERS: USER # } # lookup: - # allow search results to display the user email. Be careful, It may be contrary to the user privacy. +# allow search results to display the user email. Be careful, It may be contrary to the user privacy. # allow-email-in-search-results: true # user: - # Search base for user searches. Defaults to "". Only used with user filter. - # It should be relative to the Base DN. If the whole DN is o=user accounts,c=io,o=gravitee then the base should be like this: +# Search base for user searches. Defaults to "". Only used with user filter. +# It should be relative to the Base DN. If the whole DN is o=user accounts,c=io,o=gravitee then the base should be like this: # base: "o=user accounts" - # The LDAP filter used to search for user during authentication. For example "(uid={0})". The substituted parameter is the user's login name. +# The LDAP filter used to search for user during authentication. For example "(uid={0})". The substituted parameter is the user's login name. # filter: "(&(objectClass=Person)(|(cn=*{0}*)(uid={0})))" # Define absolute path for the a default API icon (png format) @@ -414,11 +413,11 @@ security: # SMTP configuration used to send mails email: - enabled: false - host: smtp.my.domain - subject: "[Gravitee.io] %s" - port: 587 - from: noreply@my.domain + enabled: false + host: smtp.my.domain + subject: "[Gravitee.io] %s" + port: 587 + from: noreply@my.domain # username: user@my.domain # password: password # properties: @@ -433,89 +432,90 @@ email: #portal: # themes: # path: ${gravitee.home}/themes - # Allows domains to be used while generating some emails from the portal. ie. registration, forget password - # Empty whitelist means all urls are allowed. +# Allows domains to be used while generating some emails from the portal. ie. registration, forget password +# Empty whitelist means all urls are allowed. # whitelist: # - https://portal.domain.com # - https://private-portal.domain.com # Referenced properties ds: - mongodb: - dbname: gravitee - host: localhost - port: 27017 - elastic: - host: localhost - port: 9200 + mongodb: + dbname: gravitee + host: localhost + port: 27017 + elastic: + host: localhost + port: 9200 jwt: - secret: myJWT4Gr4v1t33_S3cr3t - # Allows to define the end of validity of the token in seconds (default 604800 = a week) - #expire-after: 604800 - # Allows to define the end of validity of the token in seconds for email registration (default 86400 = a day) - #email-registration-expire-after: 86400 - # Allows to define issuer (default gravitee-management-auth) - #issuer: gravitee-management-auth - # Allows to define cookie context path (default /) - #cookie-path: / - # Allows to define cookie domain (default "") - #cookie-domain: .gravitee.io - # Allows to define if cookie secure only (default false) - #cookie-secure: true + secret: myJWT4Gr4v1t33_S3cr3t + # Allows to define the end of validity of the token in seconds (default 604800 = a week) + #expire-after: 604800 + # Allows to define the end of validity of the token in seconds for email registration (default 86400 = a day) + #email-registration-expire-after: 86400 + # Allows to define issuer (default gravitee-management-auth) + #issuer: gravitee-management-auth + # Allows to define cookie context path (default /) + #cookie-path: / + # Allows to define cookie domain (default "") + #cookie-domain: .gravitee.io + # Allows to define if cookie secure only (default false) + #cookie-secure: true swagger: - # Default scheme used when creating an API from a Swagger descriptor if there is no scheme specified. - scheme: https + # Default scheme used when creating an API from a Swagger descriptor if there is no scheme specified. + scheme: https # User management configuration user: - login: - # Create a default application when user connects to the portal for the very first time (default true) - #defaultApplication: true - - # Password complexity validation policy - # Applications should enforce password complexity rules to discourage easy to guess passwords. - # Passwords should require a minimum level of complexity that makes sense for the application and its user population. - password: - policy: - # description field is used to display a message to the user enter a password that does not match the policy. Leave it blank to disable the message. - description: Password must be at least 12 characters long, contain at least one digit, one upper case letter, one lower case letter, one special character, and no more than 2 consecutive equal characters. - pattern: ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!~<>.,;:_=?/*+\-#\"'&§`£€%°()|\[\]$^@])(?!.*(.)\1{2,}).{12,128}$ - # Example : ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!~<>.,;:_=?/*+\-#\"'&§`£€%°()|\[\]$^@])(?!.*(.)\1{2,}).{12,128}$ - # ^ # start-of-string - #(?=.*[0-9]) # a digit must occur at least once - #(?=.*[A-Z]) # an upper case letter must occur at least once - #(?=.*[a-z]) # a lower case letter must occur at least once - #(?=.*[!~<>.,;:_=?/*+\-#\"'&§`£€%°()|\[\]$^@]) # a special character must occur at least once - #((?!.*(.)\1{2,}) # no more than 2 consecutive equal characters - #.{12,128} # anything, between 12 and 128 characters - #$ # end-of-string - creation: - token: - #expire-after: 86400 - reference: - # Secret key used to generate reference of a user which is unique (default: s3cR3t4grAv1t33.1Ous3D4R3f3r3nc3) - # Must contains 32 chars (256 bits) - #secret: - anonymize-on-delete: - #enabled: false + login: + # Create a default application when user connects to the portal for the very first time (default true) + #defaultApplication: true + + # Password complexity validation policy + # Applications should enforce password complexity rules to discourage easy to guess passwords. + # Passwords should require a minimum level of complexity that makes sense for the application and its user population. + password: + policy: + # description field is used to display a message to the user enter a password that does not match the policy. Leave it blank to disable the message. + description: Password must be at least 12 characters long, contain at least one digit, one upper case letter, one lower case letter, one special character, and no more than 2 consecutive equal characters. + pattern: + ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!~<>.,;:_=?/*+\-#\"'&§`£€%°()|\[\]$^@])(?!.*(.)\1{2,}).{12,128}$ + # Example : ^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!~<>.,;:_=?/*+\-#\"'&§`£€%°()|\[\]$^@])(?!.*(.)\1{2,}).{12,128}$ + # ^ # start-of-string + #(?=.*[0-9]) # a digit must occur at least once + #(?=.*[A-Z]) # an upper case letter must occur at least once + #(?=.*[a-z]) # a lower case letter must occur at least once + #(?=.*[!~<>.,;:_=?/*+\-#\"'&§`£€%°()|\[\]$^@]) # a special character must occur at least once + #((?!.*(.)\1{2,}) # no more than 2 consecutive equal characters + #.{12,128} # anything, between 12 and 128 characters + #$ # end-of-string + creation: + token: + #expire-after: 86400 + reference: + # Secret key used to generate reference of a user which is unique (default: s3cR3t4grAv1t33.1Ous3D4R3f3r3nc3) + # Must contains 32 chars (256 bits) + #secret: + anonymize-on-delete: + #enabled: false # Enable / disable documentation sanitize. Enabled by default. documentation: - markdown: - sanitize: true + markdown: + sanitize: true #imports: - # Enable / disable import from private hosts. Enabled by default. (See https://en.wikipedia.org/wiki/Private_network) +# Enable / disable import from private hosts. Enabled by default. (See https://en.wikipedia.org/wiki/Private_network) # allow-from-private: true - # Empty whitelist means all urls are allowed. Note: allow-from-private is ignored when whitelist is defined. +# Empty whitelist means all urls are allowed. Note: allow-from-private is ignored when whitelist is defined. # whitelist: # - https://whitelist.domain1.com # - https://restricted.domain2.com/whitelisted/path search: - data: ${gravitee.home}/data + data: ${gravitee.home}/data # global configuration of the http client #httpClient: @@ -537,11 +537,11 @@ search: # password: secret notifiers: - email: - enabled: true - host: ${email.host} - subject: ${email.subject} - port: ${email.port} + email: + enabled: true + host: ${email.host} + subject: ${email.subject} + port: ${email.port} # username: ${email.username} # password: ${email.password} # starttls.enabled: false @@ -555,7 +555,7 @@ notifiers: # keyStorePassword: # webhook: # enabled: true - # Empty whitelist means all urls are allowed. +# Empty whitelist means all urls are allowed. # whitelist: # - https://whitelist.domain1.com # - https://restricted.domain2.com/whitelisted/path @@ -569,43 +569,43 @@ notifiers: # serviceUrl: https://www.google.com/recaptcha/api/siteverify #el: - # Allows to define which methods or classes are accessible to the Expression Language engine (/!\ caution, changing default whitelist may expose you to security issues). - # A complete list of default whitelist methods can be found here (https://raw.githubusercontent.com/gravitee-io/gravitee-expression-language/master/src/main/resources/whitelist). +# Allows to define which methods or classes are accessible to the Expression Language engine (/!\ caution, changing default whitelist may expose you to security issues). +# A complete list of default whitelist methods can be found here (https://raw.githubusercontent.com/gravitee-io/gravitee-expression-language/master/src/main/resources/whitelist). # whitelist: - # Allows to define if the specified list of method or classes should be append to the default one or should replace it. - # We recommend you to always choose 'append' unless you absolutely kwnow what you are doing. +# Allows to define if the specified list of method or classes should be append to the default one or should replace it. +# We recommend you to always choose 'append' unless you absolutely kwnow what you are doing. # mode: append - # Define the list of classes or methods to append (or set) to made accessible to the Expression Language. - # start with 'method' to allow a specific method (complete signature). - # start with 'class' to allow a complete class. All methods of the class will then be accessible. +# Define the list of classes or methods to append (or set) to made accessible to the Expression Language. +# start with 'method' to allow a specific method (complete signature). +# start with 'class' to allow a complete class. All methods of the class will then be accessible. # list: - # Ex: allow access to DateTimeFormatter.ofLocalizedDate(FormatStyle) method - # - method java.time.format.DateTimeFormatter ofLocalizedDate java.time.format.FormatStyle - # Ex: allow access to all methods of DateTimeFormatter class - # - class java.time.format.DateTimeFormatter +# Ex: allow access to DateTimeFormatter.ofLocalizedDate(FormatStyle) method +# - method java.time.format.DateTimeFormatter ofLocalizedDate java.time.format.FormatStyle +# Ex: allow access to all methods of DateTimeFormatter class +# - class java.time.format.DateTimeFormatter #groovy: - # Allows to define which methods, fields, constructors, annotations or classes are accessible to the Groovy Script (/!\ caution, changing default whitelist may expose you to security issues). - # A complete list of default whitelist methods can be found here (https://raw.githubusercontent.com/gravitee-io/gravitee-policy-groovy/master/src/main/resources/groovy-whitelist). +# Allows to define which methods, fields, constructors, annotations or classes are accessible to the Groovy Script (/!\ caution, changing default whitelist may expose you to security issues). +# A complete list of default whitelist methods can be found here (https://raw.githubusercontent.com/gravitee-io/gravitee-policy-groovy/master/src/main/resources/groovy-whitelist). # whitelist: - # Allows to define if the specified list of methods, fields, constructors or classes should be append to the default one or should replace it. - # We recommend you to always choose 'append' unless you absolutely know what you are doing. +# Allows to define if the specified list of methods, fields, constructors or classes should be append to the default one or should replace it. +# We recommend you to always choose 'append' unless you absolutely know what you are doing. # mode: append - # Define the list of classes, methods, constructors, fields or annotations to append (or set) to made accessible to the Groovy Script. - # start with 'method' to allow a specific method (complete signature). - # start with 'class' to allow a complete class. All methods, constructors and fields of the class will then be accessible. - # start with 'new' to allow a specific constructor (complete signature). - # start with 'field' to allow access to a specific field of a class. - # start with 'annotation' to allow use of a specific annotation. +# Define the list of classes, methods, constructors, fields or annotations to append (or set) to made accessible to the Groovy Script. +# start with 'method' to allow a specific method (complete signature). +# start with 'class' to allow a complete class. All methods, constructors and fields of the class will then be accessible. +# start with 'new' to allow a specific constructor (complete signature). +# start with 'field' to allow access to a specific field of a class. +# start with 'annotation' to allow use of a specific annotation. # list: - # Ex: allow access to DateTimeFormatter.ofLocalizedDate(FormatStyle) method - # - method java.time.format.DateTimeFormatter ofLocalizedDate java.time.format.FormatStyle - # Ex: allow access to all methods, constructors and fields of DateTimeFormatter class - # - class java.time.format.DateTimeFormatter - # Ex: allow usage of field Integer.MAX_VALUE - # - field java.lang.Integer MAX_VALUE - # Ex: allow usage of @Override annotation - # - annotation java.lang.Override +# Ex: allow access to DateTimeFormatter.ofLocalizedDate(FormatStyle) method +# - method java.time.format.DateTimeFormatter ofLocalizedDate java.time.format.FormatStyle +# Ex: allow access to all methods, constructors and fields of DateTimeFormatter class +# - class java.time.format.DateTimeFormatter +# Ex: allow usage of field Integer.MAX_VALUE +# - field java.lang.Integer MAX_VALUE +# Ex: allow usage of @Override annotation +# - annotation java.lang.Override # Allows to enable or disable the 'Subscribe to newsletter' feature when user completes his profile on first log in. Default is enabled. #newsletter: @@ -696,23 +696,23 @@ notifiers: # Integration integration: - enabled: false - controller: - ws: - port: 8072 + enabled: false + controller: + ws: + port: 8072 api: - v2: - # V4 Emulation engine allows strict respect of the policy execution order, as it defines it the policy studio whereas, in "v3" mode, execution order may differ depending on policy REQUEST_CONTENT or RESPONSE_CONTENT scope. - emulateV4Engine: - # Allow to emulate v4 engine by default when no execution mode is specified on an api - # Possible values: yes | creation_only | no; Default: yes - default: yes - # Encrypt API properties using this secret - properties: - encryption: - secret: vvLJ4Q8Khvv9tm2tIPdkGEdmgKUruAL6 + v2: + # V4 Emulation engine allows strict respect of the policy execution order, as it defines it the policy studio whereas, in "v3" mode, execution order may differ depending on policy REQUEST_CONTENT or RESPONSE_CONTENT scope. + emulateV4Engine: + # Allow to emulate v4 engine by default when no execution mode is specified on an api + # Possible values: yes | creation_only | no; Default: yes + default: yes + # Encrypt API properties using this secret + properties: + encryption: + secret: vvLJ4Q8Khvv9tm2tIPdkGEdmgKUruAL6 # Scoring scoring: - enabled: false + enabled: false diff --git a/pom.xml b/pom.xml index ee8491a3f6b..f9d6ea7844b 100644 --- a/pom.xml +++ b/pom.xml @@ -63,12 +63,12 @@ 4.5.1 1.1.5 1.8.2 - 3.2.1 + 3.2.3 2.1.0 3.8.1 4.1.0 0.3.0 - 6.4.3 + 6.4.4 1.4.3 4.1.0 1.3.0