diff --git a/api/api-pastis/pastis-standalone/pom.xml b/api/api-pastis/pastis-standalone/pom.xml index 3f1b0d1e767..0ad004fa2e2 100644 --- a/api/api-pastis/pastis-standalone/pom.xml +++ b/api/api-pastis/pastis-standalone/pom.xml @@ -1,399 +1,426 @@ - - api-pastis - fr.gouv.vitamui - 7.1.1-SNAPSHOT - - 4.0.0 + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + api-pastis + fr.gouv.vitamui + 7.1.1-SNAPSHOT + + 4.0.0 - pastis-standalone - Pastis Standalone Version - VITAMUI Pastis Standalone API + pastis-standalone + Pastis Standalone Version + VITAMUI Pastis Standalone API - - 11 - 11 - 11 - / - pastis - false - src/main/java - ui - false - false - false - false - false - ${project.parent.parent.parent.basedir} - + + 11 + 11 + 11 + / + pastis + false + src/main/java + ui + false + false + false + false + false + ${project.parent.parent.parent.basedir} + + - - - fr.gouv.vitam - common-public - - - org.projectlombok - lombok - compile - - - fr.gouv.vitamui - pastis-external - - - fr.gouv.vitamui - pastis-client - - - fr.gouv.vitamui.commons - commons-rest - - - fr.gouv.vitamui.commons - commons-vitam - - - fr.gouv.vitamui - security-client - - - fr.gouv.vitamui - iam-internal-client - - - fr.gouv.vitamui - referential-internal-client - - - fr.gouv.vitamui - iam-security - - - org.springframework.boot - spring-boot-starter-webflux - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-configuration-processor - - - org.springframework.cloud - spring-cloud-starter-consul-discovery - - - org.apache.httpcomponents - httpcore - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.security - spring-security-test - - - fr.gouv.vitamui - iam-commons - - - fr.gouv.vitamui - iam-external-client - - - fr.gouv.vitamui.commons - commons-test - - - - - org.skyscreamer - jsonassert - ${jsonassert.version} - compile - - - - com.sun.xml.bind - jaxb-impl - 2.3.1 - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-devtools - - - - - io.springfox - springfox-swagger2 - - - io.springfox - springfox-swagger-ui - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.junit.vintage - junit-vintage-engine - test - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - build-info - - build-info - - - - - repackage - - - - - true - false - fr.gouv.vitamui.pastis.standalone.ApiPastisStandaloneApplication - - - - - - - - standalone + + + fr.gouv.vitam + common-public + + + org.projectlombok + lombok + compile + + + fr.gouv.vitamui + pastis-external + + + fr.gouv.vitamui + pastis-client + + + fr.gouv.vitamui.commons + commons-rest + + + fr.gouv.vitamui.commons + commons-vitam + + + fr.gouv.vitamui + security-client + + + fr.gouv.vitamui + iam-internal-client + + + fr.gouv.vitamui + referential-internal-client + + + fr.gouv.vitamui + iam-security + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-configuration-processor + + + org.springframework.cloud + spring-cloud-starter-consul-discovery + + + org.apache.httpcomponents + httpcore + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-test + + + fr.gouv.vitamui + iam-commons + + + fr.gouv.vitamui + iam-external-client + + + fr.gouv.vitamui.commons + commons-test + + + + + org.skyscreamer + jsonassert + ${jsonassert.version} + compile + + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-devtools + - - - :pastis-standalone - + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + + + org.springframework.boot + spring-boot-starter-test + test + - - fr.gouv.vitamui - ui-frontend - provided - pom - ${project.version} + org.junit.vintage + junit-vintage-engine + test - + + - - - - target/www/ - static/ - - - src/main/resources - - - - - src/test/resources - true - - + - - - com.github.eirslett - frontend-maven-plugin - - - org.apache.maven.plugins - maven-antrun-plugin - - - - download-jdk - initialize - - run - + + org.springframework.boot + spring-boot-maven-plugin + + + build-info + + build-info + + + + + repackage + + + - - - + true + false + fr.gouv.vitamui.pastis.standalone.ApiPastisStandaloneApplication - + + + - - - unzip-jdk - package - - - - - - - - run - - - - + + + develop + + false + + + + + org.springframework.boot + spring-boot-maven-plugin + + + dev + + + + + + + + standalone - - - com.akathist.maven.plugins.launch4j - launch4j-maven-plugin - ${launch4j-maven-plugin.version} - - - l4j-clui - package - - launch4j - - - - - console - ${project.build.directory}/${project.build.finalName}.${project.packaging} - ${project.build.directory}/${project.build.finalName}.exe - Erreur - - 11 - ./jdk11/jdk-11 - - - - - 1.0.0.0 - 1.0.0.0 - ${project.build.finalName} - ${project.build.finalName} - 1.0.0.0 - Programme Vitam - pastis - - - - - - maven-resources-plugin - - - copy-resources-jre - - package - - copy-resources - - - ${basedir}/target/win32/java - + + + :pastis-standalone + + + + + fr.gouv.vitamui + ui-frontend + provided + pom + ${project.version} + + + + + - ${java.home} + target/www/ + static/ - - - - - + + src/main/resources + + + + + src/test/resources + true + + + + + + com.github.eirslett + frontend-maven-plugin + + + org.apache.maven.plugins + maven-antrun-plugin + + + + download-jdk + initialize + + run + + + + + + + - - - maven-assembly-plugin - - - assembly - package - - single - - - - ${project.basedir}/src/main/assembly/packaging-zip.xml - - - - - - - + + + unzip-jdk + package + + + + + + + + run + + + + + + + + com.akathist.maven.plugins.launch4j + launch4j-maven-plugin + ${launch4j-maven-plugin.version} + + + l4j-clui + package + + launch4j + + + + + console + + ${project.build.directory}/${project.build.finalName}.${project.packaging} + ${project.build.directory}/${project.build.finalName}.exe + Erreur + + 11 + ./jdk11/jdk-11 + + + + + 1.0.0.0 + 1.0.0.0 + ${project.build.finalName} + ${project.build.finalName} + 1.0.0.0 + Programme Vitam + pastis + + + + + + maven-resources-plugin + + + copy-resources-jre + + package + + copy-resources + + + ${basedir}/target/win32/java + + + ${java.home} + + + + + + + + + + maven-assembly-plugin + + + assembly + package + + single + + + + + ${project.basedir}/src/main/assembly/packaging-zip.xml + + + + + + + - - - releases - ${env.SERVICE_NEXUS_URL}/repository/maven-releases/ - - - snapshots - ${env.SERVICE_NEXUS_URL}/repository/maven-snapshots/ - - - ${project.artifactId}-site - ${project.baseUri} - - + + + releases + ${env.SERVICE_NEXUS_URL}/repository/maven-releases/ + + + snapshots + ${env.SERVICE_NEXUS_URL}/repository/maven-snapshots/ + + + ${project.artifactId}-site + ${project.baseUri} + + - - - vitam - ${env.SERVICE_NEXUS_URL}/repository/maven-public/ - - + + + vitam + ${env.SERVICE_NEXUS_URL}/repository/maven-public/ + + - - - - vitam - ${env.SERVICE_NEXUS_URL}/repository/maven-public/ - - true - - - false - - - + + + + vitam + ${env.SERVICE_NEXUS_URL}/repository/maven-public/ + + true + + + false + + + - - - + + + \ No newline at end of file diff --git a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/ApiPastisStandaloneApplication.java b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/ApiPastisStandaloneApplication.java index fc7a1d80cab..af6eb0972d3 100644 --- a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/ApiPastisStandaloneApplication.java +++ b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/ApiPastisStandaloneApplication.java @@ -38,13 +38,15 @@ package fr.gouv.vitamui.pastis.standalone; +import fr.gouv.vitamui.pastis.standalone.config.PastisConfiguration; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.event.EventListener; -import java.awt.*; +import java.awt.Desktop; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -52,6 +54,13 @@ @SpringBootApplication public class ApiPastisStandaloneApplication extends SpringBootServletInitializer { + private final PastisConfiguration pastisConfiguration; + + @Autowired + public ApiPastisStandaloneApplication(final PastisConfiguration pastisConfiguration) { + this.pastisConfiguration = pastisConfiguration; + } + public static void main(String[] args) { new SpringApplicationBuilder(ApiPastisStandaloneApplication.class).headless(false).run(args); } @@ -63,6 +72,6 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder applicatio @EventListener(ApplicationReadyEvent.class) public void openBrowserAfterStartup() throws IOException, URISyntaxException { - Desktop.getDesktop().browse(new URI(("http://localhost:8096"))); + Desktop.getDesktop().browse(new URI(pastisConfiguration.url)); } } diff --git a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java index 62c85e338a1..f853d9e03a1 100644 --- a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java +++ b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java @@ -35,21 +35,18 @@ The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept its terms. */ + package fr.gouv.vitamui.pastis.standalone.config; import fr.gouv.vitamui.pastis.common.service.JsonFromPUA; import fr.gouv.vitamui.pastis.common.service.PuaFromJSON; import fr.gouv.vitamui.pastis.common.service.PuaPastisValidator; import fr.gouv.vitamui.pastis.server.service.PastisService; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ResourceLoader; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import static java.util.Collections.emptyMap; import static org.springframework.http.HttpStatus.NOT_FOUND; @@ -58,20 +55,8 @@ @Configuration public class PastisConfiguration { - private ResourceLoader resourceLoader; - - @Value("${cors.allowed-origins}") - private String origins; - - @Bean - public WebMvcConfigurer corsConfigurer() { - return new WebMvcConfigurer() { - @Override - public void addCorsMappings(@NotNull CorsRegistry registry) { - registry.addMapping("/**").allowedOrigins(origins.split(",")).allowCredentials(true); - } - }; - } + @Value("${pastis.client.url}") + public String url; @Bean public ErrorViewResolver customErrorViewResolver() { @@ -91,7 +76,7 @@ public PuaFromJSON puaFromJSON() { @Bean public PastisService pastisService() { - return new PastisService(this.resourceLoader, puaPastisValidator(), jsonFromPUA(), puaFromJSON()); + return new PastisService(null, puaPastisValidator(), jsonFromPUA(), puaFromJSON()); } @Bean diff --git a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/WebConfig.java b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/WebConfig.java new file mode 100644 index 00000000000..3fa04a5308e --- /dev/null +++ b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/WebConfig.java @@ -0,0 +1,63 @@ +/* + * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022) + * + * contact.vitam@culture.gouv.fr + * + * This software is a computer program whose purpose is to implement a digital archiving back-office system managing + * high volumetry securely and efficiently. + * + * This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free + * software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as + * circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, + * users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the + * successive licensors have only limited liability. + * + * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or + * developing or reproducing the software by the user in light of its specific status of free software, that may mean + * that it is complicated to manipulate, and that also therefore means that it is reserved for developers and + * experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the + * software's suitability as regards their requirements in conditions enabling the security of their systems and/or data + * to be ensured and, more generally, to use and operate it in the same conditions as regards security. + * + * The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you + * accept its terms. + */ + +package fr.gouv.vitamui.pastis.standalone.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Value("${cors.allowed-origins}") + private String[] origins; + + @Value("${cors.allowed-methods}") + private String[] methods; + + @Value("${cors.allowed-headers}") + private String[] headers; + + @Value("${cors.allow-credentials}") + private boolean credentials; + + @Value("${cors.max-age}") + private long maxAge; + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry + .addMapping("/**") + .allowedOrigins(origins) + .allowedMethods(methods) + .allowedHeaders(headers) + .allowCredentials(credentials) + .maxAge(maxAge); + } +} diff --git a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/controller/PastisController.java b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/controller/PastisController.java index 5b5a220b857..4b27b295e65 100644 --- a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/controller/PastisController.java +++ b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/controller/PastisController.java @@ -56,7 +56,11 @@ import org.springframework.core.io.Resource; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.server.ResponseStatusException; @@ -92,6 +96,10 @@ public PastisController(final PastisService profileService) { this.profileService = profileService; } + private static boolean isInvalidFilename(String fileName) { + return VitamUIStringUtils.HTML_PATTERN.matcher(fileName).find(); + } + @Operation( summary = "Retrieve RNG representation of the JSON structure", description = "Retrieve RNG representation of the JSON structure of archive profile", @@ -217,10 +225,6 @@ ResponseEntity> getFiles() throws TechnicalException { } } - private static boolean isInvalidFilename(String fileName) { - return VitamUIStringUtils.HTML_PATTERN.matcher(fileName).find(); - } - enum ErrorMessage { INVALID_FILE_NAME("Invalid file name"), NO_PROFILE_RESPONSE("No profile response"), diff --git a/api/api-pastis/pastis-standalone/src/main/resources/application-dev.yml b/api/api-pastis/pastis-standalone/src/main/resources/application-dev.yml new file mode 100644 index 00000000000..9e185664e0a --- /dev/null +++ b/api/api-pastis/pastis-standalone/src/main/resources/application-dev.yml @@ -0,0 +1,15 @@ +pastis.client.url: https://localhost:8097 + +cors: + allowed-origins: > + http://localhost:8096, + https://localhost:8097 + allowed-methods: > + GET, + POST, + PUT, + DELETE, + OPTIONS + allowed-headers: "*" + allow-credentials: true + max-age: 3600 \ No newline at end of file diff --git a/api/api-pastis/pastis-standalone/src/main/resources/application.yml b/api/api-pastis/pastis-standalone/src/main/resources/application.yml index eaae8ebf977..0fbf92c9a58 100644 --- a/api/api-pastis/pastis-standalone/src/main/resources/application.yml +++ b/api/api-pastis/pastis-standalone/src/main/resources/application.yml @@ -11,14 +11,11 @@ spring: mvc: favicon: enabled: false - jackson: - serialization: - write-dates-as-timestamps: false -#Spring -spring.servlet.multipart: - max-file-size: 10MB - max-request-size: 11MB - enabled: true + jackson.serialization.write-dates-as-timestamps: false + servlet.multipart: + max-file-size: 10MB + max-request-size: 11MB + enabled: true #Spring docs swagger springdoc: @@ -53,4 +50,19 @@ management: show-details: always prometheus: enabled: true -cors.allowed-origins: https://dev.vitamui.com:4251,https://localhost,http://localhost:8096,http://localhost:8097 + +pastis.client.url: http://localhost:8096 + +cors: + allowed-origins: > + http://localhost:8096, + https://localhost:8096 + allowed-methods: > + GET, + POST, + PUT, + DELETE, + OPTIONS + allowed-headers: "*" + allow-credentials: true + max-age: 3600 diff --git a/ui/ui-frontend-common/src/app/modules/authentication/services/authenticator.service.ts b/ui/ui-frontend-common/src/app/modules/authentication/services/authenticator.service.ts index a9514b651e0..2c8d154a3d2 100644 --- a/ui/ui-frontend-common/src/app/modules/authentication/services/authenticator.service.ts +++ b/ui/ui-frontend-common/src/app/modules/authentication/services/authenticator.service.ts @@ -36,10 +36,10 @@ */ import { Observable } from 'rxjs'; -export interface AuthenticatorService { - login(): Observable; - logout(): void; - logoutSubrogationAndRedirectToLoginPage(username: string): void; - initSubrogationFlow(superUser: string, superUserCustomerId: string, surrogate: string, surrogateCustomerId: string): void; - redirectToLoginPage(): void; +export abstract class AuthenticatorService { + abstract login(): Observable; + abstract logout(): void; + abstract logoutSubrogationAndRedirectToLoginPage(username: string): void; + abstract initSubrogationFlow(superUser: string, superUserCustomerId: string, surrogate: string, surrogateCustomerId: string): void; + abstract redirectToLoginPage(): void; } diff --git a/ui/ui-frontend-common/src/app/modules/authentication/services/oidc-authenticator.service.ts b/ui/ui-frontend-common/src/app/modules/authentication/services/oidc-authenticator.service.ts index ac6dc2f4c24..db55657704b 100644 --- a/ui/ui-frontend-common/src/app/modules/authentication/services/oidc-authenticator.service.ts +++ b/ui/ui-frontend-common/src/app/modules/authentication/services/oidc-authenticator.service.ts @@ -35,9 +35,9 @@ * knowledge of the CeCILL-C license and that you accept its terms. */ import { OAuthService, OAuthSuccessEvent } from 'angular-oauth2-oidc'; -import { from, Observable, zip } from 'rxjs'; -import { AuthenticatorService } from './authenticator.service'; +import { Observable, from, zip } from 'rxjs'; import { map, skipWhile, take, tap } from 'rxjs/operators'; +import { AuthenticatorService } from './authenticator.service'; export class OidcAuthenticatorService implements AuthenticatorService { constructor( diff --git a/ui/ui-frontend-common/src/app/modules/index.ts b/ui/ui-frontend-common/src/app/modules/index.ts index e193b7af2d9..c9f1e137545 100644 --- a/ui/ui-frontend-common/src/app/modules/index.ts +++ b/ui/ui-frontend-common/src/app/modules/index.ts @@ -56,6 +56,7 @@ export * from './archive-unit/index'; export * from './auth.guard'; export * from './auth.service'; export { AuthenticationModule } from './authentication/authentication.module'; +export * from './authentication/services/authenticator.service'; export * from './country.service'; export * from './error-dialog/error-dialog.component'; export * from './global-event.service'; diff --git a/ui/ui-frontend/package-lock.json b/ui/ui-frontend/package-lock.json index 9860c562282..1f49ff11c59 100644 --- a/ui/ui-frontend/package-lock.json +++ b/ui/ui-frontend/package-lock.json @@ -19262,7 +19262,7 @@ "node_modules/ui-frontend-common": { "version": "2.1.58", "resolved": "file:../ui-frontend-common/ui-frontend-common-2.1.58.tgz", - "integrity": "sha512-QWZEcRYtL1Y/OFKSXpMl9oBGe1dZTmWRescu8KO4wpId1bID3M5QYsrbMFsJVsodh0Tqj8EpsILvXK2LLKNnxw==", + "integrity": "sha512-6NJMSnit8z1R3f8+frlqmVBZIt4QrRePqTf7STHCAytZUBxGmflXsu8SG6FdvLepu6/E1xXdMR8x6+RdoEjq2w==", "dependencies": { "@angular/material-moment-adapter": "^10.2.3", "@ngx-translate/core": "13.0.0", @@ -35034,7 +35034,7 @@ }, "ui-frontend-common": { "version": "file:../ui-frontend-common/ui-frontend-common-2.1.58.tgz", - "integrity": "sha512-QWZEcRYtL1Y/OFKSXpMl9oBGe1dZTmWRescu8KO4wpId1bID3M5QYsrbMFsJVsodh0Tqj8EpsILvXK2LLKNnxw==", + "integrity": "sha512-6NJMSnit8z1R3f8+frlqmVBZIt4QrRePqTf7STHCAytZUBxGmflXsu8SG6FdvLepu6/E1xXdMR8x6+RdoEjq2w==", "requires": { "@angular/material-moment-adapter": "^10.2.3", "@ngx-translate/core": "13.0.0", diff --git a/ui/ui-frontend/package.json b/ui/ui-frontend/package.json index 659e5b3488a..70b5b673027 100644 --- a/ui/ui-frontend/package.json +++ b/ui/ui-frontend/package.json @@ -22,6 +22,7 @@ "start:pastis": "ng serve pastis --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt", "start:pastis:gateway": "npm run start:pastis -- --proxy-config proxy-gateway.conf.js", "start:pastis:gateway-next": "npm run start:pastis -- --proxy-config proxy-gateway-next.conf.js", + "start:pastis:standalone": "ng serve pastis --configuration standalone --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt", "start:referential": "ng serve referential --proxy-config proxy.conf.json --disable-host-check --ssl --ssl-key $npm_package_pki_path/$npm_package_pki_asset.key --ssl-cert $npm_package_pki_path/$npm_package_pki_asset.crt", "start:referential:gateway": "npm run start:referential -- --proxy-config proxy-gateway.conf.js", "start:referential:gateway-next": "npm run start:referential -- --proxy-config proxy-gateway-next.conf.js", diff --git a/ui/ui-frontend/projects/pastis/src/app/app.module.ts b/ui/ui-frontend/projects/pastis/src/app/app.module.ts index b086b76af2f..fe8ae85b242 100644 --- a/ui/ui-frontend/projects/pastis/src/app/app.module.ts +++ b/ui/ui-frontend/projects/pastis/src/app/app.module.ts @@ -63,6 +63,7 @@ import { environment } from '../environments/environment'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { PastisConfiguration } from './core/classes/pastis-configuration'; +import { NoAuthenticationModule } from './standalone/no-authentication.module'; import { StandaloneStartupService } from './standalone/standalone-startup.service'; import { StandaloneThemeService } from './standalone/standalone-theme.service'; @@ -81,11 +82,12 @@ registerLocaleData(localeFr, 'fr'); const startupServiceClass = environment.standalone ? StandaloneStartupService : StartupService; const themeServiceClass = environment.standalone ? StandaloneThemeService : ThemeService; +const authenticationModuleClass = environment.standalone ? NoAuthenticationModule : AuthenticationModule.forRoot(); @NgModule({ declarations: [AppComponent], imports: [ - AuthenticationModule.forRoot(), + authenticationModuleClass, InjectorModule, LoggerModule.forRoot(), BrowserAnimationsModule, diff --git a/ui/ui-frontend/projects/pastis/src/app/standalone/no-authentication.module.ts b/ui/ui-frontend/projects/pastis/src/app/standalone/no-authentication.module.ts new file mode 100644 index 00000000000..30a96675898 --- /dev/null +++ b/ui/ui-frontend/projects/pastis/src/app/standalone/no-authentication.module.ts @@ -0,0 +1,28 @@ +import { APP_INITIALIZER, NgModule } from '@angular/core'; +import { AuthService, AuthenticatorService } from 'ui-frontend-common'; +import { NoAuthenticatorService } from './no-authenticator.service'; + +export function initializeApp() { + return (): Promise => Promise.resolve(true); +} + +@NgModule({ + providers: [ + { provide: AuthenticatorService, useClass: NoAuthenticatorService }, + { + provide: APP_INITIALIZER, + useFactory: initializeApp, + multi: true, + }, + ], +}) +export class NoAuthenticationModule { + private gatewayEnabled = false; + + constructor( + private authenticationService: AuthService, + private authenticatorService: AuthenticatorService, + ) { + this.authenticationService.configure(this.gatewayEnabled, this.authenticatorService); + } +} diff --git a/ui/ui-frontend/projects/pastis/src/app/standalone/no-authenticator.service.ts b/ui/ui-frontend/projects/pastis/src/app/standalone/no-authenticator.service.ts new file mode 100644 index 00000000000..af917e6aad4 --- /dev/null +++ b/ui/ui-frontend/projects/pastis/src/app/standalone/no-authenticator.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { Observable, of } from 'rxjs'; +import { AuthenticatorService } from 'ui-frontend-common'; + +@Injectable() +export class NoAuthenticatorService implements AuthenticatorService { + login(): Observable { + const authenticated = true; + + return of(authenticated); + } + + logout(): void {} + + logoutSubrogationAndRedirectToLoginPage(_username: string): void {} + + initSubrogationFlow(_superUser: string, _superUserCustomerId: string, _surrogate: string, _surrogateCustomerId: string): void {} + + redirectToLoginPage(): void {} +} diff --git a/ui/ui-frontend/projects/pastis/src/app/standalone/standalone-startup.service.ts b/ui/ui-frontend/projects/pastis/src/app/standalone/standalone-startup.service.ts index a2937e84262..6e32bbee127 100644 --- a/ui/ui-frontend/projects/pastis/src/app/standalone/standalone-startup.service.ts +++ b/ui/ui-frontend/projects/pastis/src/app/standalone/standalone-startup.service.ts @@ -67,7 +67,7 @@ export class StandaloneStartupService { @Inject(WINDOW_LOCATION) private location: any, ) {} - load(): any { + load(): Observable { this.configurationData = null; let appConf: StandaloneConfiguration = { @@ -81,7 +81,7 @@ export class StandaloneStartupService { }; this.configurationData = appConf; this.themeService.init(this.configurationData as AppConfiguration, this.configurationData.THEME_COLORS); - return appConf; + return of(appConf); } setTenantIdentifier(tenantIdentifier?: string) {