taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

bank-manual.rst (13366B)


      1 ..
      2   This file is part of GNU TALER.
      3   Copyright (C) 2014-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 Affero General Public License as published by the Free Software
      7   Foundation; either version 3.0, 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 Affero General Public License for more details.
     12 
     13   You should have received a copy of the GNU Affero General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 
     16   @author Florian Dold
     17   @author Marcello Stanisci
     18   @author Christian Grothoff
     19 
     20 .. target audience: operator, developer
     21 
     22 .. _libeufin-bank:
     23 
     24 Bank Setup Manual
     25 #################
     26 
     27 libeufin-bank implements a simple core banking system with
     28 account and REST APIs, including REST APIs for a Web interface
     29 and REST APIs to interact with GNU Taler components.
     30 
     31 In this manual, we explain how to setup a bank.
     32 
     33 Installing LibEuFin Bank
     34 ========================
     35 
     36 The following section was tested on an *OpenJDK 17* environment.
     37 
     38 Installing the libeufin-bank binary packages on Debian
     39 ------------------------------------------------------
     40 
     41 .. include:: ../frags/installing-debian.rst
     42 
     43 .. include:: ../frags/apt-install-libeufin-bank.rst
     44 
     45 
     46 Installing the libeufin-bank binary packages on Ubuntu
     47 ------------------------------------------------------
     48 
     49 .. include:: ../frags/installing-ubuntu.rst
     50 
     51 .. include:: ../frags/apt-install-libeufin-bank.rst
     52 
     53 
     54 Building from source
     55 --------------------
     56 
     57 Bank belongs to the LibEuFin project, and can be downloaded via Git:
     58 
     59 .. code-block:: console
     60 
     61   $ git clone git://git.taler.net/libeufin
     62 
     63 In order to build and run LibEuFin, you must have GNU Make and the JDK 17
     64 installed and configured in your system. Note that the correct versions of
     65 Kotlin and Gradle will be installed automatically by the GNU Make script.
     66 
     67 Navigate into the *libeufin* local repository, and from top-level run:
     68 
     69 .. code-block:: console
     70 
     71   $ ./bootstrap
     72   $ ./configure --prefix=$PREFIX
     73   $ make install
     74 
     75 If the previous steps succeeded, the ``libeufin-bank`` command should
     76 be found in the $PATH.
     77 
     78 
     79 Minimal Configuration for LibEuFin Bank
     80 =======================================
     81 
     82 The following snippet shows the mandatory configuration values:
     83 
     84 .. code-block:: ini
     85 
     86   [libeufin-bank]
     87   CURRENCY = KUDOS
     88 
     89   # THe public URL that the bank will be served under
     90   BASE_URL = https://bank.taler.net
     91 
     92   # Supported payment target type
     93   WIRE_TYPE = iban or x-taler-bank
     94   # If WIRE_TYPE = iban
     95   IBAN_PAYTO_BIC = SANDBOXX
     96 
     97 .. note::
     98   Refer to the manpage ``libeufin-man.conf(5)``
     99   for the full array of configuration values.
    100 
    101 Configuring password storage
    102 ----------------------------
    103 
    104 libeufin-bank uses secure password hashing algorithms to store user passwords. For the moment, only ``bcrypt`` is supported. The default configuration is:
    105 
    106 .. code-block:: ini
    107 
    108   [libeufin-bank]
    109   PWD_HASH_ALGORITHM = bcrypt
    110   PWD_HASH_CONFIG = { "cost": 8 }
    111 
    112 As password authentication is used frequently, password hashing should only take a few milliseconds. If your server's CPU is too weak, you should reduce the ``cost`` and you may want to increase it otherwise. You can measure the password hashing speed using the following command:
    113 
    114 .. code-block:: console
    115 
    116   $ libeufin-bank bench-pwh -c "$CONFIG_FILE"
    117 
    118 .. _libeufin-mfa:
    119 
    120 Configuring multi-factor authentication
    121 ---------------------------------------
    122 
    123 libeufin-bank supports two-factor authentication. libeufin-bank uses helper scripts to send challenge codes to addresses for multi-factor authentication. We provide two default helper scripts: ``libeufin-tan-email.sh`` to send e-mails and ``libeufin-tan-sms.sh`` to send SMS. To enable two-factor authentication you need to configure at least one TAN channel.
    124 
    125 Authentication lockout and throttling
    126 ++++++++++++++++++++++++++++++++++++++
    127 
    128 Password authentication is used to obtain access tokens; normal Core Bank API
    129 operations use those tokens.  A wrong password by itself does not lock an
    130 account, because usernames are public and that policy would let an attacker
    131 lock out another user.  Deployments must rate-limit the token-creation endpoint
    132 at the ingress layer to bound password-hashing work.
    133 
    134 For an account protected by multi-factor authentication, repeated failed
    135 confirmation of token-creation challenges can lock creation of new tokens.
    136 Existing tokens remain usable.  An authenticated user with an existing token
    137 can recover by changing the password; otherwise an administrator must set a
    138 new password.  Clients can observe the account's ``locked`` status and the
    139 token endpoint reports ``TALER_EC_BANK_ACCOUNT_LOCKED``.
    140 
    141 The bank permits concurrent challenges for use on multiple devices, but caps
    142 the number of pending challenges per account as well as retransmissions and
    143 confirmation attempts.  Challenge hints must not expose a complete email
    144 address or telephone number.  Operators must still throttle challenge
    145 creation and delivery at the ingress layer to protect external SMS and mail
    146 services.  The exact endpoint responses are specified by the
    147 :doc:`../core/api-corebank`.
    148 
    149 SMS TAN channel
    150 +++++++++++++++
    151 
    152 The default ``libeufin-tan-sms.sh`` script is based on the `Telesign <https://www.telesign.com>`_ SMS provider. It requires an additional ``TELESIGN_AUTH_TOKEN`` environment variable for `Telesign Basic authentication <https://developer.telesign.com/enterprise/docs/authentication#basic-authentication>`_.
    153 
    154 To test your setup run:
    155 
    156 .. code-block:: console
    157 
    158   $ TELESIGN_AUTH_TOKEN=$TELESIGN_TOKEN
    159   $ echo "Test 1234" | libeufin-tan-sms.sh $PHONE
    160 
    161 If you received an SMS containing "Test 1234" you can enable this channel in the config:
    162 
    163 .. code-block:: ini
    164 
    165   [libeufin-bank]
    166   TAN_SMS = libeufin-tan-sms.sh
    167   TAN_SMS_ENV = "TELESIGN_AUTH_TOKEN=$TELESIGN_TOKEN"
    168 
    169 Mail TAN channel
    170 ++++++++++++++++
    171 
    172 The default ``libeufin-tan-email.sh`` script is based on the ``mail`` Linux command. It requires a working local mail transfer agent.
    173 
    174 To test your setup run:
    175 
    176 .. code-block:: console
    177 
    178   $ echo "Test 1234" | libeufin-tan-email.sh $EMAIL
    179 
    180 If you received an email containing "Test 1234" you can enable this channel in the config:
    181 
    182 .. code-block:: ini
    183 
    184   [libeufin-bank]
    185   TAN_EMAIL = libeufin-tan-email.sh
    186 
    187 Custom TAN channel scripts
    188 ++++++++++++++++++++++++++
    189 
    190 It is possible to replace these scripts with custom scripts to send
    191 the e-mail or SMS TAN. Such alternative scripts must accept the phone number / e-mail address as the ``$1`` parameter and the message content to be transmitted in their standard input.  They should return 0 to indicate successful transmission of the challenge and non-zero on failure.
    192 
    193 To change the scripts used for multi-factor authentication, change the following
    194 options in the configuration file:
    195 
    196 .. code-block:: ini
    197 
    198   [libeufin-bank]
    199   TAN_SMS = custom-tan-sms.sh
    200   TAN_SMS_ENV =
    201   TAN_EMAIL = custom-tan-email.sh
    202   TAN_EMAIL_ENV =
    203 
    204 Launching libeufin-bank
    205 =======================
    206 
    207 Assuming that the configuration file exists at ``$CONFIG_FILE``, the following
    208 command initializes (or upgrades) the database schema:
    209 
    210 .. code-block:: console
    211 
    212   $ libeufin-bank-dbinit -c "$CONFIG_FILE"
    213 
    214 Once this is done, you can start the libeufin-bank HTTP server:
    215 
    216 .. code-block:: console
    217 
    218   $ libeufin-bank serve -c "$CONFIG_FILE"
    219 
    220 
    221 Using the bank Web interface
    222 ============================
    223 
    224 To be able to use the Web interface, you must set a password for the "admin"
    225 account.  You can set (or reset) the account password to ``$PASSWORD`` using
    226 the following command:
    227 
    228 .. code-block:: console
    229 
    230   $ libeufin-bank passwd -c "$CONFIG_FILE" admin "$PASSWORD"
    231 
    232 You can also use the same command to reset the passwords of other accounts by
    233 replacing "admin" with the respective login.
    234 
    235 
    236 Setting up accounts
    237 -------------------
    238 
    239 Using the above "$PASSWORD", log into the Web interface as "admin". To setup
    240 regular accounts, search for the button "Create account" near the list of all
    241 existing bank accounts in the Web interface of libeufin-bank.
    242 
    243 You will be asked to specify:
    244 
    245 Username
    246   A unique account name the user will use to access the bank account.
    247 
    248 Name
    249   Legal name of the user or business owning the account.
    250 
    251 Email
    252   E-mail address of the account owner. Can be used to send a TAN message for 2-factor authentication (if enabled).
    253 
    254 Phone
    255   Mobile phone number of the account owner. Can be used to send a TAN message for 2-factor authentication (if enabled).
    256 
    257 Max debt
    258   Maximum amount the account is allowed to go into debt. Non-zero settings **must** be used for the "admin" account where this setting effectively creates a limit on the amount of money managed by the bank.
    259 
    260 Is this a Taler Exchange?
    261   Should be disabled except if you are setting up an account for a GNU Taler exchange. If enabled, transactions that are not compatible with a GNU Taler exchange will be automatically refused by the bank.
    262 
    263 XXX Cashout channel
    264   Used in a regional currency setup to specify the external account number of a bank account in fiat currency that belongs to the merchant. Allows the merchant to exchange its regional currency money for wire transfers in fiat currency into this account. Optional. Not available unless the bank is configured for regional currencies.
    265 
    266 Is this account public?
    267   Public accounts can be viewed without access control.  Their balance, payto
    268   URI and complete existing and future transaction history become public.
    269   Transaction disclosure includes wire subjects and both parties' payto URIs;
    270   it is not redacted.  Changing an account from private to public immediately
    271   exposes its old history as well.  Accounts that were already public before
    272   this Core Bank API v12 correction are automatically subject to the same
    273   disclosure, so operators should review them before upgrading.
    274 
    275 After submitting the form, a randomly created password for the new account
    276 will be shown in a notification.  The administrator can also change passwords
    277 for any account in the system using the "change password" link in the account
    278 list. To change other details about an account, select the "Username" in the
    279 account list.
    280 
    281 
    282 Account introspection
    283 ---------------------
    284 
    285 Users can see (and possibly change) the settings of their bank account and
    286 also their IBAN by clicking on the "Welcome, $USERNAME" text after logging
    287 into their bank account using their username and password.
    288 
    289 The IBAN field has a convenient "copy to clipboard" button next to it.
    290 
    291 
    292 Making transfers between accounts
    293 ---------------------------------
    294 
    295 First, you need to know the IBAN of the account to credit, and log in as the
    296 user of the account to be debited. Then select "Using a form", enter the IBAN
    297 under "Recipient" and specify a wire transfer subject and the total amount to
    298 be wired. After pressing "Send", you may have to pass a 2-FA check.
    299 
    300 
    301 Integration with the Taler Exchange
    302 ===================================
    303 
    304 .. note::
    305 
    306   This step is fully automated if you use the :doc:`automated setup manual<../regional/regional-automated-manual>`.
    307 
    308 You must have an exchange account with username ``exchange`` for conversion to work.
    309 Assuming that the configuration file exists at ``$CONFIG_FILE``, the following
    310 command would create one:
    311 
    312 .. code-block:: console
    313 
    314   $ libeufin-bank create-account '{"username":"exchange","password":"$EXCHANGE_PASSWORD","name":"Cashout Exchange","is_taler_exchange":true}' -c "$CONFIG_FILE"
    315 
    316 .. note::
    317 
    318    You can also set up the exchange account as "admin" using the Web interface of libeufin-bank.
    319 
    320 Having done so, take note of two key pieces of information, namely the ``$EXCHANGE_PASSWORD`` and the "payto://"-URI of the exchange bank account.  This information must then be used to configure the exchange as described in
    321 :ref:`exchange bank account configuration <exchange-account-signing>`.  When using the libeufin-bank in the context
    322 of a regional currency with conversion, you must
    323 additionally specify a "conversion-url" when setting
    324 up the exchange account. See the section on :ref:`conversion setup <regional-conversion-setup>` in the regional currency setup chapter for details.
    325 
    326 
    327 Withdrawing e-cash to a Taler wallet
    328 ====================================
    329 
    330 .. note::
    331 
    332   This step is fully automated if you use the :doc:`automated setup manual<../regional/regional-automated-manual>`.
    333 
    334 Users can withdraw digital cash from their bank account starting from their
    335 online banking as implemented by the libeufin-bank. However, in this scenario,
    336 the Taler wallet may not already know about an exchange that works with the
    337 respective currency.  Thus, the protocol includes the possibility of the bank
    338 *recommending* an exchange service to the wallet, thus providing a sane
    339 default for the wallet to suggest to the user.  To do so, the base URL of the
    340 exchange API must be specified in the libeufin-bank configuration:
    341 
    342 .. code-block:: ini
    343 
    344   [libeufin-bank]
    345   DEFAULT_EXCHANGE=${PROTO}://exchange.${DOMAIN_NAME}
    346 
    347 After changing this value, the libeufin-bank service needs to be restarted
    348 to make the change effective.
    349 
    350 .. note::
    351 
    352   The user may change the default exchange from within the wallet, assuming they know of an alternative exchange for the currency.