Skip to content

STA SpringBoot #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM azul/zulu-openjdk-alpine:8u282-jre

# Run system update
RUN apk update
RUN apk upgrade --ignore zulu8-*
RUN apk add --no-cache --upgrade bash
RUN apk add --no-cache curl && \
rm -rf /var/cache/apk/*

# When build images, name with this tag
LABEL tag=sta

# Build arguments
ARG BUILD_VERSION=8.1.0-SNAPSHOT

# Create and use local user and group
RUN addgroup -S direct && adduser -S -D direct -G direct

# Set application location
RUN mkdir -p /opt/app
RUN chown direct:direct /opt/app
ENV PROJECT_HOME /opt/app

# Set microservice
ENV CLOUD_CONFIG=true
ENV SERVICE_PORT=8083

# Set config-service access
ENV CONFIG_SERVICE_USERNAME=admin
ENV CONFIG_SERVICE_PASSWORD=direct
ENV CONFIG_SERVICE_HOST=config-service
ENV CONFIG_SERVICE_PORT=8082

# Set msg-monitor access
ENV MSG_MONITOR_HOST=msg-monitor
ENV MSG_MONITOR_PORT=8081

# Set XD access
ENV XD_HOST=xd
ENV XD_PORT=8087

# Set RabbitMQ env variables
ENV RABBIT_MQ_HOST=rabbitmq
ENV RABBIT_MQ_PORT=5672
ENV RABBIT_MQ_USERNAME=guest
ENV RABBIT_MQ_PASSWORD=guest

# Use local user and group
USER direct:direct

# Copy application artifact
COPY bootstrap.properties $PROJECT_HOME/bootstrap.properties
COPY application.properties $PROJECT_HOME/application.properties
COPY target/direct-sta-sboot-$BUILD_VERSION.jar $PROJECT_HOME/sta.jar

# Switching to the application location
WORKDIR $PROJECT_HOME

# Run application
CMD ["java","-jar","./sta.jar"]
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# direct-sta-sboot
Direct Java RI Security and Trust Agent Standalone Spring Boot Micro-service Application

Security and Trust Agent Standalone Spring Boot Micro-service Application based on Direct Java RI8

## Build Component
This project is using maven pom.xml file for the build lifecyle.

`mvn clean install`

## Running Component
To run thins project locally with default configuration:

`java -jar direct-sta-sboot-<version>.jar`

For a custom configuration please use externalized `application.properties` along with the JAR file.

## Microservice health check

## Microservice containerization
Microservice application should be built and ready to deploy using `mvn clean isntall` command or full package built form `direct-ri-build-microsrvcs` project.

To create docker image or `sta` run command below:

`docker build -t sta:latest .`

When running created image containerized microservice will start on default port `8083` with default `admin` user and `direct` password.

## Dependencies
Running:
- `config-service` microservice with specified connection to it in the `Dockerfile`
- `msg-monitor` microservice with specified connection to it in the `Dockerfile`
- `xd` endpoint with specified connection to it in the `Dockerfile`
- `rabbitmq` message broker with specified connection to it in the `Dockerfile`

Default domain:
- domain should be added to the database through the `config-servce` or `config-ui`
13 changes: 13 additions & 0 deletions application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
server.port=${SERVICE_PORT}

direct.webservices.security.basic.user.name=${CONFIG_SERVICE_USERNAME}
direct.webservices.security.basic.user.password=${CONFIG_SERVICE_PASSWORD}

direct.config.service.url=http://${CONFIG_SERVICE_HOST}:${CONFIG_SERVICE_PORT}
direct.msgmonitor.service.url=http://${MSG_MONITOR_HOST}:${MSG_MONITOR_PORT}
direct.gateway.xd.endpointUrl=http://${XD_HOST}:${XD_PORT}/xd/service/DocumentRepository_Service

spring.rabbitmq.host: ${RABBIT_MQ_HOST}
spring.rabbitmq.port: ${RABBIT_MQ_PORT}
spring.rabbitmq.username: ${RABBIT_MQ_USERNAME}
spring.rabbitmq.password: ${RABBIT_MQ_PASSWORD}
1 change: 1 addition & 0 deletions bootstrap.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.cloud.config.enabled=${CLOUD_CONFIG}
59 changes: 32 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.nhind</groupId>
<artifactId>direct-sta-sboot</artifactId>
<version>8.1.0-SNAPSHOT</version>
<version>8.1.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Direct Java RI Security and Trust Agent Standalone Spring Boot Micro-service Application</name>
<description>Direct Java RI Security and Trust Agent Standalone Spring Boot Micro-service Application</description>
Expand All @@ -18,7 +18,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<version>2.5.6</version>
<relativePath />
</parent>
<developers>
Expand Down Expand Up @@ -73,7 +73,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down Expand Up @@ -146,17 +146,17 @@
<dependency>
<groupId>org.nhind</groupId>
<artifactId>gateway</artifactId>
<version>8.0.0</version>
<version>8.1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.nhind</groupId>
<artifactId>agent</artifactId>
<version>8.0.0</version>
<version>8.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.nhind</groupId>
<artifactId>xdmail</artifactId>
<version>8.0.0</version>
<version>8.1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
Expand Down Expand Up @@ -203,8 +203,12 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -339,24 +343,25 @@
</plugin>
</plugins>
</reporting>
<distributionManagement>
<site>
<id>nhind-site</id>
<name>NHIN Direct API publication site</name>
<url>sftp://api.nhindirect.org/x/www/api.nhindirect.org/java/site/direct-sta-sboot/${project.version}</url>
</site>
<snapshotRepository>
<id>sonatype-snapshot</id>
<name>Sonatype OSS Maven SNAPSHOT Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
<repository>
<id>sonatype-release</id>
<name>Sonatype OSS Maven Release Repositor</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<uniqueVersion>false</uniqueVersion>
</repository>
</distributionManagement>

<distributionManagement>
<site>
<id>nhind-site</id>
<name>NHIN Direct API publication site</name>
<url>sftp://api.nhindirect.org/x/www/api.nhindirect.org/java/site/direct-sta-sboot/${project.version}</url>
</site>
<snapshotRepository>
<id>sonatype-snapshot</id>
<name>Sonatype OSS Maven SNAPSHOT Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
<repository>
<id>sonatype-release</id>
<name>Sonatype OSS Maven Release Repositor</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<uniqueVersion>false</uniqueVersion>
</repository>
</distributionManagement>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@ComponentScan(basePackages = {"org.nhindirect.gateway.springconfig", "org.nhindirect.gateway.streams", "org.nhind.xdm.springconfig"})
@ComponentScan(basePackages = {"org.nhindirect.gateway.springconfig", "org.nhindirect.gateway.streams", "org.nhind.xdm.springconfig", "org.nhindirect.stagent.springconfig", "org.nhind.xd.springconfig", "org.nhind.xd.streams"})
@SpringBootApplication
@Configuration
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.nhindirect.stagent.springconfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@EnableWebSecurity
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter
{
@Override
public void configure(WebSecurity web) throws Exception
{
web.ignoring().antMatchers("/actuator/**");
}

@Override
protected void configure(HttpSecurity http) throws Exception
{
http.authorizeRequests().antMatchers("/").permitAll();

http.csrf().disable();
}
}