Skip to content

Commit

Permalink
feat: update global user principal (#487)
Browse files Browse the repository at this point in the history
use new global admin principal
ravi-sawlani-yral authored Jan 6, 2025
1 parent 1f23696 commit 9c2e9e0
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib/shared_utils/src/common/utils/permissions.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use ic_cdk::{api::is_controller, caller};
use candid::Principal;
use crate::constant::{GLOBAL_SUPER_ADMIN_USER_ID, GOVERNANCE_CANISTER_ID, RECLAIM_CANISTER_PRINCIPAL_ID};
use crate::constant::{GLOBAL_SUPER_ADMIN_USER_ID, GLOBAL_SUPER_ADMIN_USER_ID_V1, GOVERNANCE_CANISTER_ID, RECLAIM_CANISTER_PRINCIPAL_ID};

pub fn is_reclaim_canister_id() -> Result<(), String> {
let caller = ic_cdk::caller();
let reclaim_canister_principal = Principal::from_text(RECLAIM_CANISTER_PRINCIPAL_ID).unwrap();

// Here accessing the args ???
let valid_principals = vec![RECLAIM_CANISTER_PRINCIPAL_ID, GLOBAL_SUPER_ADMIN_USER_ID_V1];

if caller == reclaim_canister_principal {

if valid_principals.contains(&caller.to_string().as_ref()) {
Ok(())
} else {
Err("Caller is not allowed.".to_string())
@@ -17,7 +17,11 @@ pub fn is_reclaim_canister_id() -> Result<(), String> {


pub fn is_caller_global_admin() -> Result<(), String> {
if !caller().to_string().eq(GLOBAL_SUPER_ADMIN_USER_ID) {

let valid_canisters = vec![GLOBAL_SUPER_ADMIN_USER_ID_V1, GLOBAL_SUPER_ADMIN_USER_ID];


if !valid_canisters.contains(&caller().to_string().as_str()){
return Err("Unauthorize".into())
}
Ok(())
2 changes: 2 additions & 0 deletions src/lib/shared_utils/src/constant.rs
Original file line number Diff line number Diff line change
@@ -117,6 +117,8 @@ pub const NNS_LEDGER_CANISTER_ID: &str = "ryjl3-tyaaa-aaaaa-aaaba-cai";
pub const SNS_WASM_W_PRINCIPAL_ID: &'static str = "qaa6y-5yaaa-aaaaa-aaafa-cai";
pub const GLOBAL_SUPER_ADMIN_USER_ID: &str =
"7gaq2-4kttl-vtbt4-oo47w-igteo-cpk2k-57h3p-yioqe-wkawi-wz45g-jae";

pub const GLOBAL_SUPER_ADMIN_USER_ID_V1: &str = "zg7n3-345by-nqf6o-3moz4-iwxql-l6gko-jqdz2-56juu-ja332-unymr-fqe";
pub const RECLAIM_CANISTER_PRINCIPAL_ID: &str =
"7gaq2-4kttl-vtbt4-oo47w-igteo-cpk2k-57h3p-yioqe-wkawi-wz45g-jae";

0 comments on commit 9c2e9e0

Please sign in to comment.