METRON-1665 Move hosting of Alerts and Config UIs from Nodejs to Spring Boot (simonellistonball via merrimanr) closes apache/metron#1111
Project: http://git-wip-us.apache.org/repos/asf/metron/repo Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/54880ba8 Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/54880ba8 Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/54880ba8 Branch: refs/heads/feature/METRON-1663-knoxsso Commit: 54880ba8f2467fefe56b9c377da003d08f0fe203 Parents: 28f4b57 Author: simonellistonball <[email protected]> Authored: Tue Aug 28 14:20:10 2018 -0500 Committer: rmerriman <[email protected]> Committed: Tue Aug 28 14:20:10 2018 -0500 ---------------------------------------------------------------------- .gitignore | 6 + dependencies_with_url.csv | 48 +++ .../packaging/ambari/metron-mpack/README.md | 2 - .../common-services/METRON/CURRENT/metainfo.xml | 3 - .../packaging/docker/ansible-docker/Dockerfile | 3 - .../packaging/docker/deb-docker/Dockerfile | 4 - .../docker/deb-docker/prepackage/metron-config | 3 - .../packaging/docker/rpm-docker/Dockerfile | 4 - .../docker/rpm-docker/SPECS/metron.spec | 97 ++----- .../packaging/docker/rpm-docker/pom.xml | 4 +- metron-interface/metron-alerts-host/.gitignore | 24 ++ metron-interface/metron-alerts-host/pom.xml | 141 +++++++++ .../src/main/assembly/assembly.xml | 39 +++ .../org/apache/metron/ui/AlertsApplication.java | 29 ++ .../src/main/resources/application.yml | 61 ++++ .../src/main/scripts/metron-alerts.sh | 55 ++++ metron-interface/metron-alerts/.gitignore | 3 + metron-interface/metron-alerts/assembly.xml | 55 ---- metron-interface/metron-alerts/pom.xml | 21 +- .../metron-alerts/scripts/alerts-server.js | 76 ----- .../metron-alerts/scripts/metron-alerts-ui | 159 ---------- .../metron-alerts/scripts/package.json | 21 -- metron-interface/metron-config-host/pom.xml | 142 +++++++++ .../src/main/assembly/assembly.xml | 39 +++ .../org/apache/metron/ui/ConfigApplication.java | 31 ++ .../src/main/resources/application.yml | 34 +++ .../src/main/scripts/metron-config.sh | 55 ++++ metron-interface/metron-config/.gitignore | 3 + metron-interface/metron-config/assembly.xml | 65 ----- metron-interface/metron-config/pom.xml | 236 ++++++++------- .../metron-config/scripts/metron-management-ui | 159 ---------- .../metron-config/scripts/package.json | 22 -- .../metron-config/scripts/server.js | 76 ----- metron-interface/metron-rest/README.md | 95 ++---- metron-interface/metron-rest/pom.xml | 6 +- .../metron/rest/MetronRestApplication.java | 16 +- .../metron/rest/config/WebSecurityConfig.java | 108 ------- .../rest/controller/AlertsUIController.java | 6 +- .../src/main/resources/application-test.yml | 19 ++ .../metron-rest/src/main/scripts/metron-rest.sh | 7 +- .../metron/rest/config/TestSecurityConfig.java | 44 +++ .../AlertsUIControllerIntegrationTest.java | 18 +- metron-interface/metron-ui-host/pom.xml | 138 +++++++++ .../metron/ui/AbstractHostApplication.java | 28 ++ .../org/apache/metron/ui/UserController.java | 71 +++++ .../metron/ui/ZuulAuthenticationFilter.java | 77 +++++ .../java/org/apache/metron/ui/ZuulError.java | 34 +++ .../org/apache/metron/ui/ZuulErrorFilter.java | 67 +++++ .../src/main/resources/application.yml | 59 ++++ .../apache/metron/ui/TestHostApplication.java | 25 ++ .../java/org/apache/metron/ui/WhoamiTest.java | 120 ++++++++ .../ui/ZuulAuthorizationHeaderProxyTest.java | 103 +++++++ .../src/test/resources/application-test.yml | 77 +++++ metron-interface/metron-ui-security/pom.xml | 135 +++++++++ .../metron/ui/KnoxSSOAuthenticationFilter.java | 289 +++++++++++++++++++ .../ui/MetronAuthenticationException.java | 29 ++ .../metron/ui/MetronAuthenticationProvider.java | 60 ++++ .../apache/metron/ui/MetronSecurityConfig.java | 188 ++++++++++++ .../java/org/apache/metron/ui/EmbeddedLdap.java | 164 +++++++++++ .../java/org/apache/metron/ui/JWTTests.java | 170 +++++++++++ .../ui/KnoxSSOAuthenticationFilterTests.java | 66 +++++ .../ui/MetronAuthenticationProviderTests.java | 33 +++ .../metron/ui/config/TestSecurityConfig.java | 31 ++ .../resources/application-embedded-ldap.yml | 35 +++ .../resources/org/apache/metron/ui/headers.pem | 27 ++ .../resources/org/apache/metron/ui/invalid.pem | 27 ++ .../org/apache/metron/ui/noheaders.pem | 25 ++ .../src/test/resources/schema.ldif | 77 +++++ metron-interface/pom.xml | 13 + 69 files changed, 3147 insertions(+), 1060 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 12fd7cd..5b0971e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,9 @@ temp/** temp/**/* metron-interface/metron-alerts/node/ repodata/ + +# Ignores for eclipse IDE +.springBeans +.factorypath +.vscode +.pydevproject \ No newline at end of file http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/dependencies_with_url.csv ---------------------------------------------------------------------- diff --git a/dependencies_with_url.csv b/dependencies_with_url.csv index 6ac1f23..5740ffe 100644 --- a/dependencies_with_url.csv +++ b/dependencies_with_url.csv @@ -421,3 +421,51 @@ com.google.code.gson:gson:jar:2.8.2:compile,ASLv2,https://github.com/google/gson com.zaxxer:HikariCP:jar:2.7.8:compile,ASLv2,https://github.com/brettwooldridge/HikariCP org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile,ASLv2,https://github.com/hibernate/hibernate-validator +com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile,ASLv2,http://stephenc.github.io/jcip-annotations/ +com.google.guava:guava:jar:15.0:compile,ASLv2, +com.netflix.archaius:archaius-core:jar:0.7.6:compile,ASLv2,https://github.com/Netflix/archaius +com.netflix.hystrix:hystrix-core:jar:1.5.12:compile,ASLv2,https://github.com/Netflix/Hystrix +com.netflix.hystrix:hystrix-javanica:jar:1.5.12:compile,ASLv2,https://github.com/Netflix/Hystrix +com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.5.12:compile,ASLv2,https://github.com/Netflix/Hystrix +com.netflix.hystrix:hystrix-serialization:jar:1.5.12:compile,ASLv2,https://github.com/Netflix/Hystrix +com.netflix.netflix-commons:netflix-commons-util:jar:0.3.0:compile +com.netflix.ribbon:ribbon-core:jar:2.2.5:compile,ASLv2,https://github.com/Netflix/ribbon +com.netflix.ribbon:ribbon-httpclient:jar:2.2.5:compile,ASLv2,https://github.com/Netflix/ribbon +com.netflix.ribbon:ribbon-loadbalancer:jar:2.2.5:compile,ASLv2,https://github.com/Netflix/ribbon +com.netflix.ribbon:ribbon:jar:2.2.5:compile,ASLv2,https://github.com/Netflix/ribbon +com.netflix.zuul:zuul-core:jar:1.3.1:compile,ASLv2,https://github.com/Netflix/zuul +com.nimbusds:nimbus-jose-jwt:jar:4.41.2:compile,ASLv2,https://connect2id.com/products/nimbus-jose-jwt +commons-configuration:commons-configuration:jar:1.8:compile,ASLv2,http://commons.apache.org/ +commons-lang:commons-lang:jar:2.3:compile,ASLv2,http://commons.apache.org/ +io.micrometer:micrometer-core:jar:1.0.3:compile,ASLv2,http://micrometer.io/ +io.reactivex:rxjava-reactive-streams:jar:1.2.1:compile,ASLv2,http://reactivex.io/ +io.reactivex:rxjava:jar:1.2.0:compile,ASLv2,http://reactivex.io/ +io.undertow:undertow-core:jar:1.4.23.Final:compile,ASLv2,http://undertow.io/ +io.undertow:undertow-servlet:jar:1.4.23.Final:compile,ASLv2,http://undertow.io/ +io.undertow:undertow-websockets-jsr:jar:1.4.23.Final:compile,ASLv2,http://undertow.io/ +org.bouncycastle:bcpkix-jdk15on:jar:1.56:compile,MIT,https://www.bouncycastle.org/ +org.bouncycastle:bcprov-jdk15on:jar:1.56:compile,MIT,https://www.bouncycastle.org/ +org.glassfish:javax.el:jar:3.0.0:compile,Common Development and Distribution License (CDDL) v1.0 +org.hdrhistogram:HdrHistogram:jar:2.1.10:compile,BSD 2-clause,http://hdrhistogram.org/ +org.jboss.xnio:xnio-api:jar:3.3.8.Final:compile,ASLv2,http://xnio.jboss.org/ +org.latencyutils:LatencyUtils:jar:2.0.3:compile,BSD 2-clause,http://latencyutils.org/ +org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.0.1.RELEASE:compile,ASLv2,https://spring.io/projects/spring-boot +org.springframework.boot:spring-boot-actuator:jar:2.0.1.RELEASE:compile,ASLv2,https://spring.io/projects/spring-boot +org.springframework.boot:spring-boot-starter-actuator:jar:2.0.1.RELEASE:compile,ASLv2,https://spring.io/projects/spring-boot +org.springframework.boot:spring-boot-starter-undertow:jar:2.0.1.RELEASE:compile,ASLv2,https://spring.io/projects/spring-boot +org.springframework.cloud:spring-cloud-commons:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-context:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-netflix-core:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-netflix-zuul:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-starter-netflix-hystrix:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-starter-netflix-ribbon:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-starter-netflix-zuul:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.cloud:spring-cloud-starter:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ +org.springframework.ldap:spring-ldap-core:jar:2.3.2.RELEASE:compile,ASLv2,https://spring.io/projects/spring-ldap +org.springframework.security:spring-security-crypto:jar:5.0.4.RELEASE:compile,ASLv2,https://spring.io/projects/spring-security +org.springframework.security:spring-security-ldap:jar:5.0.4.RELEASE:compile,ASLv2,https://spring.io/projects/spring-security +org.springframework.security:spring-security-rsa:jar:1.0.5.RELEASE:compile,ASLv2,https://spring.io/projects/spring-security +org.springframework.cloud:spring-cloud-commons:jar:2.0.0.RELEASE:compile,ASLv2,http://projects.spring.io/spring-cloud/ http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/ambari/metron-mpack/README.md ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/ambari/metron-mpack/README.md b/metron-deployment/packaging/ambari/metron-mpack/README.md index cd9399d..785d20e 100644 --- a/metron-deployment/packaging/ambari/metron-mpack/README.md +++ b/metron-deployment/packaging/ambari/metron-mpack/README.md @@ -26,8 +26,6 @@ This allows you to easily install Metron using a simple, guided process. This a * Installable Metron packages (either RPMs or DEBs) located in a repository on each host at `/localrepo`. -* A [Node.js](https://nodejs.org/en/download/package-manager/) repository installed on the host running the Management and Alarm UI. - ### Quick Start 1. Build the Metron MPack. Execute the following command from the project's root directory. http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/metainfo.xml ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/metainfo.xml b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/metainfo.xml index f83d93b..85302a9 100644 --- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/metainfo.xml +++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/metainfo.xml @@ -422,9 +422,6 @@ <name>metron-rest</name> </package> <package> - <name>nodejs</name> - </package> - <package> <name>metron-config</name> </package> <package> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/docker/ansible-docker/Dockerfile ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/docker/ansible-docker/Dockerfile b/metron-deployment/packaging/docker/ansible-docker/Dockerfile index ebf002a..d5f7d24 100644 --- a/metron-deployment/packaging/docker/ansible-docker/Dockerfile +++ b/metron-deployment/packaging/docker/ansible-docker/Dockerfile @@ -58,8 +58,5 @@ RUN yum -y install asciidoc rpm-build rpm2cpio tar unzip xmlto zip rpmlint make # create a .bashrc for root, enabling the cpp 11 toolset RUN touch /root/.bashrc \ && cat '/opt/rh/devtoolset-4/enable' >> /root/.bashrc -# install node so that the node dependencies can be packaged into the RPMs -RUN curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - -RUN yum -y install nodejs WORKDIR /root http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/docker/deb-docker/Dockerfile ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/docker/deb-docker/Dockerfile b/metron-deployment/packaging/docker/deb-docker/Dockerfile index 44203c6..d4e1f91 100644 --- a/metron-deployment/packaging/docker/deb-docker/Dockerfile +++ b/metron-deployment/packaging/docker/deb-docker/Dockerfile @@ -26,8 +26,4 @@ RUN apt-get update && apt-get install -y \ dpkg-dev \ gettext -# install nodejs so that the node dependencies can be packaged into the DEBs -RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - -RUN apt-get install -y nodejs - WORKDIR /root http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/docker/deb-docker/prepackage/metron-config ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/docker/deb-docker/prepackage/metron-config b/metron-deployment/packaging/docker/deb-docker/prepackage/metron-config index a5ac74f..90bf183 100644 --- a/metron-deployment/packaging/docker/deb-docker/prepackage/metron-config +++ b/metron-deployment/packaging/docker/deb-docker/prepackage/metron-config @@ -27,6 +27,3 @@ # the working directory containing all of the files to # be packaged will be passed as the only argument to this script. # - -# package the 'production' node dependencies -npm install --prefix="${PACKAGE_WORKDIR}/${METRON_HOME}/web/expressjs" --only=production http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/docker/rpm-docker/Dockerfile ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/docker/rpm-docker/Dockerfile b/metron-deployment/packaging/docker/rpm-docker/Dockerfile index a2dae8e..2fd2565 100644 --- a/metron-deployment/packaging/docker/rpm-docker/Dockerfile +++ b/metron-deployment/packaging/docker/rpm-docker/Dockerfile @@ -27,7 +27,3 @@ RUN mv apache-maven-3.2.5 /opt/maven RUN ln -s /opt/maven/bin/mvn /usr/bin/mvn RUN yum -y install asciidoc rpm-build rpm2cpio tar unzip xmlto zip rpmlint && yum clean all WORKDIR /root - -# install node so that the node dependencies can be packaged into the RPMs -RUN curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - -RUN yum -y install gcc-c++ make nodejs http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/docker/rpm-docker/SPECS/metron.spec ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/docker/rpm-docker/SPECS/metron.spec b/metron-deployment/packaging/docker/rpm-docker/SPECS/metron.spec index 4b88fd0..df712ad 100644 --- a/metron-deployment/packaging/docker/rpm-docker/SPECS/metron.spec +++ b/metron-deployment/packaging/docker/rpm-docker/SPECS/metron.spec @@ -53,10 +53,10 @@ Source6: metron-indexing-%{full_version}-archive.tar.gz Source7: metron-pcap-backend-%{full_version}-archive.tar.gz Source8: metron-profiler-%{full_version}-archive.tar.gz Source9: metron-rest-%{full_version}-archive.tar.gz -Source10: metron-config-%{full_version}-archive.tar.gz +Source10: metron-config-host-%{full_version}-archive.tar.gz Source11: metron-management-%{full_version}-archive.tar.gz Source12: metron-maas-service-%{full_version}-archive.tar.gz -Source13: metron-alerts-%{full_version}-archive.tar.gz +Source13: metron-alerts-host-%{full_version}-archive.tar.gz Source14: metron-performance-%{full_version}-archive.tar.gz %description @@ -77,7 +77,11 @@ rm -rf %{_builddir}/* %install rm -rf %{buildroot} mkdir -p %{buildroot}%{metron_home} -mkdir -p %{buildroot}/etc/init.d + +# make PID locations for metron uis +mkdir -p %{buildroot}/var/run/metron-alerts +mkdir -p %{buildroot}/var/run/metron-config +mkdir -p %{buildroot}/var/run/metron-rest # copy source files and untar tar -xzf %{SOURCE0} -C %{buildroot}%{metron_home} @@ -96,12 +100,6 @@ tar -xzf %{SOURCE12} -C %{buildroot}%{metron_home} tar -xzf %{SOURCE13} -C %{buildroot}%{metron_home} tar -xzf %{SOURCE14} -C %{buildroot}%{metron_home} -install %{buildroot}%{metron_home}/bin/metron-management-ui %{buildroot}/etc/init.d/ -install %{buildroot}%{metron_home}/bin/metron-alerts-ui %{buildroot}/etc/init.d/ - -# allows node dependencies to be packaged in the RPMs -npm install --prefix="%{buildroot}%{metron_home}/web/expressjs" --only=production - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %package common @@ -435,41 +433,12 @@ This package installs the Metron Management UI %{metron_home} %defattr(-,root,root,755) %dir %{metron_root} %dir %{metron_home} +%dir %{metron_home}/config %dir %{metron_home}/bin -%dir %{metron_home}/web -%dir %{metron_home}/web/expressjs -%dir %{metron_home}/web/expressjs/node_modules -%dir %{metron_home}/web/expressjs/node_modules/.bin -%dir %{metron_home}/web/management-ui -%dir %{metron_home}/web/management-ui/assets -%dir %{metron_home}/web/management-ui/assets/ace -%dir %{metron_home}/web/management-ui/assets/ace/snippets -%dir %{metron_home}/web/management-ui/assets/fonts -%dir %{metron_home}/web/management-ui/assets/fonts/Roboto -%dir %{metron_home}/web/management-ui/assets/images -%dir %{metron_home}/web/management-ui/license -%{metron_home}/bin/metron-management-ui -/etc/init.d/metron-management-ui -%attr(0755,root,root) %{metron_home}/web/expressjs/node_modules/* -%attr(0755,root,root) %{metron_home}/web/expressjs/node_modules/.bin/* -%attr(0755,root,root) %{metron_home}/web/expressjs/server.js -%attr(0644,root,root) %{metron_home}/web/expressjs/package.json -%attr(0644,root,root) %{metron_home}/web/management-ui/favicon.ico -%attr(0644,root,root) %{metron_home}/web/management-ui/index.html -%attr(0644,root,root) %{metron_home}/web/management-ui/*.js -%attr(0644,root,root) %{metron_home}/web/management-ui/*.js.gz -%attr(0644,root,root) %{metron_home}/web/management-ui/*.ttf -%attr(0644,root,root) %{metron_home}/web/management-ui/*.svg -%attr(0644,root,root) %{metron_home}/web/management-ui/*.eot -%attr(0644,root,root) %{metron_home}/web/management-ui/*.woff -%attr(0644,root,root) %{metron_home}/web/management-ui/*.woff2 -%attr(0644,root,root) %{metron_home}/web/management-ui/assets/ace/*.js -%attr(0644,root,root) %{metron_home}/web/management-ui/assets/ace/LICENSE -%attr(0644,root,root) %{metron_home}/web/management-ui/assets/ace/snippets/*.js -%attr(0644,root,root) %{metron_home}/web/management-ui/assets/fonts/Roboto/LICENSE.txt -%attr(0644,root,root) %{metron_home}/web/management-ui/assets/fonts/Roboto/*.ttf -%attr(0644,root,root) %{metron_home}/web/management-ui/assets/images/* -%attr(0644,root,root) %{metron_home}/web/management-ui/license/* +%dir %{metron_home}/lib +%attr(0755,root,root) %{metron_home}/lib/metron-config-host-%{full_version}.jar +%attr(0755,root,root) %{metron_home}/bin/metron-config.sh + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -504,46 +473,18 @@ This package installs the Metron Alerts UI %{metron_home} %defattr(-,root,root,755) %dir %{metron_root} %dir %{metron_home} +%dir %{metron_home}/config %dir %{metron_home}/bin -%dir %{metron_home}/web -%dir %{metron_home}/web/alerts-ui -%dir %{metron_home}/web/alerts-ui/assets -%dir %{metron_home}/web/alerts-ui/assets/ace -%dir %{metron_home}/web/alerts-ui/assets/fonts -%dir %{metron_home}/web/alerts-ui/assets/fonts/Roboto -%dir %{metron_home}/web/alerts-ui/assets/images -%{metron_home}/bin/metron-alerts-ui -/etc/init.d/metron-alerts-ui -%attr(0755,root,root) %{metron_home}/web/expressjs/alerts-server.js -%attr(0644,root,root) %{metron_home}/web/alerts-ui/favicon.ico -%attr(0644,root,root) %{metron_home}/web/alerts-ui/index.html -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.bundle.css -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.js -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.ttf -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.svg -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.jpg -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.eot -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.woff -%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.woff2 -%attr(0644,root,root) %{metron_home}/web/alerts-ui/3rdpartylicenses.txt -%attr(0644,root,root) %{metron_home}/web/alerts-ui/assets/ace/*.js -%attr(0644,root,root) %{metron_home}/web/alerts-ui/assets/ace/LICENSE -%attr(0644,root,root) %{metron_home}/web/alerts-ui/assets/fonts/font.css -%attr(0644,root,root) %{metron_home}/web/alerts-ui/assets/fonts/Roboto/LICENSE.txt -%attr(0644,root,root) %{metron_home}/web/alerts-ui/assets/fonts/Roboto/*.ttf -%attr(0644,root,root) %{metron_home}/web/alerts-ui/assets/images/* - -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +%dir %{metron_home}/lib +%attr(0755,root,root) %{metron_home}/lib/metron-alerts-host-%{full_version}.jar +%attr(0755,root,root) %{metron_home}/bin/metron-alerts.sh -%post config -chkconfig --add metron-management-ui -chkconfig --add metron-alerts-ui -%preun config -chkconfig --del metron-management-ui -chkconfig --del metron-alerts-ui +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %changelog +* Thu Jul 19 2018 Apache Metron <[email protected]> - 0.5.1 +- Added new UI hosting methods * Thu Feb 1 2018 Apache Metron <[email protected]> - 0.4.3 - Add Solr install script to Solr RPM * Tue Sep 25 2017 Apache Metron <[email protected]> - 0.4.2 http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-deployment/packaging/docker/rpm-docker/pom.xml ---------------------------------------------------------------------- diff --git a/metron-deployment/packaging/docker/rpm-docker/pom.xml b/metron-deployment/packaging/docker/rpm-docker/pom.xml index ba57079..878f55a 100644 --- a/metron-deployment/packaging/docker/rpm-docker/pom.xml +++ b/metron-deployment/packaging/docker/rpm-docker/pom.xml @@ -174,7 +174,7 @@ </includes> </resource> <resource> - <directory>${metron_dir}/metron-interface/metron-config/target/</directory> + <directory>${metron_dir}/metron-interface/metron-config-host/target/</directory> <includes> <include>*.tar.gz</include> </includes> @@ -186,7 +186,7 @@ </includes> </resource> <resource> - <directory>${metron_dir}/metron-interface/metron-alerts/target/</directory> + <directory>${metron_dir}/metron-interface/metron-alerts-host/target/</directory> <includes> <include>*.tar.gz</include> </includes> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts-host/.gitignore ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts-host/.gitignore b/metron-interface/metron-alerts-host/.gitignore new file mode 100644 index 0000000..e0dea38 --- /dev/null +++ b/metron-interface/metron-alerts-host/.gitignore @@ -0,0 +1,24 @@ +/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts-host/pom.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts-host/pom.xml b/metron-interface/metron-alerts-host/pom.xml new file mode 100644 index 0000000..aa2ba1b --- /dev/null +++ b/metron-interface/metron-alerts-host/pom.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software + Foundation (ASF) under one or more contributor license agreements. See the + NOTICE file distributed with this work for additional information regarding + copyright ownership. The ASF licenses this file to You under the Apache License, + Version 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.metron.ui</groupId> + <artifactId>metron-alerts-host</artifactId> + <packaging>jar</packaging> + + <name>Metron Alerts UI Host</name> + <description>Spring Server to run frontend</description> + + <parent> + <groupId>org.apache.metron</groupId> + <artifactId>metron-interface</artifactId> + <version>0.5.1</version> + </parent> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.metron</groupId> + <artifactId>metron-alerts</artifactId> + <version>${project.parent.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.metron</groupId> + <artifactId>metron-ui-host</artifactId> + <version>${project.parent.version}</version> + </dependency> + + </dependencies> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-dependencies</artifactId> + <version>${spring-cloud.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <!-- Import dependency management from Spring Boot --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring.boot.version}</version> + <type>pom</type> + <scope>import</scope> + <exclusions> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </dependencyManagement> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring.boot.version}</version> + <configuration> + <executable>true</executable> + <mainClass>org.apache.metron.ui.AlertsApplication</mainClass> + <embeddedLaunchScriptProperties> + <initInfoProvides>metron-alerts</initInfoProvides> + <initInfoDescription>Metron Alerts UI server</initInfoDescription> + <initInfoShortDescription>Metron Alerts</initInfoShortDescription> + </embeddedLaunchScriptProperties> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>unpack-shared-resources</id> + <goals> + <goal>unpack-dependencies</goal> + </goals> + <phase>generate-resources</phase> + <configuration> + <outputDirectory>${project.build.directory}/generated-resources</outputDirectory> + <includeArtifacIds>shared-resources</includeArtifacIds> + <includeGroupIds>${project.groupId}</includeGroupIds> + <excludeTransitive>true</excludeTransitive> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptor>src/main/assembly/assembly.xml</descriptor> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts-host/src/main/assembly/assembly.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts-host/src/main/assembly/assembly.xml b/metron-interface/metron-alerts-host/src/main/assembly/assembly.xml new file mode 100644 index 0000000..1377f60 --- /dev/null +++ b/metron-interface/metron-alerts-host/src/main/assembly/assembly.xml @@ -0,0 +1,39 @@ +<!-- + Licensed to the Apache Software + Foundation (ASF) under one or more contributor license agreements. See the + NOTICE file distributed with this work for additional information regarding + copyright ownership. The ASF licenses this file to You under the Apache License, + Version 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. + --> + +<assembly> + <id>archive</id> + <formats> + <format>tar.gz</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <fileSets> + <fileSet> + <directory>${project.basedir}/target</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <outputDirectory>lib</outputDirectory> + <useDefaultExcludes>true</useDefaultExcludes> + </fileSet> + <fileSet> + <directory>${project.basedir}/src/main/scripts</directory> + <includes> + <include>metron-alerts.sh</include> + </includes> + <outputDirectory>bin</outputDirectory> + <useDefaultExcludes>true</useDefaultExcludes> + <filtered>true</filtered> + </fileSet> + </fileSets> +</assembly> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts-host/src/main/java/org/apache/metron/ui/AlertsApplication.java ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts-host/src/main/java/org/apache/metron/ui/AlertsApplication.java b/metron-interface/metron-alerts-host/src/main/java/org/apache/metron/ui/AlertsApplication.java new file mode 100644 index 0000000..8423dcc --- /dev/null +++ b/metron-interface/metron-alerts-host/src/main/java/org/apache/metron/ui/AlertsApplication.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.metron.ui; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScans; + +@SpringBootApplication +@ComponentScans( + value = {@ComponentScan, @ComponentScan(basePackageClasses = MetronSecurityConfig.class)}) +public class AlertsApplication extends AbstractHostApplication { + public static void main(String[] args) { + SpringApplication.run(AlertsApplication.class, args); + } +} http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts-host/src/main/resources/application.yml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts-host/src/main/resources/application.yml b/metron-interface/metron-alerts-host/src/main/resources/application.yml new file mode 100644 index 0000000..3eb9045 --- /dev/null +++ b/metron-interface/metron-alerts-host/src/main/resources/application.yml @@ -0,0 +1,61 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +metron: + version: ${project.version} + +server: + session: + cookie: + secure: false + name: METRONUISESSION + +zuul: + routes: + rest: + path: /api/v1/** + url: http://localhost:8082/api/v1/ + sensitiveHeaders: Cookie,Set-Cookie + +proxy: + auth: + routes: + rest: passthru + +ribbon: + ConnectTimeout: 3000 + ReadTimeout: 60000 + + +ldap: + provider: + url: ldap://localhost:33389 + userdn: uid=admin,ou=people,dc=hadoop,dc=apache,dc=org + password: admin-password + user: + dn.patterns: uid={0},ou=people,dc=hadoop,dc=apache,dc=org + passwordAttribute: userPassword + searchBase: ou=people,dc=hadoop,dc=apache,dc=org + searchFilter: "" + group: + searchBase: ou=groups,dc=hadoop,dc=apache,dc=org + searchFilter: "member={0}" + roleAttribute: "cn" + +knox: + sso: + url: '' + pubkey: '' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts-host/src/main/scripts/metron-alerts.sh ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts-host/src/main/scripts/metron-alerts.sh b/metron-interface/metron-alerts-host/src/main/scripts/metron-alerts.sh new file mode 100644 index 0000000..a171cff --- /dev/null +++ b/metron-interface/metron-alerts-host/src/main/scripts/metron-alerts.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if [ -z "${METRON_SSL_PASSWORD}" ]; then + echo "METRON_SSL_PASSWORD unset." +fi + +METRON_VERSION=${project.version} +METRON_HOME="${METRON_HOME:-/usr/metron/${METRON_VERSION}}" +METRON_SYSCONFIG="${METRON_SYSCONFIG:-/etc/default/metron}" + +echo "METRON_VERSION=${METRON_VERSION}" +echo "METRON_HOME=${METRON_HOME}" +echo "METRON_SYSCONFIG=${METRON_SYSCONFIG}" + +if [ -f "$METRON_SYSCONFIG" ]; then + echo "METRON_SYSCONFIG=${METRON_SYSCONFIG}" + set -a + . "$METRON_SYSCONFIG" +fi + +echo "METRON_SPRING_PROFILES_ACTIVE=${METRON_SPRING_PROFILES_ACTIVE}" + +METRON_CONFIG_LOCATION=" --spring.config.location=classpath:/application.yml,$METRON_HOME/config/alerts_ui.yml" +echo "METRON_CONFIG_LOCATION=${METRON_CONFIG_LOCATION}" +METRON_SPRING_OPTIONS+=${METRON_CONFIG_LOCATION} + +# Find the metron alerts jar +files=( "${METRON_HOME}/lib/metron-alerts-host-*.jar" ) +echo "Default metron-alerts-host jar is: ${files[0]}" +APP_JAR="${files[0]}" + +export CONF_FOLDER=$METHRON_HOME/config +export LOG_FOLDER=/var/log/metron/ +export PID_FOLDER=/var/run/metron/ +export RUN_ARGS=$METRON_SPRING_OPTIONS +export APP_NAME=metron-alerts +export MODE=service +${APP_JAR} $1 http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts/.gitignore ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts/.gitignore b/metron-interface/metron-alerts/.gitignore index 703c7a9..de23844 100644 --- a/metron-interface/metron-alerts/.gitignore +++ b/metron-interface/metron-alerts/.gitignore @@ -4,3 +4,6 @@ metron-alerts.iml node_modules/ /dist/ coverage + +# Build Files +bin/ http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts/assembly.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts/assembly.xml b/metron-interface/metron-alerts/assembly.xml deleted file mode 100644 index f392a66..0000000 --- a/metron-interface/metron-alerts/assembly.xml +++ /dev/null @@ -1,55 +0,0 @@ -<!-- - Licensed to the Apache Software - Foundation (ASF) under one or more contributor license agreements. See the - NOTICE file distributed with this work for additional information regarding - copyright ownership. The ASF licenses this file to You under the Apache License, - Version 2.0 (the "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - OR CONDITIONS OF ANY KIND, either express or implied. See the License for - the specific language governing permissions and limitations under the License. - --> - -<assembly> - <id>archive</id> - <formats> - <format>tar.gz</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <fileSets> - <fileSet> - <directory>${project.basedir}/dist</directory> - <outputDirectory>/web/alerts-ui</outputDirectory> - <excludes> - <exclude>**/.npmignore</exclude> - </excludes> - <fileMode>0644</fileMode> - </fileSet> - <fileSet> - <directory>${project.basedir}/scripts</directory> - <outputDirectory>web/expressjs</outputDirectory> - <includes> - <include>alerts-server.js</include> - </includes> - <fileMode>0644</fileMode> - </fileSet> - <fileSet> - <directory>${project.basedir}/scripts</directory> - <outputDirectory>bin</outputDirectory> - <useDefaultExcludes>true</useDefaultExcludes> - <includes> - <include>metron-alerts-ui</include> - </includes> - <fileMode>0755</fileMode> - <lineEnding>unix</lineEnding> - <filtered>true</filtered> - </fileSet> - </fileSets> - <files> - <file> - <source>src/favicon.ico</source> - <outputDirectory>/web/alerts-ui</outputDirectory> - </file> - </files> -</assembly> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts/pom.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts/pom.xml b/metron-interface/metron-alerts/pom.xml index e7706b3..b47f241 100644 --- a/metron-interface/metron-alerts/pom.xml +++ b/metron-interface/metron-alerts/pom.xml @@ -31,6 +31,12 @@ <dependencies> </dependencies> <build> + <resources> + <resource> + <directory>dist</directory> + <targetPath>public</targetPath> + </resource> + </resources> <plugins> <plugin> <groupId>com.github.eirslett</groupId> @@ -97,21 +103,6 @@ </configuration> </plugin> <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptor>assembly.xml</descriptor> - </configuration> - <executions> - <execution> - <id>make-assembly</id> <!-- this is used for inheritance merges --> - <phase>package</phase> <!-- bind to the packaging phase --> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.5.0</version> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts/scripts/alerts-server.js ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts/scripts/alerts-server.js b/metron-interface/metron-alerts/scripts/alerts-server.js deleted file mode 100644 index 716f37b..0000000 --- a/metron-interface/metron-alerts/scripts/alerts-server.js +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env node -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -var os = require('os'); -var app = require('express')(); -var path = require('path'); -var compression = require('compression'); -var serveStatic = require('serve-static'); -var favicon = require('serve-favicon'); -var proxy = require('http-proxy-middleware'); -var argv = require('optimist') - .demand(['c']) - .alias('c', 'config_file') - .usage('Usage: alerts-server.js -c [config_file]') - .describe('c', 'Path to alerts_ui.yml') - .argv; -var YAML = require('yamljs'); - -var metronUIAddress = ''; -var ifaces = os.networkInterfaces(); -var uiConfig = YAML.load(argv.c); - -Object.keys(ifaces).forEach(function (dev) { - ifaces[dev].forEach(function (details) { - if (details.family === 'IPv4') { - metronUIAddress += '\n'; - metronUIAddress += 'http://' + details.address + ':' + uiConfig.port; - } - }); -}); - -function setCustomCacheControl (res, path) { - if (serveStatic.mime.lookup(path) === 'text/html') { - res.setHeader('Cache-Control', 'public, max-age=10') - } - res.setHeader("Expires", new Date(Date.now() + 2592000000).toUTCString()); -} - -app.use(compression()); - -var restUrl = 'http://' + uiConfig.rest.host + ':' + uiConfig.rest.port; -app.use('/api/v1', proxy(restUrl)); -app.use('/logout', proxy(restUrl)); - -app.use(favicon(path.join(__dirname, '../alerts-ui/favicon.ico'))); - -app.use(serveStatic(path.join(__dirname, '../alerts-ui'), { - maxAge: '1d', - setHeaders: setCustomCacheControl -})); - -app.get('*', function(req, res){ - res.sendFile(path.join(__dirname, '../alerts-ui/index.html')); -}); - -app.listen(uiConfig.port, function(){ - console.log("Metron alerts ui is listening on " + metronUIAddress); -}); http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts/scripts/metron-alerts-ui ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts/scripts/metron-alerts-ui b/metron-interface/metron-alerts/scripts/metron-alerts-ui deleted file mode 100644 index bb8e67c..0000000 --- a/metron-interface/metron-alerts/scripts/metron-alerts-ui +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# metron alerts UI service -# chkconfig: - 20 80 -# description: Alerts UI -# processname: metron-alerts-ui -# - -# all LSB compliant distributions provide the following -# http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptfunc.html -if [ -f /lib/lsb/init-functions ]; then - . /lib/lsb/init-functions -fi - -NAME=metron-alerts-ui -DESC="Metron Alerts UI" -METRON_VERSION=${project.version} -METRON_HOME=/usr/metron/$METRON_VERSION -METRON_LOG_DIR="/var/log/metron" -METRON_PID_DIR="/var/run/metron" -METRON_USER="metron" -METRON_GROUP="metron" -METRON_SYSCONFIG="/etc/default/metron" -if [ -f "$METRON_SYSCONFIG" ]; then - set -a - . "$METRON_SYSCONFIG" -fi - -PIDFILE="$METRON_PID_DIR/$NAME.pid" - -DAEMON="node $METRON_HOME/web/expressjs/alerts-server.js -c $METRON_HOME/config/alerts_ui.yml" - -# -# start the rest application -# -start() { - - # if pidfile exists, do not start another - if [ -f $PIDFILE ]; then - PID=`cat $PIDFILE` - printf "OK [$PID]\n" - return - fi - - if [ ! -d "$METRON_LOG_DIR" ]; then - mkdir -p "$METRON_LOG_DIR" && chown "$METRON_USER":"$METRON_GROUP" "$METRON_LOG_DIR" - fi - - if [ ! -d "$METRON_PID_DIR" ]; then - mkdir -p "$METRON_PID_DIR" && chown "$METRON_USER":"$METRON_GROUP" "$METRON_PID_DIR" - fi - - # kick-off the daemon - CMD="$DAEMON >> $METRON_LOG_DIR/$NAME.log 2>&1 & echo \$!" - PID=`su -c "$CMD" $METRON_USER` - - if [ -z $PID ]; then - printf "Fail\n" - else - echo $PID > $PIDFILE - printf "Ok [$PID]\n" - fi -} - -# -# stop the rest application -# -stop() { - if [ -f $PIDFILE ]; then - PID=`cat $PIDFILE` - while sleep 1 - echo -n "." - kill -0 $PID >/dev/null 2>&1 - do - kill $PID - done - rm -f $PIDFILE - printf "%s\n" "Ok" - else - printf "%s\n" "Not running" - fi -} - -# -# status check of the rest application -# -status() { - if [ -f $PIDFILE ]; then - PID=`cat $PIDFILE` - if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then - printf "%s\n" "Process dead but pidfile exists" - else - echo "Running" - fi - else - printf "%s\n" "Service not running" - fi -} - -case "$1" in - - ############################################################################## - # start - # - start) - printf "%-50s \n" "Starting $NAME..." - start - ;; - - ############################################################################## - # status - # - status) - printf "%-50s \n" "Checking $NAME..." - status - ;; - - ############################################################################## - # stop - # - stop) - printf "%-50s \n" "Stopping $NAME..." - stop - ;; - - ############################################################################## - # restart - # - restart) - $0 stop - $0 start - ;; - - ############################################################################## - # reload - # - reload) - ;; - - *) - echo "Usage: $0 {status|start|stop|restart}" - exit 1 -esac http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-alerts/scripts/package.json ---------------------------------------------------------------------- diff --git a/metron-interface/metron-alerts/scripts/package.json b/metron-interface/metron-alerts/scripts/package.json deleted file mode 100644 index d41da81..0000000 --- a/metron-interface/metron-alerts/scripts/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "metron-alerts-ui-web-server", - "version": "0.4.0", - "description": "Metron alerts ui web server", - "main": "server.js", - "dependencies": { - "compression": "1.6.2", - "express": "4.15.2", - "http-proxy-middleware": "0.17.4", - "optimist": "0.6.1", - "serve-favicon": "2.4.2", - "serve-static": "1.12.1" - }, - "devDependencies": {}, - "scripts": { - "start": "node server.js" - }, - "private": true, - "author": "", - "license": "Apache 2.0" -} http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config-host/pom.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config-host/pom.xml b/metron-interface/metron-config-host/pom.xml new file mode 100644 index 0000000..f51692b --- /dev/null +++ b/metron-interface/metron-config-host/pom.xml @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software + Foundation (ASF) under one or more contributor license agreements. See the + NOTICE file distributed with this work for additional information regarding + copyright ownership. The ASF licenses this file to You under the Apache License, + Version 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.metron.ui</groupId> + <artifactId>metron-config-host</artifactId> + <packaging>jar</packaging> + + <name>Metron Config UI Host</name> + <description>Spring Server to host config ui</description> + + <parent> + <groupId>org.apache.metron</groupId> + <artifactId>metron-interface</artifactId> + <version>0.5.1</version> + </parent> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.metron</groupId> + <artifactId>metron-config</artifactId> + <version>${project.parent.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.metron</groupId> + <artifactId>metron-ui-host</artifactId> + <version>${project.parent.version}</version> + </dependency> + </dependencies> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-dependencies</artifactId> + <version>${spring-cloud.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <!-- Import dependency management from Spring Boot --> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring.boot.version}</version> + <type>pom</type> + <scope>import</scope> + <exclusions> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </dependencyManagement> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring.boot.version}</version> + <configuration> + <executable>true</executable> + <mainClass>org.apache.metron.ui.ConfigApplication</mainClass> + <embeddedLaunchScriptProperties> + <initInfoProvides>metron-config</initInfoProvides> + <initInfoDescription>Metron Management UI server</initInfoDescription> + <initInfoShortDescription>Metron Management</initInfoShortDescription> + </embeddedLaunchScriptProperties> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>unpack-shared-resources</id> + <goals> + <goal>unpack-dependencies</goal> + </goals> + <phase>generate-resources</phase> + <configuration> + <outputDirectory>${project.build.directory}/generated-resources</outputDirectory> + <includeArtifacIds>shared-resources</includeArtifacIds> + <includeGroupIds>${project.groupId}</includeGroupIds> + <excludeTransitive>true</excludeTransitive> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptor>src/main/assembly/assembly.xml</descriptor> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config-host/src/main/assembly/assembly.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config-host/src/main/assembly/assembly.xml b/metron-interface/metron-config-host/src/main/assembly/assembly.xml new file mode 100644 index 0000000..e20c39f --- /dev/null +++ b/metron-interface/metron-config-host/src/main/assembly/assembly.xml @@ -0,0 +1,39 @@ +<!-- + Licensed to the Apache Software + Foundation (ASF) under one or more contributor license agreements. See the + NOTICE file distributed with this work for additional information regarding + copyright ownership. The ASF licenses this file to You under the Apache License, + Version 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. + --> + +<assembly> + <id>archive</id> + <formats> + <format>tar.gz</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <fileSets> + <fileSet> + <directory>${project.basedir}/target</directory> + <includes> + <include>${project.artifactId}-${project.version}.jar</include> + </includes> + <outputDirectory>lib</outputDirectory> + <useDefaultExcludes>true</useDefaultExcludes> + </fileSet> + <fileSet> + <directory>${project.basedir}/src/main/scripts</directory> + <includes> + <include>metron-config.sh</include> + </includes> + <outputDirectory>bin</outputDirectory> + <useDefaultExcludes>true</useDefaultExcludes> + <filtered>true</filtered> + </fileSet> + </fileSets> +</assembly> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config-host/src/main/java/org/apache/metron/ui/ConfigApplication.java ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config-host/src/main/java/org/apache/metron/ui/ConfigApplication.java b/metron-interface/metron-config-host/src/main/java/org/apache/metron/ui/ConfigApplication.java new file mode 100644 index 0000000..d769be3 --- /dev/null +++ b/metron-interface/metron-config-host/src/main/java/org/apache/metron/ui/ConfigApplication.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.ui; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScans; + +@SpringBootApplication +@ComponentScans(value = { @ComponentScan, @ComponentScan(basePackageClasses = MetronSecurityConfig.class) }) +public class ConfigApplication extends AbstractHostApplication { + public static void main(String[] args) { + SpringApplication.run(ConfigApplication.class, args); + } +} http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config-host/src/main/resources/application.yml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config-host/src/main/resources/application.yml b/metron-interface/metron-config-host/src/main/resources/application.yml new file mode 100644 index 0000000..906b739 --- /dev/null +++ b/metron-interface/metron-config-host/src/main/resources/application.yml @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +metron: + version: 0.5.0 + +logging: + level: + root: INFO + +server: + port: 4200 + +zuul: + routes: + rest: + path: /api/v1/** + url: http://localhost:8082/api/v1 + +ribbon: + ConnectTimeout: 3000 + ReadTimeout: 60000 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config-host/src/main/scripts/metron-config.sh ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config-host/src/main/scripts/metron-config.sh b/metron-interface/metron-config-host/src/main/scripts/metron-config.sh new file mode 100644 index 0000000..5d4d72a --- /dev/null +++ b/metron-interface/metron-config-host/src/main/scripts/metron-config.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +if [ -z "${METRON_SSL_PASSWORD}" ]; then + echo "METRON_SSL_PASSWORD unset." +fi + +METRON_VERSION=${project.version} +METRON_HOME="${METRON_HOME:-/usr/metron/${METRON_VERSION}}" +METRON_SYSCONFIG="${METRON_SYSCONFIG:-/etc/default/metron}" + +echo "METRON_VERSION=${METRON_VERSION}" +echo "METRON_HOME=${METRON_HOME}" +echo "METRON_SYSCONFIG=${METRON_SYSCONFIG}" + +if [ -f "$METRON_SYSCONFIG" ]; then + echo "METRON_SYSCONFIG=${METRON_SYSCONFIG}" + set -a + . "$METRON_SYSCONFIG" +fi + +echo "METRON_SPRING_PROFILES_ACTIVE=${METRON_SPRING_PROFILES_ACTIVE}" + +METRON_CONFIG_LOCATION=" --spring.config.location=classpath:/application.yml,$METRON_HOME/config/config_ui.yml" +echo "METRON_CONFIG_LOCATION=${METRON_CONFIG_LOCATION}" +METRON_SPRING_OPTIONS+=${METRON_CONFIG_LOCATION} + +# Find the metron alerts jar +files=( "${METRON_HOME}/lib/metron-config-host-*.jar" ) +echo "Default metron-alerts-host jar is: ${files[0]}" +APP_JAR="${files[0]}" + +export CONF_FOLDER=$METHRON_HOME/config +export LOG_FOLDER=/var/log/metron/ +export PID_FOLDER=/var/run/metron/ +export RUN_ARGS=$METRON_SPRING_OPTIONS +export APP_NAME=metron-config +export MODE=service +${APP_JAR} $1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config/.gitignore ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config/.gitignore b/metron-interface/metron-config/.gitignore index 4be186c..82c2d7a 100644 --- a/metron-interface/metron-config/.gitignore +++ b/metron-interface/metron-config/.gitignore @@ -40,3 +40,6 @@ testem.log #System Files .DS_Store Thumbs.db + +# Build Files +bin/ http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config/assembly.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config/assembly.xml b/metron-interface/metron-config/assembly.xml deleted file mode 100644 index c07fbd6..0000000 --- a/metron-interface/metron-config/assembly.xml +++ /dev/null @@ -1,65 +0,0 @@ -<!-- - Licensed to the Apache Software - Foundation (ASF) under one or more contributor license agreements. See the - NOTICE file distributed with this work for additional information regarding - copyright ownership. The ASF licenses this file to You under the Apache License, - Version 2.0 (the "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - OR CONDITIONS OF ANY KIND, either express or implied. See the License for - the specific language governing permissions and limitations under the License. - --> - -<assembly> - <id>archive</id> - <formats> - <format>tar.gz</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <fileSets> - <fileSet> - <directory>${project.basedir}/dist</directory> - <outputDirectory>web/management-ui</outputDirectory> - <excludes> - <exclude>**/.npmignore</exclude> - </excludes> - <fileMode>0644</fileMode> - </fileSet> - <fileSet> - <directory>${project.basedir}/scripts</directory> - <outputDirectory>web/expressjs</outputDirectory> - <includes> - <include>package.json</include> - <include>server.js</include> - </includes> - <fileMode>0644</fileMode> - </fileSet> - <fileSet> - <directory>${project.basedir}/scripts</directory> - <outputDirectory>bin</outputDirectory> - <useDefaultExcludes>true</useDefaultExcludes> - <includes> - <include>metron-management-ui</include> - </includes> - <fileMode>0755</fileMode> - <lineEnding>unix</lineEnding> - <filtered>true</filtered> - </fileSet> - <fileSet> - <directory>${project.basedir}</directory> - <outputDirectory>web/management-ui/license</outputDirectory> - <includes> - <include>LICENSE</include> - <include>NOTICE</include> - </includes> - <fileMode>0644</fileMode> - </fileSet> - </fileSets> - <files> - <file> - <source>src/favicon.ico</source> - <outputDirectory>web/management-ui</outputDirectory> - </file> - </files> -</assembly> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config/pom.xml ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config/pom.xml b/metron-interface/metron-config/pom.xml index 14acdc6..e48515b 100644 --- a/metron-interface/metron-config/pom.xml +++ b/metron-interface/metron-config/pom.xml @@ -12,133 +12,123 @@ the specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.metron</groupId> - <artifactId>metron-interface</artifactId> - <version>0.5.1</version> - </parent> - <artifactId>metron-config</artifactId> - <url>https://metron.apache.org/</url> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <node.version>v6.2.0</node.version> - <npm.version>3.8.9</npm.version> - </properties> - <dependencies> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.3</version> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.metron</groupId> + <artifactId>metron-interface</artifactId> + <version>0.5.1</version> + </parent> + <artifactId>metron-config</artifactId> + <url>https://metron.apache.org/</url> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <node.version>v7.10.0</node.version> + <npm.version>4.2.0</npm.version> + </properties> + <dependencies> + </dependencies> + <build> + <resources> + <resource> + <directory>dist</directory> + <targetPath>public</targetPath> + </resource> + </resources> + <plugins> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.3</version> + <configuration> + <workingDirectory>./</workingDirectory> + <nodeVersion>${node.version}</nodeVersion> + <npmVersion>${npm.version}</npmVersion> + <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven> + </configuration> + <executions> + <execution> + <phase>generate-resources</phase> + <id>install node and npm</id> + <goals> + <goal>install-node-and-npm</goal> + </goals> + </execution> + <execution> + <phase>generate-resources</phase> + <id>npm install</id> + <goals> + <goal>npm</goal> + </goals> + <configuration> + <arguments>install</arguments> + </configuration> + </execution> + <execution> + <phase>generate-resources</phase> + <id>ng build</id> + <goals> + <goal>npm</goal> + </goals> <configuration> - <workingDirectory>./</workingDirectory> - <nodeVersion>${node.version}</nodeVersion> - <npmVersion>${npm.version}</npmVersion> - <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven> + <arguments>run build</arguments> </configuration> - <executions> - <execution> - <phase>generate-resources</phase> - <id>install node and npm</id> - <goals> - <goal>install-node-and-npm</goal> - </goals> - </execution> - <execution> - <phase>generate-resources</phase> - <id>npm install</id> - <goals> - <goal>npm</goal> - </goals> - <configuration> - <arguments>install</arguments> - </configuration> - </execution> - <execution> - <phase>generate-resources</phase> - <id>ng build</id> - <goals> - <goal>npm</goal> - </goals> - <configuration> - <arguments>run build</arguments> - </configuration> - </execution> - <execution> - <id>npm test</id> - <goals> - <goal>npm</goal> - </goals> - <phase>test</phase> - <configuration> - <arguments>test</arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-clean-plugin</artifactId> - <version>3.0.0</version> + </execution> + <execution> + <id>npm test</id> + <goals> + <goal>npm</goal> + </goals> + <phase>test</phase> <configuration> - <filesets> - <fileset> - <directory>coverage</directory> - <followSymlinks>false</followSymlinks> - </fileset> - <fileset> - <directory>dist</directory> - <followSymlinks>false</followSymlinks> - </fileset> - <fileset> - <directory>node</directory> - <followSymlinks>false</followSymlinks> - </fileset> - <fileset> - <directory>node_modules</directory> - <followSymlinks>false</followSymlinks> - </fileset> - </filesets> + <arguments>test</arguments> </configuration> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.0.0</version> + <configuration> + <filesets> + <fileset> + <directory>coverage</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>dist</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node</directory> + <followSymlinks>false</followSymlinks> + </fileset> + <fileset> + <directory>node_modules</directory> + <followSymlinks>false</followSymlinks> + </fileset> + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.5.0</version> + <executions> + <execution> + <id>prepend-license-header</id> + <phase>prepare-package</phase> + <goals> + <goal>exec</goal> + </goals> <configuration> - <descriptor>assembly.xml</descriptor> + <executable>./scripts/prepend_license_header.sh</executable> </configuration> - <executions> - <execution> - <id>make-assembly</id> <!-- this is used for inheritance merges --> - <phase>package</phase> <!-- bind to the packaging phase --> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.5.0</version> - <executions> - <execution> - <id>prepend-license-header</id> - <phase>prepare-package</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>./scripts/prepend_license_header.sh</executable> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config/scripts/metron-management-ui ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config/scripts/metron-management-ui b/metron-interface/metron-config/scripts/metron-management-ui deleted file mode 100644 index 76b9be8..0000000 --- a/metron-interface/metron-config/scripts/metron-management-ui +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# metron management UI service -# chkconfig: - 20 80 -# description: Management UI -# processname: metron-management-ui -# - -# all LSB compliant distributions provide the following -# http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptfunc.html -if [ -f /lib/lsb/init-functions ]; then - . /lib/lsb/init-functions -fi - -NAME=metron-management-ui -DESC="Metron Management UI" -METRON_VERSION=${project.version} -METRON_HOME=/usr/metron/$METRON_VERSION -METRON_LOG_DIR="/var/log/metron" -METRON_PID_DIR="/var/run/metron" -METRON_USER="metron" -METRON_GROUP="metron" -METRON_SYSCONFIG="/etc/default/metron" -if [ -f "$METRON_SYSCONFIG" ]; then - set -a - . "$METRON_SYSCONFIG" -fi - -PIDFILE="$METRON_PID_DIR/$NAME.pid" - -DAEMON="node $METRON_HOME/web/expressjs/server.js -c $METRON_HOME/config/management_ui.yml" - -# -# start the rest application -# -start() { - - # if pidfile exists, do not start another - if [ -f $PIDFILE ]; then - PID=`cat $PIDFILE` - printf "OK [$PID]\n" - return - fi - - if [ ! -d "$METRON_LOG_DIR" ]; then - mkdir -p "$METRON_LOG_DIR" && chown "$METRON_USER":"$METRON_GROUP" "$METRON_LOG_DIR" - fi - - if [ ! -d "$METRON_PID_DIR" ]; then - mkdir -p "$METRON_PID_DIR" && chown "$METRON_USER":"$METRON_GROUP" "$METRON_PID_DIR" - fi - - # kick-off the daemon - CMD="$DAEMON >> $METRON_LOG_DIR/$NAME.log 2>&1 & echo \$!" - PID=`su -c "$CMD" $METRON_USER` - - if [ -z $PID ]; then - printf "Fail\n" - else - echo $PID > $PIDFILE - printf "Ok [$PID]\n" - fi -} - -# -# stop the rest application -# -stop() { - if [ -f $PIDFILE ]; then - PID=`cat $PIDFILE` - while sleep 1 - echo -n "." - kill -0 $PID >/dev/null 2>&1 - do - kill $PID - done - rm -f $PIDFILE - printf "%s\n" "Ok" - else - printf "%s\n" "Not running" - fi -} - -# -# status check of the rest application -# -status() { - if [ -f $PIDFILE ]; then - PID=`cat $PIDFILE` - if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then - printf "%s\n" "Process dead but pidfile exists" - else - echo "Running" - fi - else - printf "%s\n" "Service not running" - fi -} - -case "$1" in - - ############################################################################## - # start - # - start) - printf "%-50s \n" "Starting $NAME..." - start - ;; - - ############################################################################## - # status - # - status) - printf "%-50s \n" "Checking $NAME..." - status - ;; - - ############################################################################## - # stop - # - stop) - printf "%-50s \n" "Stopping $NAME..." - stop - ;; - - ############################################################################## - # restart - # - restart) - $0 stop - $0 start - ;; - - ############################################################################## - # reload - # - reload) - ;; - - *) - echo "Usage: $0 {status|start|stop|restart}" - exit 1 -esac http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config/scripts/package.json ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config/scripts/package.json b/metron-interface/metron-config/scripts/package.json deleted file mode 100644 index 24d17e0..0000000 --- a/metron-interface/metron-config/scripts/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "metron-management-ui-web-server", - "version": "0.5.1", - "description": "Metron management ui web server", - "main": "server.js", - "dependencies": { - "compression": "1.6.2", - "express": "4.15.2", - "http-proxy-middleware": "0.17.4", - "optimist": "0.6.1", - "serve-favicon": "2.4.2", - "serve-static": "1.12.1", - "yamljs": "0.2.9" - }, - "devDependencies": {}, - "scripts": { - "start": "node server.js" - }, - "private": true, - "author": "", - "license": "Apache-2.0" -} http://git-wip-us.apache.org/repos/asf/metron/blob/54880ba8/metron-interface/metron-config/scripts/server.js ---------------------------------------------------------------------- diff --git a/metron-interface/metron-config/scripts/server.js b/metron-interface/metron-config/scripts/server.js deleted file mode 100755 index 7c8ee9e..0000000 --- a/metron-interface/metron-config/scripts/server.js +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env node -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -var os = require('os'); -var app = require('express')(); -var path = require('path'); -var compression = require('compression'); -var serveStatic = require('serve-static'); -var favicon = require('serve-favicon'); -var proxy = require('http-proxy-middleware'); -var argv = require('optimist') - .demand(['c']) - .alias('c', 'config_file') - .usage('Usage: server.js -c [config_file]') - .describe('c', 'Path to management_ui.yml') - .argv; -var YAML = require('yamljs'); - -var metronUIAddress = ''; -var ifaces = os.networkInterfaces(); -var uiConfig = YAML.load(argv.c); - -Object.keys(ifaces).forEach(function (dev) { - ifaces[dev].forEach(function (details) { - if (details.family === 'IPv4') { - metronUIAddress += '\n'; - metronUIAddress += 'http://' + details.address + ':' + uiConfig.port; - } - }); -}); - -function setCustomCacheControl (res, path) { - if (serveStatic.mime.lookup(path) === 'text/html') { - res.setHeader('Cache-Control', 'public, max-age=10') - } - res.setHeader("Expires", new Date(Date.now() + 2592000000).toUTCString()); -} - -app.use(compression()); - -var restUrl = 'http://' + uiConfig.rest.host + ':' + uiConfig.rest.port; -app.use('/api/v1', proxy(restUrl)); -app.use('/logout', proxy(restUrl)); - -app.use(favicon(path.join(__dirname, '../management-ui/favicon.ico'))); - -app.use(serveStatic(path.join(__dirname, '../management-ui'), { - maxAge: '1d', - setHeaders: setCustomCacheControl -})); - -app.get('*', function(req, res){ - res.sendFile(path.join(__dirname, '../management-ui/index.html')); -}); - -app.listen(uiConfig.port, function(){ - console.log("Metron server listening on " + metronUIAddress); -});
