-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(keymanager): add tenant-id to keymanager requests #6968
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
impl Default for super::settings::GlobalTenant { | ||
fn default() -> Self { | ||
Self { | ||
tenant_id: id_type::TenantId::new_unchecked(String::new()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel passing in empty string here could cause issues when this value is being serialized/deserialized.
@Narayanbhat166 Correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the new_unchecked
does not validate the length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But deserialization would. So, even if the application does start running with the empty string as the tenant ID, and say the tenant ID is serialized / deserialized when writing to / reading from Redis, then the serialization may go through but the deserialization would fail, thus possibly causing an internal server error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't we have the default tenant id as well? isn't it global
?
@@ -794,7 +794,7 @@ sdk_eligible_payment_methods = "card" | |||
|
|||
[multitenancy] | |||
enabled = false | |||
global_tenant = { schema = "public", redis_key_prefix = "", clickhouse_database = "default"} | |||
global_tenant = { tenant_id = "global" ,schema = "public", redis_key_prefix = "global", clickhouse_database = "default"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you replicate similar changes in the other TOML config files which have global_tenant
configuration?
@@ -15,6 +15,13 @@ crate::impl_queryable_id_type!(TenantId); | |||
crate::impl_to_sql_from_sql_id_type!(TenantId); | |||
|
|||
impl TenantId { | |||
/// Construct TenantID without checking for length constraints | |||
pub fn new_unchecked(input_string: String) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should not be public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this public to be used in router crate :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then we can create the function which will create the tenant id with specified name, we cannot accept any generic string for unchecked functions.
Reference:
pub fn get_merchant_id_not_found() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
Type of Change
Description
Adds tenant-id for every requests to keymanager
Motivation and Context
Added tenant id header for the keymanager service to classify key ids based on tenants.
How did you test it?
public
x-request-id
for the request and query it in grafana and see the if the tenant_id ispublic
Checklist
cargo +nightly fmt --all
cargo clippy