Skip to content
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

V2.1.4 #332

Merged
merged 6 commits into from
Sep 17, 2024
Merged
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
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,43 @@ Suivez les guides d'installation et d'exploitation ici : https://github.com/asit
* Tomcat 9 (Extract n’est actuellement pas compatible avec Tomcat 10 en raison de l’utilisation de Spring Boot 2)
* PostgreSQL >= 12

## Développement

### Packaging

Pour générer un WAR de l'application, il faut lancer la commande suivante
```bash
mvn package
```

Outre le fichier WAR, l'archive de livraison d'une nouvelle version contient :

* La dernière version du script de mise à jour de la base de données (`sql/update_db.sql`)
* La documentation :
* guide d'installation (`doc/MAN_ASIT_Extract_ManuelInstallation.pdf`)
* guide d'exploitation (`doc/MAN_ASIT_Extract_ManuelExploitation.pdf`)
* guide d'utilisation (`doc/MAN_ASIT_Extract_ManuelUtilisation.pdf`)
* documentation de création d'un connecteur (`doc/extract-connector-sample/`)
* documentation de création d'un plugin de tâche (`doc/extract-task-sample/`)
* Le script d'exemple FME (`fme/`)

### Tests

Les tests unitaires peuvent se lancer indépendamment du packaging par la commande
```bash
mvn -q test -Punit-tests --batch-mode --fail-at-end
```

Pour exécuter les tests d'intégration
```bash
mvn -q verify -Pintegration-tests --batch-mode
```

