libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

libeufin-bank-0014.sql (2174B)


      1 --
      2 -- This file is part of TALER
      3 -- Copyright (C) 2025 Taler Systems SA
      4 --
      5 -- TALER is free software; you can redistribute it and/or modify it under the
      6 -- terms of the GNU General Public License as published by the Free Software
      7 -- Foundation; either version 3, or (at your option) any later version.
      8 --
      9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11 -- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 --
     13 -- You should have received a copy of the GNU General Public License along with
     14 -- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 
     16 BEGIN;
     17 
     18 SELECT _v.register_patch('libeufin-bank-0014', NULL, NULL);
     19 
     20 SET search_path TO libeufin_bank;
     21 
     22 -- Cashout request UID need to be null for code triggered cashouts
     23 ALTER TABLE cashout_operations DROP CONSTRAINT cashout_operations_pkey;
     24 ALTER TABLE cashout_operations ADD CONSTRAINT request_uid_unique UNIQUE (request_uid);
     25 ALTER TABLE cashout_operations ALTER COLUMN request_uid DROP NOT NULL;
     26 
     27 -- Allow user accounts to have many tan channels
     28 ALTER TABLE customers
     29   ADD COLUMN tan_channels tan_enum[] NOT NULL DEFAULT ARRAY[]::tan_enum[];
     30 UPDATE customers 
     31   SET tan_channels = ARRAY[tan_channel]
     32   WHERE tan_channel IS NOT NULL;
     33 ALTER TABLE customers DROP COLUMN tan_channel;
     34 
     35 -- Only store salted body hash in challenges
     36 TRUNCATE TABLE tan_challenges;
     37 ALTER TABLE tan_challenges 
     38   DROP COLUMN body, 
     39   ADD COLUMN uuid UUID NOT NULL,
     40   ADD COLUMN hbody BYTEA NOT NULL CHECK (LENGTH(hbody)=64),
     41   ADD COLUMN salt BYTEA NOT NULL CHECK (LENGTH(salt)=16),
     42   ALTER COLUMN tan_channel SET NOT NULL,
     43   ALTER COLUMN tan_info SET NOT NULL;
     44 COMMENT ON COLUMN tan_challenges.hbody
     45   IS 'Salted hash of the body of the original request that triggered the challenge, to be replayed once the challenge is satisfied.';
     46 COMMENT ON COLUMN tan_challenges.salt
     47   IS 'Salt used when hashing the original body.';
     48 
     49 CREATE INDEX tan_challenges_uuid_index ON tan_challenges (uuid);
     50 
     51 -- Add new token scope 'observability'
     52 ALTER TYPE token_scope_enum ADD VALUE 'observability';
     53 
     54 COMMIT;