didx-xyz / aries-cloudapi-python

Apache License 2.0
12 stars 8 forks source link

`wallet_scheme` appears to be ignored in `ACAPY_WALLET_STORAGE_CONFIG` #464

Closed rblaine95 closed 11 months ago

rblaine95 commented 1 year ago

According to hyperledger/aries-cloudagent-python, the ACAPY_WALLET_STORAGE_CONFIG environment variable maps to the Indy SDK Postgres Plugin

// https://github.com/hyperledger/indy-sdk/blob/main/experimental/plugins/postgres_storage/src/postgres_storage.rs#L377-L398
#[derive(Deserialize)]
pub struct PostgresConfig {
    url: String,
    tls: Option<String>,
    tls_ca: Option<String>,
    // default off
    max_connections: Option<u32>,
    // default 5
    min_idle_time: Option<u32>,
    // default 0, deprecated
    min_idle_count: Option<u32>,
    // default 0
    connection_timeout: Option<u64>,
    // default 5
    wallet_scheme: Option<WalletScheme>,   // default DatabasePerWallet
    database_name: Option<String>,   // default _WALLET_DB

    // For TLS
    #[serde(skip)]
    negotiator: Option<OpenSsl>,

}

It looks like wallet_scheme is being ignored when set via the ACAPY_WALLET_STORAGE_CONFIG environment variable (environments/governance-multitenant/aca-py-agent.default.env)

rblaine95 commented 1 year ago

🤔 https://github.com/hyperledger/aries-askar/blob/main/askar-storage/src/backend/postgres/provision.rs#L28-L41

rblaine95 commented 1 year ago
for ((i=0; i<10; i++)); do
curl -s -X 'POST' \
  'http://localhost:8100/admin/tenants' \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: adminApiKey' \
  -d @- <<EOF
{
  "image_url": "https://api.dicebear.com/7.x/pixel-art/svg?seed=somethingradnom",
  "name": "my-issuer",
  "roles": [
    "issuer"
  ],
  "group_id": "someGroup"
}
EOF
done

The above loop results in a Database Per Wallet being created, even if ACAPY_WALLET_STORAGE_CONFIG={"url":"governance-multitenant-wallets-db:5432","wallet_scheme":"MultiWalletSingleTable","max_connections":50}

rblaine95 commented 1 year ago

https://github.com/hyperledger/aries-cloudagent-python/issues/2043#issuecomment-1344532882 uses wallet_scheme https://github.com/hyperledger/aries-cloudagent-python/issues/2074#issuecomment-1402311748 uses scheme

ff137 commented 12 months ago

AFAICT, wallet_scheme is the key used in all examples, except for one where scheme is used. That one's probably wrong.

Here's a test that claims to "test_postgres_wallet_scheme_works": https://github.com/hyperledger/aries-cloudagent-python/blob/ac1dde304e92683ab50bb0f2b8cad298b918aa52/aries_cloudagent/wallet/tests/test_indy_wallet.py#L830

But the IndyWalletConfig object that it's creating, makes no mention of wallet_scheme, or scheme ..... https://github.com/hyperledger/aries-cloudagent-python/blob/ac1dde304e92683ab50bb0f2b8cad298b918aa52/aries_cloudagent/indy/sdk/wallet_setup.py#L24

So it does indeed seem to be specific to the postgres_storage plugin. Because the following test is for the postgres plugin, and it uses '{"wallet_scheme":"MultiWalletSingleTable"}': https://github.com/hyperledger/aries-cloudagent-python/blob/ac1dde304e92683ab50bb0f2b8cad298b918aa52/aries_cloudagent/indy/sdk/tests/test_wallet_plugin.py#L15

See load_postgres_plugin method: https://github.com/hyperledger/aries-cloudagent-python/blob/ac1dde304e92683ab50bb0f2b8cad298b918aa52/aries_cloudagent/indy/sdk/wallet_plugin.py#L51C1-L51C1

All of this seems to be fairly untouched code in the last 2-3 years ... especially the plugin itself is still under "experimental" and most of it hasn't changed in 4-5 years ... maybe there's newer, better ways to do things? :man_shrugging: Questions for the hyperledger team!

The relevant flag seems to be: --wallet-storage-type postgres_storage, which we do have set with: ACAPY_WALLET_STORAGE_TYPE=postgres_storage.

All I can think is that maybe the ACAPY_WALLET_STORAGE_CONFIG body needs to be escaped? i.e. "...,\"wallet_scheme\":\"MultiWalletSingleTable\"}". Probably not, that's just a shot in the dark. But must be some way to get this config passed to the plugin: https://github.com/hyperledger/indy-sdk/blob/main/experimental/plugins/postgres_storage/README.md#wallet-management-modes

That's as much as I can see at the moment!

rblaine95 commented 12 months ago

This looks very much related to didx-xyz/acapy-wallet-groups-plugin

Edit: It's not

ff137 commented 11 months ago

The following issue links to documentation for migrating indy wallets using MultiWalletSingleTable to askar: https://github.com/hyperledger/aries-acapy-tools/issues/7

ff137 commented 11 months ago

This seems to be what we're missing: --multitenancy-config As mentioned in aries-askar readme, to use wallet_type=askar-profile