diff --git a/docker-compose/README.md b/docker-compose/README.md index 436ffc6e..625e1684 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -5,10 +5,9 @@ This is the docker-compose setup to run eSignet Signup service with mock identit ## Run signup service in local with all its dependencies 1. Run `docker compose --file dependent-docker-compose.yml up` to start all the dependent services. -2. Go to command line for the project root directory and run `mvn clean install -Dgpg.skip=true -DskipTests=true` -3. Add [esignet-mock-plugin.jar](../signup-service/target/signup-plugins/esignet-mock-plugin.jar) to signup-service classpath in your IDE. -4. Add [kernel-auth-adapter-lite.jar](../signup-service/target/signup-plugins/kernel-auth-adapter-lite.jar) to signup-service classpath in your IDE. -5. Update below properties in [application-local.properties](../signup-service/src/main/resources/application-local.properties) with valid values: +2. Go to [signup-with-plugins](../signup-with-plugins) folder and run `mvn clean install -Dgpg.skip=true` from the command line. +3. Add [esignet-mock-plugin.jar](../signup-with-plugins/target/esignet-mock-plugin.jar) to signup-service classpath in your IDE. +4. Update below properties in [application-local.properties](../signup-service/src/main/resources/application-local.properties) with valid values: mosip.internal.domain.url=https://api-internal.dev.mosip.net diff --git a/docker-compose/dependent-docker-compose.yml b/docker-compose/dependent-docker-compose.yml index 2e5558b0..168dbac3 100644 --- a/docker-compose/dependent-docker-compose.yml +++ b/docker-compose/dependent-docker-compose.yml @@ -54,7 +54,7 @@ services: esignet: - image: 'mosipdev/esignet:release-1.5.x' + image: 'mosipdev/esignet-with-plugins:release-1.5.x' user: root ports: - 8088:8088 diff --git a/signup-service/Dockerfile b/signup-service/Dockerfile index 242c9fd0..c9d0a461 100644 --- a/signup-service/Dockerfile +++ b/signup-service/Dockerfile @@ -55,14 +55,11 @@ RUN apt-get -y update \ && chmod +x configure_start.sh \ && chown -R ${container_user}:${container_user} /home/${container_user} -# copy all files under target/esignet-plugins to the plugins folder -COPY ./target/*-plugin.jar ${plugins_path} -COPY ./target/kernel-auth-adapter-lite.jar ${loader_path} - # select container user for all tasks USER ${container_user_uid}:${container_user_gid} EXPOSE 8089 ENTRYPOINT [ "./configure_start.sh" ] -CMD java -jar -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" signup-service.jar + +CMD ["java", "-jar", "-Dloader.path=${loader_path_env}", "-Dspring.cloud.config.label=${spring_config_label_env}", "-Dspring.profiles.active=${active_profile_env}", "-Dspring.cloud.config.uri=${spring_config_url_env}", "signup-service.jar"] \ No newline at end of file diff --git a/signup-service/pom.xml b/signup-service/pom.xml index b2657fdc..25f72e29 100644 --- a/signup-service/pom.xml +++ b/signup-service/pom.xml @@ -200,6 +200,12 @@ shedlock-provider-redis-spring 4.47.0 + + + io.mosip.kernel + kernel-auth-adapter-lite + 1.2.0.1-B4 + @@ -221,51 +227,6 @@ - - org.apache.maven.plugins - maven-dependency-plugin - 3.5.0 - - - copy - package - - copy - - - - - - - io.mosip.kernel - kernel-auth-adapter-lite - ${kernel-auth-adapter-lite.version} - ${signup-plugins.location} - ${kernel-auth-adapter-lite.fileName} - jar - - - io.mosip.esignet - mosip-identity-plugin - ${mosip-identity-plugin.version} - ${signup-plugins.location} - ${mosip-identity-plugin.fileName} - jar - - - io.mosip.esignet - mock-plugin - ${signup-mock-plugin.version} - ${signup-plugins.location} - ${signup-mock-plugin.fileName} - jar - - - true - true - true - - diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/CsrfControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/CsrfControllerTest.java index 42de8c70..5ddda9be 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/CsrfControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/CsrfControllerTest.java @@ -7,13 +7,15 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.http.MediaType; import org.springframework.security.web.csrf.CsrfToken; import org.springframework.security.web.csrf.DefaultCsrfToken; @@ -25,7 +27,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) -@WebMvcTest(value = CsrfController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class}) +@WebMvcTest(value = CsrfController.class, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}), + excludeAutoConfiguration = {SecurityAutoConfiguration.class}) class CsrfControllerTest { @Autowired diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/IdentityVerificationControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/IdentityVerificationControllerTest.java index 12853ff3..22db850c 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/IdentityVerificationControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/IdentityVerificationControllerTest.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig; import io.mosip.signup.dto.*; import io.mosip.esignet.core.dto.RequestWrapper; import io.mosip.signup.dto.InitiateIdentityVerificationRequest; @@ -26,6 +27,8 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -38,7 +41,9 @@ import java.time.format.DateTimeFormatter; @RunWith(SpringRunner.class) -@WebMvcTest(value = IdentityVerificationController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class}) +@WebMvcTest(value = IdentityVerificationController.class, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}), + excludeAutoConfiguration = {SecurityAutoConfiguration.class}) @ActiveProfiles(value = {"test"}) public class IdentityVerificationControllerTest { diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java index ff5a5a2f..65d09dc4 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/RegistrationControllerTest.java @@ -10,6 +10,7 @@ import io.mosip.esignet.core.dto.RequestWrapper; import io.mosip.esignet.core.exception.EsignetException; import io.mosip.esignet.core.util.IdentityProviderUtil; +import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig; import io.mosip.signup.api.dto.ProfileDto; import io.mosip.signup.api.exception.InvalidProfileException; import io.mosip.signup.api.spi.ProfileRegistryPlugin; @@ -28,6 +29,8 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -55,7 +58,9 @@ @RunWith(SpringRunner.class) -@WebMvcTest(value = RegistrationController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class}) +@WebMvcTest(value = RegistrationController.class, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}), + excludeAutoConfiguration = {SecurityAutoConfiguration.class}) @ActiveProfiles(value = {"test"}) public class RegistrationControllerTest { diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/ResetPasswordControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/ResetPasswordControllerTest.java index 830e3239..08e62546 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/ResetPasswordControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/ResetPasswordControllerTest.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.mosip.esignet.core.dto.RequestWrapper; +import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig; import io.mosip.signup.api.util.ProfileCreateUpdateStatus; import io.mosip.signup.dto.RegistrationStatusResponse; import io.mosip.signup.dto.ResetPasswordRequest; @@ -20,6 +21,8 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -39,7 +42,9 @@ @RunWith(SpringRunner.class) -@WebMvcTest(value = ResetPasswordController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class}) +@WebMvcTest(value = ResetPasswordController.class, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}), + excludeAutoConfiguration = {SecurityAutoConfiguration.class}) @ActiveProfiles(value = {"test"}) public class ResetPasswordControllerTest { diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java index 85b62ec2..a994021a 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java @@ -6,6 +6,7 @@ package io.mosip.signup.controllers; import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig; import io.mosip.signup.helper.AuditHelper; import io.mosip.signup.services.RegistrationService; import org.junit.Test; @@ -14,6 +15,8 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -26,7 +29,9 @@ @RunWith(SpringRunner.class) -@WebMvcTest(value = SignUpController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class}) +@WebMvcTest(value = SignUpController.class, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}), + excludeAutoConfiguration = {SecurityAutoConfiguration.class}) @ActiveProfiles(value = {"test"}) public class SignUpControllerTest { diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/WebSocketControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/WebSocketControllerTest.java index f2ac8b02..b39c1dcb 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/WebSocketControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/WebSocketControllerTest.java @@ -1,5 +1,6 @@ package io.mosip.signup.controllers; +import io.mosip.kernel.auth.defaultadapter.config.SecurityConfig; import io.mosip.signup.api.dto.IdentityVerificationResult; import io.mosip.signup.api.exception.IdentityVerifierException; import io.mosip.signup.api.util.VerificationStatus; @@ -19,6 +20,8 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.util.ReflectionTestUtils; @@ -33,7 +36,9 @@ @RunWith(SpringRunner.class) -@WebMvcTest(value = WebSocketController.class, excludeAutoConfiguration = {SecurityAutoConfiguration.class}) +@WebMvcTest(value = WebSocketController.class, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {SecurityConfig.class}), + excludeAutoConfiguration = {SecurityAutoConfiguration.class}) @ActiveProfiles(value = {"test"}) public class WebSocketControllerTest { diff --git a/signup-service/src/test/resources/application-test.properties b/signup-service/src/test/resources/application-test.properties index 2c45f898..adc88835 100644 --- a/signup-service/src/test/resources/application-test.properties +++ b/signup-service/src/test/resources/application-test.properties @@ -98,6 +98,8 @@ mosip.iam.adapter.self-token-renewal-enable=true mosip.service-context=${server.servlet.context-path} mosip.service.end-points=/**/* mosip.service.exclude.auth.allowed.method=GET,POST +mosip.security.csrf-enable=false +mosip.security.cors-enable=false ## -------------------------- External endpoints ----------------------------------------------------------------------- mosip.signup.integration.impl.basepackage=io.signup.plugin.mosipid diff --git a/signup-with-plugins/Dockerfile b/signup-with-plugins/Dockerfile new file mode 100644 index 00000000..53a932d8 --- /dev/null +++ b/signup-with-plugins/Dockerfile @@ -0,0 +1,4 @@ +FROM mosipdev/signup-service:develop + +# copy all files under target to the plugins folder +COPY ./target/*.jar ${plugins_path_env} \ No newline at end of file diff --git a/signup-with-plugins/README.md b/signup-with-plugins/README.md new file mode 100644 index 00000000..bfa8ebfd --- /dev/null +++ b/signup-with-plugins/README.md @@ -0,0 +1,16 @@ +## Signup service with plugins docker + +This directory contains files required to build the Signup docker with default plugins preloaded. All the plugins +available under [esignet-plugins](https://github.com/mosip/esignet-plugins) repository is included in the "signup-with-plugins" docker image. + +Based on the configured plugin name during the runtime, corresponding plugin jar will be copied to the Signup service +classpath from the plugins directory in the docker container. +For example, "plugin_name_env" environment variable is set to "esignet-mock-plugin.jar", then "esignet-mock-plugin.jar" is copied +to loader_path in the signup service container. After successful copy Signup service is started. + +"signup-with-plugins" docker image is created with "signup-service" base image. The base image can also be directly used to start the signup +service. Mount external directory with the plugin onto "/home/mosip/plugins" directory in the container and finally set "plugin_name_env" environment variable. +With this setup, signup service should get started with the configured plugin. + +## License +This project is licensed under the terms of [Mozilla Public License 2.0](../LICENSE). \ No newline at end of file diff --git a/signup-with-plugins/pom.xml b/signup-with-plugins/pom.xml new file mode 100644 index 00000000..46d9e437 --- /dev/null +++ b/signup-with-plugins/pom.xml @@ -0,0 +1,155 @@ + + + + 4.0.0 + + + io.mosip.signup + signup-parent + 1.1.1-SNAPSHOT + + + signup-with-plugins + 1.1.1-SNAPSHOT + signup-with-plugins + pom + + Project of MOSIP eSignet signup with Plugins + https://github.com/mosip/esignet-signup + + + 11 + target + 1.3.1-SNAPSHOT + esignet-mock-plugin.jar + 1.3.1-SNAPSHOT + mosip-identity-plugin.jar + + + + + MPL 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + + + + + scm:git:git://github.com/mosip/esignet-signup.git + scm:git:ssh://github.com:mosip/esignet-signup.git + https://github.com/mosip/esignet-signup + HEAD + + + + + Mosip + mosip.emailnotifier@gmail.com + io.mosip + https://github.com/mosip/esignet-signup + + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.5.0 + + + copy + package + + copy + + + + + + + io.mosip.esignet + mosip-identity-plugin + ${mosip-identity-plugin.version} + ${signup-plugins.location} + ${mosip-identity-plugin.fileName} + jar + + + io.mosip.esignet + mock-plugin + ${signup-mock-plugin.version} + ${signup-plugins.location} + ${signup-mock-plugin.fileName} + jar + + + true + true + true + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + pl.project13.maven + git-commit-id-plugin + 3.0.1 + + + get-the-git-infos + + revision + + validate + + + + true + ${project.build.outputDirectory}/git.properties + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + ${project.basedir}/.git + json + + + + + +