SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
HEU, IL FAUT CHIFFRER LES
DONNÉES DE LA BASE !
ON FAIT COMMENT ?
CONTEXTE
Application web existante
Opération ponctuelle
Infrastructure existante
POURQUOI CHIFFRER ?
Protéger des données sensibles
DE QUI ?
De nous !
QUE DOIT-ON CHIFFRER ?
Tout ou partie ?
QUEL CHIFFREMENT UTILISER ?
Symétrique ou Asymétrique ?
SYMÉTRIQUE
Une seule clé pour chiffrer et déchiffrer
ASYMÉTRIQUE
Une paire de clé, publique/privée
SALAGE OU PAS SALAGE ?
QUELLES SOLUTIONS ?
L'ARCHITECTURE
CHIFFREMENT DES DISQUES
Simple de mise en œuvre
Protège contre les vols physiques
Conservation des fonctionnalités
de la BDD
Backup non chiffré
Si compromission de la machine,
les données sont en clair
À faire lors de l'installation de la
machine
CHIFFREMENT DE L'INSTANCE DE LA
BASE DE DONNÉES
Transparent Data Encryption
Protège contre l'exfiltration des
fichiers
Conservation des fonctionnalités
de la BDD
Backup fichier chiffré
Backup non chiffré via pg_dump
Si compromission de la BDD, les
données sont en clair
Nécessite une installation
CHIFFREMENT DES COLONNES DE LA
BASE DE DONNÉES
Aucune installation
supplémentaire
Backup chiffré
Perte de fonctionnalité de la BDD
(recherche, unicité, index, ...)
CHIFFREMENT DE LA DONNÉE PAR
L'APPLICATION
La BDD reçoit des données
chiffrées
Backup chiffré
Perte de fonctionnalité de la BDD
(recherche, unicité, index, ...)
CHIFFREMENT DE LA DONNÉE PAR LE
NAVIGATEUR
L'application et la BDD reçoivent
des données chiffrées
Backup chiffré
Perte de fonctionnalité de la BDD
(recherche, unicité, index, ...)
Pas de contrôle de données
Mauvaises expériences
PGCRYPTO
https://www.postgresql.org/docs/current/pgcrypto.htm
CREATE EXTENSION pgcrypto;
CHIFFREMENT
SELECT pgp_sym_encrypt(
'My value',
'secretKey'
);
-- xc30d04090302b...ea06ca101f8ece6f
DÉCHIFFREMENT
SELECT pgp_sym_decrypt(
'xc30d04090302b...ea06ca101f8ece6f',
'secretKey'
);
-- My value
ET MAINTENANT ?
Chiffrement dans la base de données
Création de vue des données déchiffrées
Création des tables chiffrées
Ajout de trigger de mise à jour sur la vue
CRÉATION DES TABLES CHIFFRÉES
CREATE TABLE private.candidate_form (
id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY
PRIMARY KEY,
first_name bytea,
last_name bytea,
pee_identifier bytea,
email bytea,
-- ...
);
CRÉATION DES VUES DÉCHIFFRÉES
Comment passer la clé secrète à la vue ?
LA CLÉ
SET application.key='mySecret';
-- ...
SELECT current_setting('application.key');
1
2
3
SET application.key='mySecret';
1
-- ...
2
SELECT current_setting('application.key');
3 SELECT current_setting('application.key');
SET application.key='mySecret';
1
-- ...
2
3
CRÉATION DES VUES DÉCHIFFRÉES
CREATE VIEW candidate_form AS
SELECT id,
pgp_sym_decrypt(
first_name,
current_setting('application.key')
) AS first_name,
-- ...
FROM private.candidate_form;
1
2
3
4
5
6
7
8
pgp_sym_decrypt(
first_name,
current_setting('application.key')
) AS first_name,
CREATE VIEW candidate_form AS
1
SELECT id,
2
3
4
5
6
-- ...
7
FROM private.candidate_form;
8
TRIGGER DE VUE : INSERT
CREATE FUNCTION encryption_insert() RETURNS trigger AS $$
BEGIN
INSERT INTO private.candidate_form (
first_name, -- ...
) VALUES (
pgp_sym_encrypt(
NEW.first_name,
current_setting('application.key')
), -- ...
);
return NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
1
2
3
4
5
6
7
8
9
10
11
12
13
INSERT INTO private.candidate_form (
first_name, -- ...
) VALUES (
pgp_sym_encrypt(
NEW.first_name,
current_setting('application.key')
), -- ...
);
return NEW;
CREATE FUNCTION encryption_insert() RETURNS trigger AS $$
1
BEGIN
2
3
4
5
6
7
8
9
10
11
END;
12
$$ LANGUAGE plpgsql SECURITY DEFINER;
13
pgp_sym_encrypt(
NEW.first_name,
current_setting('application.key')
), -- ...
);
CREATE FUNCTION encryption_insert() RETURNS trigger AS $$
1
BEGIN
2
INSERT INTO private.candidate_form (
3
first_name, -- ...
4
) VALUES (
5
6
7
8
9
10
return NEW;
11
END;
12
$$ LANGUAGE plpgsql SECURITY DEFINER;
13
TRIGGER DE VUE : UPDATE
CREATE FUNCTION encryption_update() RETURNS trigger AS $$
BEGIN
UPDATE private.candidate_form SET
first_name = pgp_sym_encrypt(
NEW.first_name,
current_setting('application.key')
),
-- ...
WHERE id = OLD.id;
return NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
1
2
3
4
5
6
7
8
9
10
11
12
UPDATE private.candidate_form SET
first_name = pgp_sym_encrypt(
NEW.first_name,
current_setting('application.key')
),
-- ...
WHERE id = OLD.id;
return NEW;
CREATE FUNCTION encryption_update() RETURNS trigger AS $$
1
BEGIN
2
3
4
5
6
7
8
9
10
END;
11
$$ LANGUAGE plpgsql SECURITY DEFINER;
12
first_name = pgp_sym_encrypt(
NEW.first_name,
current_setting('application.key')
),
-- ...
CREATE FUNCTION encryption_update() RETURNS trigger AS $$
1
BEGIN
2
UPDATE private.candidate_form SET
3
4
5
6
7
8
WHERE id = OLD.id;
9
return NEW;
10
END;
11
$$ LANGUAGE plpgsql SECURITY DEFINER;
12
LE HIC !
Pas de contrainte d'unicité => Trigger
TRIGGER D'UNICITÉ
CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$
DECLARE
pee_identifier_already_exists boolean;
BEGIN
SELECT count(pee_identifier) > 0
INTO pee_identifier_already_exists
FROM private.candidate_form
WHERE public.pgp_sym_decrypt(
pee_identifier,
current_setting('application.key')
) = public.pgp_sym_decrypt(
NEW.pee_identifier,
current_setting('application.key')
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FROM private.candidate_form
CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$
1
DECLARE
2
pee_identifier_already_exists boolean;
3
BEGIN
4
SELECT count(pee_identifier) > 0
5
INTO pee_identifier_already_exists
6
7
WHERE public.pgp_sym_decrypt(
8
pee_identifier,
9
current_setting('application.key')
10
) = public.pgp_sym_decrypt(
11
NEW.pee_identifier,
12
current_setting('application.key')
13
);
14
15
WHERE public.pgp_sym_decrypt(
pee_identifier,
current_setting('application.key')
) = public.pgp_sym_decrypt(
NEW.pee_identifier,
current_setting('application.key')
);
CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$
1
DECLARE
2
pee_identifier_already_exists boolean;
3
BEGIN
4
SELECT count(pee_identifier) > 0
5
INTO pee_identifier_already_exists
6
FROM private.candidate_form
7
8
9
10
11
12
13
14
15
SELECT count(pee_identifier) > 0
INTO pee_identifier_already_exists
CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$
1
DECLARE
2
pee_identifier_already_exists boolean;
3
BEGIN
4
5
6
FROM private.candidate_form
7
WHERE public.pgp_sym_decrypt(
8
pee_identifier,
9
current_setting('application.key')
10
) = public.pgp_sym_decrypt(
11
NEW.pee_identifier,
12
current_setting('application.key')
13
);
14
15
CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$
1
DECLARE
2
pee_identifier_already_exists boolean;
3
BEGIN
4
SELECT count(pee_identifier) > 0
5
INTO pee_identifier_already_exists
6
FROM private.candidate_form
7
WHERE public.pgp_sym_decrypt(
8
pee_identifier,
9
current_setting('application.key')
10
) = public.pgp_sym_decrypt(
11
NEW.pee_identifier,
12
current_setting('application.key')
13
);
14
15
CONCLUSION
Ça fait le job
Réalisé en quelques jours
Aucune modification serveur/service
BDD qui chiffre mais l'application a la clé
MAIS
Si mauvaise clé alors 💥
Questions ?
Chiffrement de base de données avec postgresql

Mais conteúdo relacionado

Semelhante a Chiffrement de base de données avec postgresql

Développement sécurisé d'applications avec Zend Framework
Développement sécurisé d'applications avec Zend FrameworkDéveloppement sécurisé d'applications avec Zend Framework
Développement sécurisé d'applications avec Zend FrameworkMickael Perraud
 
Tuto atelier securisation_site_web
Tuto atelier securisation_site_webTuto atelier securisation_site_web
Tuto atelier securisation_site_websahar dridi
 
Mise en place d’un système de détection
Mise en place d’un système de détectionMise en place d’un système de détection
Mise en place d’un système de détectionManassé Achim kpaya
 
Rapport atelier Web App Security 2015
Rapport atelier Web App Security 2015Rapport atelier Web App Security 2015
Rapport atelier Web App Security 2015Hamza Ben Marzouk
 
Quoi de neuf dans Zend Framework 1.10 ?
Quoi de neuf dans Zend Framework 1.10 ?Quoi de neuf dans Zend Framework 1.10 ?
Quoi de neuf dans Zend Framework 1.10 ?Mickael Perraud
 
Machine learning pour tous
Machine learning pour tousMachine learning pour tous
Machine learning pour tousDamien Seguy
 
Drupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptesDrupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptesSkilld
 
Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Xavier NOPRE
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonyVincent Composieux
 
Symfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantSymfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantHugo Hamon
 
2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...
2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...
2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...aOS Community
 
Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...
Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...
Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...Microsoft Décideurs IT
 
Alphorm.com Formation Windows ICD (Imaging Configuration Designer)
Alphorm.com Formation Windows ICD (Imaging Configuration Designer)Alphorm.com Formation Windows ICD (Imaging Configuration Designer)
Alphorm.com Formation Windows ICD (Imaging Configuration Designer)Alphorm
 
Mode offline et Synchronisation avec Windows Phone et Windows 8.1
Mode offline et Synchronisation avec Windows Phone et Windows 8.1Mode offline et Synchronisation avec Windows Phone et Windows 8.1
Mode offline et Synchronisation avec Windows Phone et Windows 8.1Microsoft
 
Qualité logicielle
Qualité logicielleQualité logicielle
Qualité logiciellecyrilgandon
 

Semelhante a Chiffrement de base de données avec postgresql (20)

Sécurité des données
Sécurité des donnéesSécurité des données
Sécurité des données
 
Développement sécurisé d'applications avec Zend Framework
Développement sécurisé d'applications avec Zend FrameworkDéveloppement sécurisé d'applications avec Zend Framework
Développement sécurisé d'applications avec Zend Framework
 
iTunes Stats
iTunes StatsiTunes Stats
iTunes Stats
 
Tuto atelier securisation_site_web
Tuto atelier securisation_site_webTuto atelier securisation_site_web
Tuto atelier securisation_site_web
 
Mise en place d’un système de détection
Mise en place d’un système de détectionMise en place d’un système de détection
Mise en place d’un système de détection
 
Sécurité MySQL
Sécurité MySQLSécurité MySQL
Sécurité MySQL
 
Rapport atelier Web App Security 2015
Rapport atelier Web App Security 2015Rapport atelier Web App Security 2015
Rapport atelier Web App Security 2015
 
rapportWAS
rapportWASrapportWAS
rapportWAS
 
Quoi de neuf dans Zend Framework 1.10 ?
Quoi de neuf dans Zend Framework 1.10 ?Quoi de neuf dans Zend Framework 1.10 ?
Quoi de neuf dans Zend Framework 1.10 ?
 
Machine learning pour tous
Machine learning pour tousMachine learning pour tous
Machine learning pour tous
 
La Sécurité Sur Le Web
La Sécurité Sur Le WebLa Sécurité Sur Le Web
La Sécurité Sur Le Web
 
Drupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptesDrupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptes
 
Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013Play framework - Human Talks Grenoble - 12.02.2013
Play framework - Human Talks Grenoble - 12.02.2013
 
Soutenance Zend Framework vs Symfony
Soutenance Zend Framework vs SymfonySoutenance Zend Framework vs Symfony
Soutenance Zend Framework vs Symfony
 
Symfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantSymfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 Performant
 
2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...
2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...
2019-06-12 aOS Aix Marseille - B4 - Gestion des comptes à privilèges - Jean-P...
 
Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...
Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...
Tester la sécurité de votre annuaire Active Directory : top 10 des menaces et...
 
Alphorm.com Formation Windows ICD (Imaging Configuration Designer)
Alphorm.com Formation Windows ICD (Imaging Configuration Designer)Alphorm.com Formation Windows ICD (Imaging Configuration Designer)
Alphorm.com Formation Windows ICD (Imaging Configuration Designer)
 
Mode offline et Synchronisation avec Windows Phone et Windows 8.1
Mode offline et Synchronisation avec Windows Phone et Windows 8.1Mode offline et Synchronisation avec Windows Phone et Windows 8.1
Mode offline et Synchronisation avec Windows Phone et Windows 8.1
 
Qualité logicielle
Qualité logicielleQualité logicielle
Qualité logicielle
 

Chiffrement de base de données avec postgresql

  • 1. HEU, IL FAUT CHIFFRER LES DONNÉES DE LA BASE ! ON FAIT COMMENT ?
  • 2. CONTEXTE Application web existante Opération ponctuelle Infrastructure existante
  • 3. POURQUOI CHIFFRER ? Protéger des données sensibles
  • 4. DE QUI ? De nous !
  • 5. QUE DOIT-ON CHIFFRER ? Tout ou partie ?
  • 6. QUEL CHIFFREMENT UTILISER ? Symétrique ou Asymétrique ?
  • 7. SYMÉTRIQUE Une seule clé pour chiffrer et déchiffrer
  • 8. ASYMÉTRIQUE Une paire de clé, publique/privée
  • 9. SALAGE OU PAS SALAGE ?
  • 12. CHIFFREMENT DES DISQUES Simple de mise en œuvre Protège contre les vols physiques Conservation des fonctionnalités de la BDD Backup non chiffré Si compromission de la machine, les données sont en clair À faire lors de l'installation de la machine
  • 13. CHIFFREMENT DE L'INSTANCE DE LA BASE DE DONNÉES Transparent Data Encryption Protège contre l'exfiltration des fichiers Conservation des fonctionnalités de la BDD Backup fichier chiffré Backup non chiffré via pg_dump Si compromission de la BDD, les données sont en clair Nécessite une installation
  • 14. CHIFFREMENT DES COLONNES DE LA BASE DE DONNÉES Aucune installation supplémentaire Backup chiffré Perte de fonctionnalité de la BDD (recherche, unicité, index, ...)
  • 15. CHIFFREMENT DE LA DONNÉE PAR L'APPLICATION La BDD reçoit des données chiffrées Backup chiffré Perte de fonctionnalité de la BDD (recherche, unicité, index, ...)
  • 16. CHIFFREMENT DE LA DONNÉE PAR LE NAVIGATEUR L'application et la BDD reçoivent des données chiffrées Backup chiffré Perte de fonctionnalité de la BDD (recherche, unicité, index, ...) Pas de contrôle de données Mauvaises expériences
  • 20. ET MAINTENANT ? Chiffrement dans la base de données Création de vue des données déchiffrées Création des tables chiffrées Ajout de trigger de mise à jour sur la vue
  • 21. CRÉATION DES TABLES CHIFFRÉES CREATE TABLE private.candidate_form ( id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, first_name bytea, last_name bytea, pee_identifier bytea, email bytea, -- ... );
  • 22. CRÉATION DES VUES DÉCHIFFRÉES Comment passer la clé secrète à la vue ?
  • 23. LA CLÉ SET application.key='mySecret'; -- ... SELECT current_setting('application.key'); 1 2 3 SET application.key='mySecret'; 1 -- ... 2 SELECT current_setting('application.key'); 3 SELECT current_setting('application.key'); SET application.key='mySecret'; 1 -- ... 2 3
  • 24. CRÉATION DES VUES DÉCHIFFRÉES CREATE VIEW candidate_form AS SELECT id, pgp_sym_decrypt( first_name, current_setting('application.key') ) AS first_name, -- ... FROM private.candidate_form; 1 2 3 4 5 6 7 8 pgp_sym_decrypt( first_name, current_setting('application.key') ) AS first_name, CREATE VIEW candidate_form AS 1 SELECT id, 2 3 4 5 6 -- ... 7 FROM private.candidate_form; 8
  • 25. TRIGGER DE VUE : INSERT CREATE FUNCTION encryption_insert() RETURNS trigger AS $$ BEGIN INSERT INTO private.candidate_form ( first_name, -- ... ) VALUES ( pgp_sym_encrypt( NEW.first_name, current_setting('application.key') ), -- ... ); return NEW; END; $$ LANGUAGE plpgsql SECURITY DEFINER; 1 2 3 4 5 6 7 8 9 10 11 12 13 INSERT INTO private.candidate_form ( first_name, -- ... ) VALUES ( pgp_sym_encrypt( NEW.first_name, current_setting('application.key') ), -- ... ); return NEW; CREATE FUNCTION encryption_insert() RETURNS trigger AS $$ 1 BEGIN 2 3 4 5 6 7 8 9 10 11 END; 12 $$ LANGUAGE plpgsql SECURITY DEFINER; 13 pgp_sym_encrypt( NEW.first_name, current_setting('application.key') ), -- ... ); CREATE FUNCTION encryption_insert() RETURNS trigger AS $$ 1 BEGIN 2 INSERT INTO private.candidate_form ( 3 first_name, -- ... 4 ) VALUES ( 5 6 7 8 9 10 return NEW; 11 END; 12 $$ LANGUAGE plpgsql SECURITY DEFINER; 13
  • 26. TRIGGER DE VUE : UPDATE CREATE FUNCTION encryption_update() RETURNS trigger AS $$ BEGIN UPDATE private.candidate_form SET first_name = pgp_sym_encrypt( NEW.first_name, current_setting('application.key') ), -- ... WHERE id = OLD.id; return NEW; END; $$ LANGUAGE plpgsql SECURITY DEFINER; 1 2 3 4 5 6 7 8 9 10 11 12 UPDATE private.candidate_form SET first_name = pgp_sym_encrypt( NEW.first_name, current_setting('application.key') ), -- ... WHERE id = OLD.id; return NEW; CREATE FUNCTION encryption_update() RETURNS trigger AS $$ 1 BEGIN 2 3 4 5 6 7 8 9 10 END; 11 $$ LANGUAGE plpgsql SECURITY DEFINER; 12 first_name = pgp_sym_encrypt( NEW.first_name, current_setting('application.key') ), -- ... CREATE FUNCTION encryption_update() RETURNS trigger AS $$ 1 BEGIN 2 UPDATE private.candidate_form SET 3 4 5 6 7 8 WHERE id = OLD.id; 9 return NEW; 10 END; 11 $$ LANGUAGE plpgsql SECURITY DEFINER; 12
  • 27. LE HIC ! Pas de contrainte d'unicité => Trigger
  • 28. TRIGGER D'UNICITÉ CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$ DECLARE pee_identifier_already_exists boolean; BEGIN SELECT count(pee_identifier) > 0 INTO pee_identifier_already_exists FROM private.candidate_form WHERE public.pgp_sym_decrypt( pee_identifier, current_setting('application.key') ) = public.pgp_sym_decrypt( NEW.pee_identifier, current_setting('application.key') ); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 FROM private.candidate_form CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$ 1 DECLARE 2 pee_identifier_already_exists boolean; 3 BEGIN 4 SELECT count(pee_identifier) > 0 5 INTO pee_identifier_already_exists 6 7 WHERE public.pgp_sym_decrypt( 8 pee_identifier, 9 current_setting('application.key') 10 ) = public.pgp_sym_decrypt( 11 NEW.pee_identifier, 12 current_setting('application.key') 13 ); 14 15 WHERE public.pgp_sym_decrypt( pee_identifier, current_setting('application.key') ) = public.pgp_sym_decrypt( NEW.pee_identifier, current_setting('application.key') ); CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$ 1 DECLARE 2 pee_identifier_already_exists boolean; 3 BEGIN 4 SELECT count(pee_identifier) > 0 5 INTO pee_identifier_already_exists 6 FROM private.candidate_form 7 8 9 10 11 12 13 14 15 SELECT count(pee_identifier) > 0 INTO pee_identifier_already_exists CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$ 1 DECLARE 2 pee_identifier_already_exists boolean; 3 BEGIN 4 5 6 FROM private.candidate_form 7 WHERE public.pgp_sym_decrypt( 8 pee_identifier, 9 current_setting('application.key') 10 ) = public.pgp_sym_decrypt( 11 NEW.pee_identifier, 12 current_setting('application.key') 13 ); 14 15 CREATE FUNCTION check_uniq() RETURNS TRIGGER AS $$ 1 DECLARE 2 pee_identifier_already_exists boolean; 3 BEGIN 4 SELECT count(pee_identifier) > 0 5 INTO pee_identifier_already_exists 6 FROM private.candidate_form 7 WHERE public.pgp_sym_decrypt( 8 pee_identifier, 9 current_setting('application.key') 10 ) = public.pgp_sym_decrypt( 11 NEW.pee_identifier, 12 current_setting('application.key') 13 ); 14 15
  • 29. CONCLUSION Ça fait le job Réalisé en quelques jours Aucune modification serveur/service BDD qui chiffre mais l'application a la clé
  • 30. MAIS Si mauvaise clé alors 💥