-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbilling_adapter.rs
More file actions
45 lines (41 loc) · 1.77 KB
/
Copy pathbilling_adapter.rs
File metadata and controls
45 lines (41 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! The single permitted gkg-server↔gkg-billing seam.
//!
//! Billing logic lives in `crates/gkg-billing/`. The only data that crosses
//! the boundary is `BillingInputs` (defined there). This file is the
//! complete declaration of which `auth::Claims` fields populate that struct.
//! All billing-related call sites in gkg-server consume `BillingInputs`
//! built via this `From` impl — they never construct `BillingInputs`
//! directly. Per SOX boundary policy, this file plus the `gkg-billing`
//! crate are the entire auditable surface for billing in this repository.
use gkg_billing::{BillingInputs, QuotaCheckInputs};
use crate::auth::Claims;
impl From<&Claims> for BillingInputs {
fn from(c: &Claims) -> Self {
Self {
realm: c.realm.clone(),
user_id: c.user_id as i64,
source_type: <&str>::from(c.source_type).to_string(),
organization_id: c.organization_id.map(|id| id as i64),
instance_id: c.instance_id.clone(),
unique_instance_id: c.unique_instance_id.clone(),
instance_version: c.instance_version.clone(),
global_user_id: c.global_user_id.clone(),
host_name: c.host_name.clone(),
root_namespace_id: c.root_namespace_id,
deployment_type: c.deployment_type.clone(),
}
}
}
impl From<&Claims> for QuotaCheckInputs {
fn from(c: &Claims) -> Self {
Self {
source_type: <&str>::from(c.source_type).to_string(),
user_id: c.user_id as i64,
realm: c.realm.clone(),
global_user_id: c.global_user_id.clone(),
root_namespace_id: c.root_namespace_id,
instance_id: c.instance_id.clone(),
unique_instance_id: c.unique_instance_id.clone(),
}
}
}