aries_cloudagent.multitenant package



aries_cloudagent.multitenant.askar_profile_manager module

aries_cloudagent.multitenant.base module

Manager for multitenancy.

class aries_cloudagent.multitenant.base.BaseMultitenantManager(profile: aries_cloudagent.core.profile.Profile)[source]

Bases: abc.ABC

Base class for handling multitenancy.

async create_auth_token(wallet_record: aries_cloudagent.wallet.models.wallet_record.WalletRecord, wallet_key: Optional[str] = None) str[source]

Create JWT auth token for specified wallet record.

  • wallet_record – The wallet record to create the token for

  • wallet_key – The wallet key to include in the token. Only required for “unmanaged” wallets


WalletKeyMissingError – If the wallet key is missing. Only thrown for “unmanaged” wallets


JWT auth token

Return type


async create_wallet(settings: dict, key_management_mode: str) aries_cloudagent.wallet.models.wallet_record.WalletRecord[source]

Create new wallet and wallet record.

  • settings – The context settings for this wallet

  • key_management_mode – The mode to use for key management. Either “unmanaged” to not store the wallet key, or “managed” to store the wallet key


MultitenantManagerError – If the wallet name already exists


The newly created wallet record

Return type


async get_default_mediator() Optional[aries_cloudagent.protocols.coordinate_mediation.v1_0.models.mediation_record.MediationRecord][source]

Retrieve the default mediator used for subwallet routing.


retrieved default mediator or None if not set

Return type


async get_profile_for_key(context: aries_cloudagent.config.injection_context.InjectionContext, recipient_key: str) Optional[aries_cloudagent.core.profile.Profile][source]

Retrieve a wallet profile by recipient key.

async get_profile_for_token(context: aries_cloudagent.config.injection_context.InjectionContext, token: str) aries_cloudagent.core.profile.Profile[source]

Get the profile associated with a JWT header token.

  • context – The context to use for profile creation

  • token – The token

  • WalletKeyMissingError – If the wallet_key is missing for an unmanaged wallet

  • InvalidTokenError – If there is an exception while decoding the token


Profile associated with the token

async get_wallet_and_profile(context: aries_cloudagent.config.injection_context.InjectionContext, wallet_id: str, wallet_key: str) Tuple[aries_cloudagent.wallet.models.wallet_record.WalletRecord, aries_cloudagent.core.profile.Profile][source]

Get the wallet_record and profile associated with wallet id and key.

get_wallet_details_from_token(token: str) Tuple[str, str][source]

Get the wallet_id and wallet_key from provided token.

abstract async get_wallet_profile(base_context: aries_cloudagent.config.injection_context.InjectionContext, wallet_record: aries_cloudagent.wallet.models.wallet_record.WalletRecord, extra_settings: dict = {}, *, provision=False) aries_cloudagent.core.profile.Profile[source]

Get profile for a wallet record.

  • base_context – Base context to extend from

  • wallet_record – Wallet record to get the context for

  • extra_settings – Any extra context settings


Profile for the wallet record

Return type


async get_wallets_by_message(message_body, wire_format: Optional[aries_cloudagent.transport.wire_format.BaseWireFormat] = None) List[aries_cloudagent.wallet.models.wallet_record.WalletRecord][source]

Get the wallet records associated with the message boy.

  • message_body – The body of the message

  • wire_format – Wire format to use for recipient detection


Wallet records associated with the message body

get_webhook_urls(base_context: aries_cloudagent.config.injection_context.InjectionContext, wallet_record: aries_cloudagent.wallet.models.wallet_record.WalletRecord) list[source]

Get the webhook urls according to dispatch_type.

  • base_context – Base context to get base_webhook_urls

  • wallet_record – Wallet record to get dispatch_type and webhook_urls


webhook urls according to dispatch_type

abstract property open_profiles: Iterable[aries_cloudagent.core.profile.Profile]

Return iterator over open profiles.

async remove_wallet(wallet_id: str, wallet_key: Optional[str] = None)[source]

Remove the wallet with specified wallet id.

  • wallet_id – The wallet id of the wallet record

  • wallet_key – The wallet key to open the wallet. Only required for “unmanaged” wallets


WalletKeyMissingError – If the wallet key is missing. Only thrown for “unmanaged” wallets

abstract async remove_wallet_profile(profile: aries_cloudagent.core.profile.Profile)[source]

Remove the wallet profile instance.


profile – The wallet profile instance

