Commit 976f523d authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Intégration des limites pour les signatures numériques

parent 5c370403
Loading
Loading
Loading
Loading
Loading
+2 −2
Changes for composer.json: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
  "repositories"     : [
    {
      "type": "composer",
      "url" : "https://gest.unicaen.fr/packagist"
      "url" : "https://packagist.unicaen.fr"
    }
  ],

@@ -31,7 +31,7 @@
    "guzzlehttp/guzzle": "^7.0",
    "phpoffice/phpspreadsheet": "^1.29",
    "phpoffice/phpword": "^1.1",
    "unicaen/signature": "2.1.*",
    "unicaen/signature": "2.3.*",
    "ext-gettext": "*",
    "ext-fileinfo": "*",
    "symfony/filesystem": "^7.1",
+4 −4
Changes for composer.lock: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
        "This file is @generated automatically"
    ],
    "content-hash": "a357f1cdb50d569594c4b8e44b451e19",
    "content-hash": "57b78b6fda828250e25af2c131bebd96",
    "packages": [
        {
            "name": "apereo/phpcas",
@@ -9171,11 +9171,11 @@
        },
        {
            "name": "unicaen/signature",
            "version": "2.1.1",
            "version": "2.3.1",
            "source": {
                "type": "git",
                "url": "https://git.unicaen.fr/lib/unicaen/signature.git",
                "reference": "479640214aa97d5740274aea8472fd17def491e4"
                "reference": "06290bf27c123852bee9019edb46e41315952a40"
            },
            "require": {
                "ext-fileinfo": "*",
@@ -9205,7 +9205,7 @@
                }
            },
            "description": "Module de signature électronique",
            "time": "2025-10-24T13:01:36+00:00"
            "time": "2026-10-02T10:06:56+00:00"
        },
        {
            "name": "unicaen/utilisateur",
+28 −0
Changes for module/Oscar/src/Oscar/Service/ContractDocumentService.php: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -165,6 +165,9 @@ class ContractDocumentService implements UseOscarConfigurationService, UseEntity
            $activity->getLabel(),
        );

        $fileSize = $document->getFileSize();
        $fileMime = $document->getFileTypeMime();

        // Patch (texte trop long)
        if( strlen($contextShort) > 255 ){
            $contextShort = substr($contextShort, 0, 250) . '...';
@@ -193,8 +196,29 @@ class ContractDocumentService implements UseOscarConfigurationService, UseEntity
            }
        }

        $errors = [];
        // Configuration du Flow / Comparaison à la configuration initiale
        foreach ($signatureFlowDatas['steps'] as &$step) {

            if(array_key_exists('limitFormat', $step) && !in_array($fileMime, $step['limitFormat']) ) {
                $errors[] = sprintf(
                    _("L'étape '%s' (parapheur %s) n'autorise pas ce format de fichier '%s'"),
                    $step['label'],
                    $step['letterfilename'],
                    $fileMime,
                );
            }

            if($step['limitSize'] > 0 && $fileSize > $step['limitSize']) {
                $limitSize = ceil(intval($step['limitSize'])/1024/1024);
                $errors[] = sprintf(
                    _("L'étape '%s' (parapheur %s) n'autorise pas des fichiers dont la taille dépasse les %sMo"),
                    $step['label'],
                    $step['letterfilename'],
                    $limitSize,
                );
            }

            if ($step['editable']) {
                if (array_key_exists($step['id'], $sortedFlowDatas)) {
                    $config = $sortedFlowDatas[$step['id']];
@@ -229,6 +253,10 @@ class ContractDocumentService implements UseOscarConfigurationService, UseEntity
            }
        }

        if( count($errors) ){
            throw new OscarException("Impossible de signer ce document : " . implode(", ", $errors));
        }

        if ($signatureFlowDatas['missing_recipients']) {
            throw new OscarException("Ils manquent des destinataires pour déclencher le processus de signature");
        }
+8 −0
Changes for module/Oscar/src/Oscar/Service/ProjectGrantApiService.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -669,6 +669,7 @@ class ProjectGrantApiService implements
            $allowProcessCreate = false;
            $allowProcessDelete = false;
            $allowProcessUpdate = false;
            $unsignableMessages = [];

            // Il y a un processus en cours
            if ($process) {
@@ -695,6 +696,13 @@ class ProjectGrantApiService implements

                $allowProcessCreate = true;
                $sService = $this->getServiceContainer()->get(SignatureService::class);

//                if (!array_key_exists($doc->getFileTypeMime(), $sService->getSignatureConfigurationService()->getDocumentMimes())) {
//                    $allowProcessCreate = false;
//                    $unsignableMessages[] = "Type de document non supporté";
//                }


                if (!array_key_exists($doc->getFileTypeMime(), $sService->getSignatureConfigurationService()->getDocumentMimes())) {
                    $allowProcessCreate = false;
                }
+33 −0
Changes for ui/src/views/DocumentsList.vue: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -180,6 +180,12 @@
            <small>Procédure de signature</small><br>
            <strong>{{ selectedSignProcess.label }}</strong>
          </h3>
          <div v-if="errors && errors.length" class="alert alert-danger">
            <ul>
              <li v-for="err in errors">{{ err }}</li>
            </ul>
          </div>
          <section v-else>
            <article v-for="step in selectedSignProcess.steps" class="step"
                     :class="step.missing_recipients ? 'error' : 'ok'">
              <h4>ÉTAPE {{ step.order }} :<strong>{{ step.label }}</strong></h4>
@@ -231,6 +237,7 @@
              </div>
            </article>
          </section>
        </section>
      </div>

      <div class="alert alert-danger" v-if="signProcessError">
@@ -488,6 +495,32 @@ export default {
    }
  },

  computed: {
    errors(){
      let errors = [];
      let docSize = this.signDocument.fileSize;
      let docMime = this.signDocument.typeMime;

      this.selectedSignProcess.steps.forEach(step => {
        let stepSizeHuman = Math.ceil(step.limitSize/1024/1024)+"Mo";
        if( step.limitSize > 0 && docSize >= step.limitSize ){
          errors.push("Le fichier est trop volumineux pour l'étape "
              + step.label
              + '(' + step.letterfile_label +')'
              +". Limité à " + stepSizeHuman);
        }
        if( step.limitFormat.length && step.limitFormat.indexOf(docMime) == -1 ){
          errors.push("Le format '"
              +docMime+"' de fichier n'est pas supporté pour l'étape " + step.label
              + ", Parapheur : " + step.letterfile_label
          );
        }
      });

      return errors;
    }
  },

  methods: {
    urlShow(url = null) {
      console.log(url);