Skip to content

Commit 2a92338

Browse files
committed
feat(backend): remove hardcoded unkey api ids
1 parent 425b96f commit 2a92338

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

apps/backend/src/main.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ async fn main() -> Result<()> {
7878
fs::write(config_dump_path, serde_json::to_string_pretty(&config)?)?;
7979
let is_pro = check_if_pro_license_available(&config.server.pro_key, &compile_timestamp).await;
8080

81+
ryot_log!(debug, "Is pro: {:#?}", is_pro);
82+
8183
let mut aws_conf = aws_sdk_s3::Config::builder()
8284
.region(Region::new(config.file_storage.s3_region.clone()))
8385
.force_path_style(true);
@@ -304,25 +306,21 @@ async fn check_if_pro_license_available(pro_key: &str, compilation_time: &DateTi
304306
use serde_with::skip_serializing_none;
305307
use unkey::{models::VerifyKeyRequest, Client};
306308

307-
#[cfg(debug_assertions)]
308-
const API_ID: &str = "api_4GvvJVbWobkNjcnnvFHmBP5pXb4K";
309-
#[cfg(not(debug_assertions))]
310-
const API_ID: &str = "api_LQTzbpPNHgPALgiNdxg8bMfVxeg";
311-
312-
ryot_log!(debug, "Verifying pro key for API ID: {}", API_ID);
313-
314-
if pro_key.is_empty() {
309+
let unkey_api_id = env::var("UNKEY_API_ID").unwrap_or_default();
310+
if pro_key.is_empty() || unkey_api_id.is_empty() {
315311
return false;
316312
}
317313

314+
ryot_log!(debug, "Verifying pro key for API ID: {:#?}", unkey_api_id);
315+
318316
#[skip_serializing_none]
319317
#[derive(Debug, Serialize, Clone, Deserialize)]
320318
struct Meta {
321319
expiry: Option<NaiveDate>,
322320
}
323321

324322
let unkey_client = Client::new("public");
325-
let verify_request = VerifyKeyRequest::new(pro_key, API_ID);
323+
let verify_request = VerifyKeyRequest::new(pro_key, &unkey_api_id);
326324
let validated_key = match unkey_client.verify_key(verify_request).await {
327325
Ok(verify_response) => {
328326
if !verify_response.valid {

0 commit comments

Comments
 (0)