async update_wallet(wallet_id: str, new_settings: dict) aries_cloudagent.wallet.models.wallet_record.WalletRecord[source]

Update an existing wallet record.

  • wallet_id – The wallet id of the wallet record

  • new_settings – The context settings to be updated for this wallet


The updated wallet record

Return type


exception aries_cloudagent.multitenant.base.MultitenantManagerError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: aries_cloudagent.core.error.BaseError

Generic multitenant error.

aries_cloudagent.multitenant.cache module

Cache for multitenancy profiles.

class aries_cloudagent.multitenant.cache.ProfileCache(capacity: int)[source]

Bases: object

Profile cache that caches based on LRU strategy.

get(key: str) Optional[aries_cloudagent.core.profile.Profile][source]

Get profile with associated key from cache.

If a profile is open but has been evicted from the cache, this will reinsert the profile back into the cache. This prevents attempting to open a profile that is already open. Triggers clean up.


key (str) – the key to get the profile for.


Profile if found in cache.

Return type


has(key: str) bool[source]

Check whether there is a profile with associated key in the cache.


key (str) – the key to check for a profile


Whether the key exists in the cache

Return type


put(key: str, value: aries_cloudagent.core.profile.Profile) None[source]

Add profile with associated key to the cache.

If new profile exceeds the cache capacity least recently used profiles that are not used will be removed from the cache.

  • key (str) – the key to set

  • value (Profile) – the profile to set

remove(key: str)[source]

Remove profile with associated key from the cache.


key (str) – The key to remove from the cache.

aries_cloudagent.multitenant.error module

Multitenant error classes.

exception aries_cloudagent.multitenant.error.WalletKeyMissingError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: aries_cloudagent.core.error.BaseError

Wallet key missing exception.

aries_cloudagent.multitenant.manager module

aries_cloudagent.multitenant.manager_provider module

Profile manager for multitenancy.

class aries_cloudagent.multitenant.manager_provider.MultitenantManagerProvider(root_profile)[source]

Bases: aries_cloudagent.config.base.BaseProvider

Multitenant manager provider.

Decides which manager to use based on the settings.

MANAGER_TYPES = {'askar-profile': 'aries_cloudagent.multitenant.askar_profile_manager.AskarProfileMultitenantManager', 'basic': 'aries_cloudagent.multitenant.manager.MultitenantManager'}
askar_profile_manager_path = 'aries_cloudagent.multitenant.askar_profile_manager.AskarProfileMultitenantManager'
provide(settings: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Create the multitenant manager instance.

aries_cloudagent.multitenant.route_manager module

Multitenancy route manager.

class aries_cloudagent.multitenant.route_manager.BaseWalletRouteManager[source]

Bases: aries_cloudagent.protocols.coordinate_mediation.v1_0.route_manager.CoordinateMediationV1RouteManager

Route manager for operations specific to the base wallet.

async connection_from_recipient_key(profile: aries_cloudagent.core.profile.Profile, recipient_key: str) aries_cloudagent.connections.models.conn_record.ConnRecord[source]

Retrieve a connection by recipient key.

The recipient key is expected to be a local key owned by this agent.

Since the multi-tenant base wallet can receive and send keylist updates for sub wallets, we check the sub wallet’s connections before the base wallet.

class aries_cloudagent.multitenant.route_manager.MultitenantRouteManager(root_profile: aries_cloudagent.core.profile.Profile)[source]

Bases: aries_cloudagent.protocols.coordinate_mediation.v1_0.route_manager.RouteManager

Multitenancy route manager.

async get_base_wallet_mediator() Optional[aries_cloudagent.protocols.coordinate_mediation.v1_0.models.mediation_record.MediationRecord][source]

Get base wallet’s default mediator.

async mediation_records_for_connection(profile: aries_cloudagent.core.profile.Profile, conn_record: aries_cloudagent.connections.models.conn_record.ConnRecord, mediation_id: Optional[str] = None, or_default: bool = False) List[aries_cloudagent.protocols.coordinate_mediation.v1_0.models.mediation_record.MediationRecord][source]

Determine mediation records for a connection.

async routing_info(profile: aries_cloudagent.core.profile.Profile, mediation_record: Optional[aries_cloudagent.protocols.coordinate_mediation.v1_0.models.mediation_record.MediationRecord] = None) aries_cloudagent.protocols.coordinate_mediation.v1_0.route_manager.RoutingInfo[source]

Return routing info.