Skip to content

Commit

Permalink
refactor(events): Adding changes to type of API events to Kafka (#2992)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 837480d commit d63f6f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions crates/router/src/events/api_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ pub struct ApiEvent {
status_code: i64,
#[serde(flatten)]
auth_type: AuthenticationType,
request: serde_json::Value,
request: String,
user_agent: Option<String>,
ip_addr: Option<String>,
url_path: String,
response: Option<serde_json::Value>,
response: Option<String>,
error: Option<serde_json::Value>,
#[serde(flatten)]
event_type: ApiEventsType,
Expand All @@ -59,12 +59,12 @@ impl ApiEvent {
) -> Self {
Self {
api_flow: api_flow.to_string(),
created_at_timestamp: OffsetDateTime::now_utc().unix_timestamp_nanos(),
created_at_timestamp: OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000_000,
request_id: request_id.as_hyphenated().to_string(),
latency,
status_code,
request,
response,
request: request.to_string(),
response: response.map(|resp| resp.to_string()),
auth_type,
error,
ip_addr: http_req
Expand Down
22 changes: 11 additions & 11 deletions crates/router/src/services/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ pub enum AuthenticationType {
key_id: String,
},
AdminApiKey,
MerchantJWT {
MerchantJwt {
merchant_id: String,
user_id: Option<String>,
},
MerchantID {
MerchantId {
merchant_id: String,
},
PublishableKey {
Expand All @@ -70,9 +70,9 @@ impl AuthenticationType {
merchant_id,
key_id: _,
}
| Self::MerchantID { merchant_id }
| Self::MerchantId { merchant_id }
| Self::PublishableKey { merchant_id }
| Self::MerchantJWT {
| Self::MerchantJwt {
merchant_id,
user_id: _,
}
Expand Down Expand Up @@ -352,7 +352,7 @@ where
};
Ok((
auth.clone(),
AuthenticationType::MerchantID {
AuthenticationType::MerchantId {
merchant_id: auth.merchant_account.merchant_id.clone(),
},
))
Expand Down Expand Up @@ -423,7 +423,7 @@ where

Ok((
(),
AuthenticationType::MerchantJWT {
AuthenticationType::MerchantJwt {
merchant_id: payload.merchant_id,
user_id: Some(payload.user_id),
},
Expand Down Expand Up @@ -451,7 +451,7 @@ where
org_id: payload.org_id,
role_id: payload.role_id,
},
AuthenticationType::MerchantJWT {
AuthenticationType::MerchantJwt {
merchant_id: payload.merchant_id,
user_id: Some(payload.user_id),
},
Expand Down Expand Up @@ -479,13 +479,13 @@ where
let permissions = authorization::get_permissions(&payload.role_id)?;
authorization::check_authorization(&self.required_permission, permissions)?;

// Check if token has access to merchantID that has been requested through query param
// Check if token has access to MerchantId that has been requested through query param
if payload.merchant_id != self.merchant_id {
return Err(report!(errors::ApiErrorResponse::InvalidJwtToken));
}
Ok((
(),
AuthenticationType::MerchantJWT {
AuthenticationType::MerchantJwt {
merchant_id: payload.merchant_id,
user_id: Some(payload.user_id),
},
Expand Down Expand Up @@ -549,7 +549,7 @@ where
};
Ok((
auth.clone(),
AuthenticationType::MerchantJWT {
AuthenticationType::MerchantJwt {
merchant_id: auth.merchant_account.merchant_id.clone(),
user_id: None,
},
Expand Down Expand Up @@ -579,7 +579,7 @@ where
org_id: payload.org_id,
role_id: payload.role_id,
},
AuthenticationType::MerchantJWT {
AuthenticationType::MerchantJwt {
merchant_id: payload.merchant_id,
user_id: Some(payload.user_id),
},
Expand Down

0 comments on commit d63f6f7

Please sign in to comment.