juspay/hyperswitch

[FEAT] Add multitenancy support for keymanager

Open

#6,227 opened on Sep 23, 2024

View on GitHub
 (6 comments) (0 reactions) (1 assignee)Rust (42,690 stars) (4,676 forks)batch import
E-mediumRusthacktoberfesthelp wanted

Description

Description:

Cripta is a service which creates keys and maintains it (includes key rotation etc.) individually for different Merchants and Users.

The idea here is to segregate key data for each tenants logically by creating different schemas for different tenants. So in the service we need to maintain the connection between multiple schemas.

[!NOTE] We will get the tenant for which the current request should be run in X-tenant header.

Getting started:

Go through the README for guidelines on the structure and functionality.

Possible implementation:

  1. Add a config entry for multi-tenancy in this structure
[mult_tenancy]
tenant_name = { schema = "tenant_schema" }
  1. Add connections for different schemas for different tenants
struct AppState {
	// This will maintain connection pool for different schemas for tenants
	connections: HashMap<String, DieselConnectionPool>
}
  1. Add SessionState which will have the connections for the particular tenant
struct SessionState {
	pool: DieselConnectionPool
}

impl AppState {
	fn get_session_state(&self,tenant: &str) -> SessionState {
			return self.pool.get(tenant)
	}
}

Reference:

Submission Process:

  • Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
  • Once assigned, submit a pull request (PR).
  • Maintainers will review and provide feedback, if any.
  • Maintainers can unassign issues due to inactivity, read more here.
  • For this issue, please raise a PR on the https://github.com/juspay/hyperswitch-encryption-service repo, and link the issue.

Refer here for Terms and conditions for the contest.

Contributor guide