Pour les tests fonctionnels (nécessite que l'application tourne sur le port 8080 du localhost)
```bash
mvn -q verify -Pfunctional-tests --batch-mode
```

## Documentation et liens:

Aide et documentation : https://github.com/asit-asso/extract/wiki
Expand Down
4 changes: 2 additions & 2 deletions extract-connector-easysdiv4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-connector-easysdiv4</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -26,7 +26,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion extract-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-archive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-archive</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-email/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-email</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-fmedesktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-fmedesktop</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-fmeserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-fmeserver</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-qgisprint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-qgisprint</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>

<repositories>
Expand Down Expand Up @@ -67,7 +67,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-reject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-reject</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-remark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-remark</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract-task-validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-task-validation</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>jar</packaging>
<pluginRepositories>
<pluginRepository>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions extract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>ch.asit_asso</groupId>
<artifactId>extract</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<packaging>war</packaging>

<name>extract</name>
Expand Down Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>ch.asit_asso</groupId>
<artifactId>extract-plugin-commoninterface</artifactId>
<version>2.1.3-RELEASE</version>
<version>2.1.4-RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import ch.asit_asso.extract.persistence.RememberMeTokenRepository;
import ch.asit_asso.extract.persistence.UsersRepository;
import ch.asit_asso.extract.utils.Secrets;
import ch.asit_asso.extract.utils.UrlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.savedrequest.DefaultSavedRequest;
Expand All @@ -43,6 +45,7 @@
*/
@Component
public class ExtractAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
private final String applicationPath;

/**
* The writer to the application logs.
Expand All @@ -58,10 +61,11 @@ public class ExtractAuthenticationSuccessHandler extends SavedRequestAwareAuthen


public ExtractAuthenticationSuccessHandler(Secrets secrets, RememberMeTokenRepository tokenRepository,
UsersRepository usersRepository) {
UsersRepository usersRepository, Environment environment) {
this.secrets = secrets;
this.rememberMeRepository = tokenRepository;
this.usersRepository = usersRepository;
this.applicationPath = UrlUtils.getApplicationPath(environment.getProperty("application.external.url"));
}


Expand All @@ -87,7 +91,7 @@ public final void onAuthenticationSuccess(final HttpServletRequest request, fina
String userName = domainUser.getLogin();
this.logger.debug("Found user {}.", userName);
TwoFactorRememberMe rememberMeUser = new TwoFactorRememberMe(domainUser, this.rememberMeRepository,
this.secrets);
this.secrets, this.applicationPath);
rememberMeUser.cleanUp();

switch (user.getTwoFactorStatus()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ public class TwoFactorCookie {

private static final int DAYS_TO_LIVE = 30;

private static final String PATH = "/extract";
//private static final String PATH = "/extract";

private final String applicationPath;

private final String userHash;

private final String token;

private final Secrets secrets;

public TwoFactorCookie(@NotNull User user, @NotNull String token, @NotNull Secrets secrets) {
this(user.getLogin(), token, secrets);
public TwoFactorCookie(@NotNull User user, @NotNull String token, @NotNull Secrets secrets,
@NotNull String applicationPath) {
this(user.getLogin(), token, secrets, applicationPath);
}

public TwoFactorCookie(@NotNull String userName, @NotNull String token, @NotNull Secrets secrets) {
public TwoFactorCookie(@NotNull String userName, @NotNull String token, @NotNull Secrets secrets,
@NotNull String applicationPath) {
this.secrets = secrets;
this.userHash = this.secrets.hash(userName);
this.token = token;
this.applicationPath = applicationPath;
}

private TwoFactorCookie(@NotNull Cookie cookie, @NotNull Secrets secrets) {
Expand All @@ -46,6 +51,7 @@ private TwoFactorCookie(@NotNull Cookie cookie, @NotNull Secrets secrets) {
this.secrets = secrets;
this.userHash = this.parseUserHashFromCookieName(cookie.getName());
this.token = cookie.getValue();
this.applicationPath = cookie.getPath();
}

public static boolean isTwoFactorCookie(@NotNull Cookie cookie) {
Expand Down Expand Up @@ -87,7 +93,7 @@ public Cookie toCookie() {
public Cookie toCookie(boolean expire) {
Cookie cookie = new Cookie(this.buildCookieName(), (expire) ? null : this.token);
cookie.setHttpOnly(true);
cookie.setPath(TwoFactorCookie.PATH);
cookie.setPath(this.applicationPath);
cookie.setMaxAge((expire) ? 0 : (int) Duration.ofDays(TwoFactorCookie.DAYS_TO_LIVE).toSeconds());

return cookie;
Expand All @@ -104,7 +110,7 @@ public ResponseCookie toResponseCookie(boolean expire) {

return ResponseCookie.from(this.buildCookieName(), (expire) ? "" : this.token)
.httpOnly(true)
.path(TwoFactorCookie.PATH)
.path(this.applicationPath)
.maxAge(Duration.ofDays((expire) ? 0 : TwoFactorCookie.DAYS_TO_LIVE))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.slf4j.LoggerFactory;

public class TwoFactorRememberMe {
private final String applicationPath;

private final Logger logger = LoggerFactory.getLogger(TwoFactorRememberMe.class);

private final Secrets secrets;
Expand All @@ -27,10 +29,11 @@ public class TwoFactorRememberMe {
private final User user;

public TwoFactorRememberMe(@NotNull User user, @NotNull RememberMeTokenRepository tokenRepository,
@NotNull Secrets secrets) {
@NotNull Secrets secrets, String applicationPath) {
this.secrets = secrets;
this.repository = tokenRepository;
this.user = user;
this.applicationPath = applicationPath;
}


Expand Down Expand Up @@ -129,7 +132,8 @@ private void removeEntries() {


private void setCookie(String token, HttpServletResponse response) {
TwoFactorCookie twoFactorCookie = new TwoFactorCookie(this.user.getLogin(), token, this.secrets);
TwoFactorCookie twoFactorCookie = new TwoFactorCookie(this.user.getLogin(), token, this.secrets,
this.applicationPath);
response.addCookie(twoFactorCookie.toCookie());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,6 @@ private boolean sendEmailNotification(final Request request) {
final Set<String> recipientsAddresses
= new HashSet<>(Arrays.asList(operatorsAddresses));

for (String adminAddress : this.repositories.getUsersRepository().getActiveAdministratorsAddresses()) {

if (adminAddress == null || recipientsAddresses.contains(adminAddress)) {
continue;
}

recipientsAddresses.add(adminAddress);
}

if (!message.initialize(request, recipientsAddresses.toArray(new String[]{}))) {
this.logger.error("Could not create the request export failure message.");
return false;
Expand Down
Loading
Loading